[dm-devel] [PATCH 32/42] Make 'allocated' an integer in vector.h
Hannes Reinecke
hare at suse.de
Tue Jan 8 13:54:10 UTC 2013
I don't trust the programmers here, as we're unconditionally
decreasing the 'allocated' setting on vector_free().
So better make that an integer to catch underflows.
Signed-off-by: Hannes Reinecke <hare at suse.de>
---
libmultipath/vector.c | 2 +-
libmultipath/vector.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libmultipath/vector.c b/libmultipath/vector.c
index 74079a4..dcf69bf 100644
--- a/libmultipath/vector.c
+++ b/libmultipath/vector.c
@@ -114,7 +114,7 @@ vector_del_slot(vector v, int slot)
v->allocated -= VECTOR_DEFAULT_SIZE;
- if (!v->allocated) {
+ if (v->allocated <= 0) {
FREE(v->slot);
v->slot = NULL;
v->allocated = 0;
diff --git a/libmultipath/vector.h b/libmultipath/vector.h
index 6779186..7612b4c 100644
--- a/libmultipath/vector.h
+++ b/libmultipath/vector.h
@@ -25,7 +25,7 @@
/* vector definition */
struct _vector {
- unsigned int allocated;
+ int allocated;
void **slot;
};
typedef struct _vector *vector;
--
1.7.4.2
More information about the dm-devel
mailing list