diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2011-06-20 18:40:31 +0930 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2011-06-20 11:18:35 +0200 |
commit | 6bc59d77b64d1ecbe5c906ed2fa80a7b8ca5d420 (patch) | |
tree | 616215df22728c5e4e95cf20f80ff62051274531 /lib/util | |
parent | 1078eb21c49d707ddeef2257353f35c10d131b9f (diff) | |
download | samba-6bc59d77b64d1ecbe5c906ed2fa80a7b8ca5d420.tar.gz samba-6bc59d77b64d1ecbe5c906ed2fa80a7b8ca5d420.tar.bz2 samba-6bc59d77b64d1ecbe5c906ed2fa80a7b8ca5d420.zip |
tdb_store: check returns for 0, not -1.
TDB2 returns a negative error number on failure. This is compatible
if we always check for != 0 instead of == -1.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'lib/util')
-rw-r--r-- | lib/util/util_tdb.c | 14 | ||||
-rw-r--r-- | lib/util/util_tdb.h | 10 |
2 files changed, 12 insertions, 12 deletions
diff --git a/lib/util/util_tdb.c b/lib/util/util_tdb.c index 2dd5f9dd5f..304239f951 100644 --- a/lib/util/util_tdb.c +++ b/lib/util/util_tdb.c @@ -133,7 +133,7 @@ int32_t tdb_fetch_int32(struct tdb_context *tdb, const char *keystr) } /**************************************************************************** - Store a int32_t value by an arbitrary blob key, return 0 on success, -1 on failure. + Store a int32_t value by an arbitrary blob key, return 0 on success, -ve on failure. Input is int32_t in native byte order. Output in tdb is in little-endian. ****************************************************************************/ @@ -150,7 +150,7 @@ int tdb_store_int32_byblob(struct tdb_context *tdb, TDB_DATA key, int32_t v) } /**************************************************************************** - Store a int32_t value by string key, return 0 on success, -1 on failure. + Store a int32_t value by string key, return 0 on success, -ve on failure. Input is int32_t in native byte order. Output in tdb is in little-endian. ****************************************************************************/ @@ -190,7 +190,7 @@ bool tdb_fetch_uint32(struct tdb_context *tdb, const char *keystr, uint32_t *val } /**************************************************************************** - Store a uint32_t value by an arbitrary blob key, return 0 on success, -1 on failure. + Store a uint32_t value by an arbitrary blob key, return true on success, false on failure. Input is uint32_t in native byte order. Output in tdb is in little-endian. ****************************************************************************/ @@ -204,14 +204,14 @@ bool tdb_store_uint32_byblob(struct tdb_context *tdb, TDB_DATA key, uint32_t val data.dptr = (unsigned char *)&v_store; data.dsize = sizeof(uint32_t); - if (tdb_store(tdb, key, data, TDB_REPLACE) == -1) + if (tdb_store(tdb, key, data, TDB_REPLACE) != 0) ret = false; return ret; } /**************************************************************************** - Store a uint32_t value by string key, return 0 on success, -1 on failure. + Store a uint32_t value by string key, return true on success, false on failure. Input is uint32_t in native byte order. Output in tdb is in little-endian. ****************************************************************************/ @@ -220,7 +220,7 @@ bool tdb_store_uint32(struct tdb_context *tdb, const char *keystr, uint32_t valu return tdb_store_uint32_byblob(tdb, string_term_tdb_data(keystr), value); } /**************************************************************************** - Store a buffer by a null terminated string key. Return 0 on success, -1 + Store a buffer by a null terminated string key. Return 0 on success, -ve on failure. ****************************************************************************/ @@ -284,7 +284,7 @@ int32_t tdb_change_int32_atomic(struct tdb_context *tdb, const char *keystr, int /* Increment value for storage and return next time */ val += change_val; - if (tdb_store_int32(tdb, keystr, val) == -1) + if (tdb_store_int32(tdb, keystr, val) != 0) goto err_out; ret = 0; diff --git a/lib/util/util_tdb.h b/lib/util/util_tdb.h index 92b88bacb4..edffa058d7 100644 --- a/lib/util/util_tdb.h +++ b/lib/util/util_tdb.h @@ -63,13 +63,13 @@ int32_t tdb_fetch_int32_byblob(struct tdb_context *tdb, TDB_DATA key); int32_t tdb_fetch_int32(struct tdb_context *tdb, const char *keystr); /**************************************************************************** - Store a int32_t value by an arbitrary blob key, return 0 on success, -1 on failure. + Store a int32_t value by an arbitrary blob key, return 0 on success, -ve on failure. Input is int32_t in native byte order. Output in tdb is in little-endian. ****************************************************************************/ int tdb_store_int32_byblob(struct tdb_context *tdb, TDB_DATA key, int32_t v); /**************************************************************************** - Store a int32_t value by string key, return 0 on success, -1 on failure. + Store a int32_t value by string key, return 0 on success, -ve on failure. Input is int32_t in native byte order. Output in tdb is in little-endian. ****************************************************************************/ int tdb_store_int32(struct tdb_context *tdb, const char *keystr, int32_t v); @@ -87,19 +87,19 @@ bool tdb_fetch_uint32_byblob(struct tdb_context *tdb, TDB_DATA key, uint32_t *va bool tdb_fetch_uint32(struct tdb_context *tdb, const char *keystr, uint32_t *value); /**************************************************************************** - Store a uint32_t value by an arbitrary blob key, return 0 on success, -1 on failure. + Store a uint32_t value by an arbitrary blob key, return true on success, false on failure. Input is uint32_t in native byte order. Output in tdb is in little-endian. ****************************************************************************/ bool tdb_store_uint32_byblob(struct tdb_context *tdb, TDB_DATA key, uint32_t value); /**************************************************************************** - Store a uint32_t value by string key, return 0 on success, -1 on failure. + Store a uint32_t value by string key, return true on success, false on failure. Input is uint32_t in native byte order. Output in tdb is in little-endian. ****************************************************************************/ bool tdb_store_uint32(struct tdb_context *tdb, const char *keystr, uint32_t value); /**************************************************************************** - Store a buffer by a null terminated string key. Return 0 on success, -1 + Store a buffer by a null terminated string key. Return 0 on success, -ve on failure. ****************************************************************************/ int tdb_store_bystring(struct tdb_context *tdb, const char *keystr, TDB_DATA data, int flags); |