[PATCH 32/42] Make 'allocated' an integer in vector.h

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx>
---
 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

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel


[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux