diff options
author | Andrew Bartlett <abartlet@samba.org> | 2003-01-02 09:07:17 +0000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2003-01-02 09:07:17 +0000 |
commit | 92a777d0eaa4fb3a1c7835816f93c6bdd456816d (patch) | |
tree | df854338df6d4dbff5d654d23dc8ff18c67f24da /source/tdb | |
parent | 5d6c1810330b38e48355078b7a5d53e7b5076f74 (diff) | |
download | samba-92a777d0eaa4fb3a1c7835816f93c6bdd456816d.tar.gz samba-92a777d0eaa4fb3a1c7835816f93c6bdd456816d.tar.xz samba-92a777d0eaa4fb3a1c7835816f93c6bdd456816d.zip |
BIG patch...
This patch makes Samba compile cleanly with -Wwrite-strings.
- That is, all string literals are marked as 'const'. These strings are
always read only, this just marks them as such for passing to other functions.
What is most supprising is that I didn't need to change more than a few lines of code (all
in 'net', which got a small cleanup of net.h and extern variables). The rest
is just adding a lot of 'const'.
As far as I can tell, I have not added any new warnings - apart from making all
of tdbutil.c's function const (so they warn for adding that const string to
struct).
Andrew Bartlett
Diffstat (limited to 'source/tdb')
-rw-r--r-- | source/tdb/tdbutil.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/source/tdb/tdbutil.c b/source/tdb/tdbutil.c index 12db8b337f7..d7e4350ada9 100644 --- a/source/tdb/tdbutil.c +++ b/source/tdb/tdbutil.c @@ -73,7 +73,7 @@ static int tdb_chainlock_with_timeout( TDB_CONTEXT *tdb, TDB_DATA key, unsigned Lock a chain by string. Return -1 if timeout or lock failed. ****************************************************************************/ -int tdb_lock_bystring(TDB_CONTEXT *tdb, char *keyval, unsigned int timeout) +int tdb_lock_bystring(TDB_CONTEXT *tdb, const char *keyval, unsigned int timeout) { TDB_DATA key; @@ -87,7 +87,7 @@ int tdb_lock_bystring(TDB_CONTEXT *tdb, char *keyval, unsigned int timeout) Unlock a chain by string. ****************************************************************************/ -void tdb_unlock_bystring(TDB_CONTEXT *tdb, char *keyval) +void tdb_unlock_bystring(TDB_CONTEXT *tdb, const char *keyval) { TDB_DATA key; @@ -101,7 +101,7 @@ void tdb_unlock_bystring(TDB_CONTEXT *tdb, char *keyval) Read lock a chain by string. Return -1 if timeout or lock failed. ****************************************************************************/ -int tdb_read_lock_bystring(TDB_CONTEXT *tdb, char *keyval, unsigned int timeout) +int tdb_read_lock_bystring(TDB_CONTEXT *tdb, const char *keyval, unsigned int timeout) { TDB_DATA key; @@ -115,7 +115,7 @@ int tdb_read_lock_bystring(TDB_CONTEXT *tdb, char *keyval, unsigned int timeout) Read unlock a chain by string. ****************************************************************************/ -void tdb_read_unlock_bystring(TDB_CONTEXT *tdb, char *keyval) +void tdb_read_unlock_bystring(TDB_CONTEXT *tdb, const char *keyval) { TDB_DATA key; @@ -131,7 +131,7 @@ void tdb_read_unlock_bystring(TDB_CONTEXT *tdb, char *keyval) Output is int32 in native byte order. ****************************************************************************/ -int32 tdb_fetch_int32_byblob(TDB_CONTEXT *tdb, char *keyval, size_t len) +int32 tdb_fetch_int32_byblob(TDB_CONTEXT *tdb, const char *keyval, size_t len) { TDB_DATA key, data; int32 ret; @@ -154,7 +154,7 @@ int32 tdb_fetch_int32_byblob(TDB_CONTEXT *tdb, char *keyval, size_t len) Output is int32 in native byte order. ****************************************************************************/ -int32 tdb_fetch_int32(TDB_CONTEXT *tdb, char *keystr) +int32 tdb_fetch_int32(TDB_CONTEXT *tdb, const char *keystr) { return tdb_fetch_int32_byblob(tdb, keystr, strlen(keystr) + 1); } @@ -164,7 +164,7 @@ int32 tdb_fetch_int32(TDB_CONTEXT *tdb, char *keystr) Input is int32 in native byte order. Output in tdb is in little-endian. ****************************************************************************/ -int tdb_store_int32_byblob(TDB_CONTEXT *tdb, char *keystr, size_t len, int32 v) +int tdb_store_int32_byblob(TDB_CONTEXT *tdb, const char *keystr, size_t len, int32 v) { TDB_DATA key, data; int32 v_store; @@ -183,7 +183,7 @@ int tdb_store_int32_byblob(TDB_CONTEXT *tdb, char *keystr, size_t len, int32 v) Input is int32 in native byte order. Output in tdb is in little-endian. ****************************************************************************/ -int tdb_store_int32(TDB_CONTEXT *tdb, char *keystr, int32 v) +int tdb_store_int32(TDB_CONTEXT *tdb, const char *keystr, int32 v) { return tdb_store_int32_byblob(tdb, keystr, strlen(keystr) + 1, v); } @@ -193,7 +193,7 @@ int tdb_store_int32(TDB_CONTEXT *tdb, char *keystr, int32 v) Output is uint32 in native byte order. ****************************************************************************/ -BOOL tdb_fetch_uint32_byblob(TDB_CONTEXT *tdb, char *keyval, size_t len, uint32 *value) +BOOL tdb_fetch_uint32_byblob(TDB_CONTEXT *tdb, const char *keyval, size_t len, uint32 *value) { TDB_DATA key, data; @@ -215,7 +215,7 @@ BOOL tdb_fetch_uint32_byblob(TDB_CONTEXT *tdb, char *keyval, size_t len, uint32 Output is uint32 in native byte order. ****************************************************************************/ -BOOL tdb_fetch_uint32(TDB_CONTEXT *tdb, char *keystr, uint32 *value) +BOOL tdb_fetch_uint32(TDB_CONTEXT *tdb, const char *keystr, uint32 *value) { return tdb_fetch_uint32_byblob(tdb, keystr, strlen(keystr) + 1, value); } @@ -225,7 +225,7 @@ BOOL tdb_fetch_uint32(TDB_CONTEXT *tdb, char *keystr, uint32 *value) Input is uint32 in native byte order. Output in tdb is in little-endian. ****************************************************************************/ -BOOL tdb_store_uint32_byblob(TDB_CONTEXT *tdb, char *keystr, size_t len, uint32 value) +BOOL tdb_store_uint32_byblob(TDB_CONTEXT *tdb, const char *keystr, size_t len, uint32 value) { TDB_DATA key, data; uint32 v_store; @@ -248,7 +248,7 @@ BOOL tdb_store_uint32_byblob(TDB_CONTEXT *tdb, char *keystr, size_t len, uint32 Input is uint32 in native byte order. Output in tdb is in little-endian. ****************************************************************************/ -BOOL tdb_store_uint32(TDB_CONTEXT *tdb, char *keystr, uint32 value) +BOOL tdb_store_uint32(TDB_CONTEXT *tdb, const char *keystr, uint32 value) { return tdb_store_uint32_byblob(tdb, keystr, strlen(keystr) + 1, value); } @@ -257,7 +257,7 @@ BOOL tdb_store_uint32(TDB_CONTEXT *tdb, char *keystr, uint32 value) on failure. ****************************************************************************/ -int tdb_store_by_string(TDB_CONTEXT *tdb, char *keystr, TDB_DATA data, int flags) +int tdb_store_by_string(TDB_CONTEXT *tdb, const char *keystr, TDB_DATA data, int flags) { TDB_DATA key; @@ -272,7 +272,7 @@ int tdb_store_by_string(TDB_CONTEXT *tdb, char *keystr, TDB_DATA data, int flags free() on the result dptr. ****************************************************************************/ -TDB_DATA tdb_fetch_by_string(TDB_CONTEXT *tdb, char *keystr) +TDB_DATA tdb_fetch_by_string(TDB_CONTEXT *tdb, const char *keystr) { TDB_DATA key; @@ -286,7 +286,7 @@ TDB_DATA tdb_fetch_by_string(TDB_CONTEXT *tdb, char *keystr) Delete an entry using a null terminated string key. ****************************************************************************/ -int tdb_delete_by_string(TDB_CONTEXT *tdb, char *keystr) +int tdb_delete_by_string(TDB_CONTEXT *tdb, const char *keystr) { TDB_DATA key; @@ -300,7 +300,7 @@ int tdb_delete_by_string(TDB_CONTEXT *tdb, char *keystr) Atomic integer change. Returns old value. To create, set initial value in *oldval. ****************************************************************************/ -int32 tdb_change_int32_atomic(TDB_CONTEXT *tdb, char *keystr, int32 *oldval, int32 change_val) +int32 tdb_change_int32_atomic(TDB_CONTEXT *tdb, const char *keystr, int32 *oldval, int32 change_val) { int32 val; int32 ret = -1; @@ -341,7 +341,7 @@ int32 tdb_change_int32_atomic(TDB_CONTEXT *tdb, char *keystr, int32 *oldval, int Atomic unsigned integer change. Returns old value. To create, set initial value in *oldval. ****************************************************************************/ -BOOL tdb_change_uint32_atomic(TDB_CONTEXT *tdb, char *keystr, uint32 *oldval, uint32 change_val) +BOOL tdb_change_uint32_atomic(TDB_CONTEXT *tdb, const char *keystr, uint32 *oldval, uint32 change_val) { uint32 val; BOOL ret = False; @@ -384,7 +384,7 @@ BOOL tdb_change_uint32_atomic(TDB_CONTEXT *tdb, char *keystr, uint32 *oldval, ui integers and strings. ****************************************************************************/ -size_t tdb_pack(char *buf, int bufsize, char *fmt, ...) +size_t tdb_pack(char *buf, int bufsize, const char *fmt, ...) { va_list ap; uint16 w; @@ -395,7 +395,7 @@ size_t tdb_pack(char *buf, int bufsize, char *fmt, ...) char *s; char c; char *buf0 = buf; - char *fmt0 = fmt; + const char *fmt0 = fmt; int bufsize0 = bufsize; va_start(ap, fmt); @@ -468,7 +468,7 @@ size_t tdb_pack(char *buf, int bufsize, char *fmt, ...) integers and strings. ****************************************************************************/ -int tdb_unpack(char *buf, int bufsize, char *fmt, ...) +int tdb_unpack(char *buf, int bufsize, const char *fmt, ...) { va_list ap; uint16 *w; @@ -479,7 +479,7 @@ int tdb_unpack(char *buf, int bufsize, char *fmt, ...) char *s, **b; char c; char *buf0 = buf; - char *fmt0 = fmt; + const char *fmt0 = fmt; int bufsize0 = bufsize; va_start(ap, fmt); |