tdb: Fix some signed/unsigned hickups
authorVolker Lendecke <vl@samba.org>
Mon, 7 Nov 2016 20:38:58 +0000 (21:38 +0100)
committerJeremy Allison <jra@samba.org>
Mon, 10 Apr 2017 18:44:21 +0000 (20:44 +0200)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
lib/tdb/common/lock.c

index 195dbb5daf265c8d8f997a3ccdd81fe7b642945c..594c28751f1d68c8305bd225f228c437fee81c9e 100644 (file)
@@ -294,7 +294,7 @@ fail:
 static struct tdb_lock_type *find_nestlock(struct tdb_context *tdb,
                                           tdb_off_t offset)
 {
-       unsigned int i;
+       int i;
 
        for (i=0; i<tdb->num_lockrecs; i++) {
                if (tdb->lockrecs[i].off == offset) {
@@ -381,7 +381,7 @@ static int tdb_lock_and_recover(struct tdb_context *tdb)
 
 static bool have_data_locks(const struct tdb_context *tdb)
 {
-       unsigned int i;
+       int i;
 
        for (i = 0; i < tdb->num_lockrecs; i++) {
                if (tdb->lockrecs[i].off >= lock_offset(-1))
@@ -560,7 +560,8 @@ static int tdb_allrecord_check(struct tdb_context *tdb, int ltype,
                return -1;
        }
 
-       if (tdb->allrecord_lock.count && tdb->allrecord_lock.ltype == ltype) {
+       if (tdb->allrecord_lock.count &&
+           tdb->allrecord_lock.ltype == (uint32_t)ltype) {
                tdb->allrecord_lock.count++;
                return 0;
        }
@@ -706,7 +707,7 @@ int tdb_allrecord_unlock(struct tdb_context *tdb, int ltype, bool mark_lock)
        }
 
        /* Upgradable locks are marked as write locks. */
-       if (tdb->allrecord_lock.ltype != ltype
+       if (tdb->allrecord_lock.ltype != (uint32_t)ltype
            && (!tdb->allrecord_lock.off || ltype != F_RDLCK)) {
                tdb->ecode = TDB_ERR_LOCK;
                return -1;
@@ -945,7 +946,8 @@ bool tdb_have_extra_locks(struct tdb_context *tdb)
 /* The transaction code uses this to remove all locks. */
 void tdb_release_transaction_locks(struct tdb_context *tdb)
 {
-       unsigned int i, active = 0;
+       int i;
+       unsigned int active = 0;
 
        if (tdb->allrecord_lock.count != 0) {
                tdb_allrecord_unlock(tdb, tdb->allrecord_lock.ltype, false);