diff options
author | Volker Lendecke <vl@samba.org> | 2008-02-25 15:24:49 +0100 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2008-02-25 16:09:26 +0100 |
commit | 317639287886181edf08ccecad1b324e4cc55d0b (patch) | |
tree | 8388cbc402ff784babdfcd892daa87090497a8a1 /source3/lib | |
parent | cd95385207ff2a9c27031dcff19b7b74df3a626f (diff) | |
download | samba-317639287886181edf08ccecad1b324e4cc55d0b.tar.gz samba-317639287886181edf08ccecad1b324e4cc55d0b.tar.bz2 samba-317639287886181edf08ccecad1b324e4cc55d0b.zip |
Fix some warnings
warning: ignoring return value of 'asprintf', declared with attribute warn_unused_result
(This used to be commit ad37b7b0aee265a3e4d8b7552610f4b9a105434d)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/debug.c | 10 | ||||
-rw-r--r-- | source3/lib/gencache.c | 12 | ||||
-rw-r--r-- | source3/lib/util_sock.c | 3 | ||||
-rw-r--r-- | source3/lib/util_str.c | 30 | ||||
-rw-r--r-- | source3/lib/util_tdb.c | 16 |
5 files changed, 36 insertions, 35 deletions
diff --git a/source3/lib/debug.c b/source3/lib/debug.c index 9ff267b607..c4a0d1b47b 100644 --- a/source3/lib/debug.c +++ b/source3/lib/debug.c @@ -827,6 +827,7 @@ void check_log_size( void ) }; int priority; char *msgbuf = NULL; + int ret; if( syslog_level >= ( sizeof(priority_map) / sizeof(priority_map[0]) ) || syslog_level < 0) priority = LOG_DEBUG; @@ -834,10 +835,10 @@ void check_log_size( void ) priority = priority_map[syslog_level]; va_start(ap, format_str); - vasprintf(&msgbuf, format_str, ap); + ret = vasprintf(&msgbuf, format_str, ap); va_end(ap); - if (msgbuf) { + if (ret == -1) { syslog(priority, "%s", msgbuf); } SAFE_FREE(msgbuf); @@ -1059,12 +1060,13 @@ bool dbghdr(int level, int cls, const char *file, const char *func, int line) va_list ap; char *msgbuf = NULL; bool ret = true; + int res; va_start(ap, format_str); - vasprintf(&msgbuf, format_str, ap); + res = vasprintf(&msgbuf, format_str, ap); va_end(ap); - if (msgbuf) { + if (res != -1) { format_debug_text(msgbuf); } else { ret = false; diff --git a/source3/lib/gencache.c b/source3/lib/gencache.c index 663385cfe3..6131269adb 100644 --- a/source3/lib/gencache.c +++ b/source3/lib/gencache.c @@ -120,9 +120,9 @@ bool gencache_set(const char *keystr, const char *value, time_t timeout) if (!gencache_init()) return False; - asprintf(&valstr, CACHE_DATA_FMT, (int)timeout, value); - if (!valstr) + if (asprintf(&valstr, CACHE_DATA_FMT, (int)timeout, value) == -1) { return False; + } databuf = string_term_tdb_data(valstr); DEBUG(10, ("Adding cache entry with key = %s; value = %s and timeout =" @@ -340,8 +340,7 @@ bool gencache_set_data_blob(const char *keystr, DATA_BLOB *blob, time_t timeout) return False; } - asprintf(&valstr, "%12u/%s", (int)timeout, BLOB_TYPE); - if (!valstr) { + if (asprintf(&valstr, "%12u/%s", (int)timeout, BLOB_TYPE) == -1) { return False; } @@ -452,8 +451,9 @@ void gencache_iterate(void (*fn)(const char* key, const char *value, time_t time break; } - asprintf(&fmt, READ_CACHE_DATA_FMT_TEMPLATE, (unsigned int)databuf.dsize - TIMEOUT_LEN); - if (!fmt) { + if (asprintf(&fmt, READ_CACHE_DATA_FMT_TEMPLATE, + (unsigned int)databuf.dsize - TIMEOUT_LEN) + == -1) { SAFE_FREE(valstr); SAFE_FREE(entry); SAFE_FREE(keystr); diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index e040f4631a..a7c35c4887 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -1904,8 +1904,7 @@ int create_pipe_sock(const char *socket_dir, goto out_close; } - asprintf(&path, "%s/%s", socket_dir, socket_name); - if (!path) { + if (asprintf(&path, "%s/%s", socket_dir, socket_name) == -1) { goto out_close; } diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index f631dfffee..cb8a100fa7 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -2086,6 +2086,7 @@ static char *ipstr_list_add(char **ipstr_list, const struct ip_service *service) { char *new_ipstr = NULL; char addr_buf[INET6_ADDRSTRLEN]; + int ret; /* arguments checking */ if (!ipstr_list || !service) { @@ -2100,33 +2101,30 @@ static char *ipstr_list_add(char **ipstr_list, const struct ip_service *service) if (*ipstr_list) { if (service->ss.ss_family == AF_INET) { /* IPv4 */ - asprintf(&new_ipstr, "%s%s%s:%d", - *ipstr_list, - IPSTR_LIST_SEP, - addr_buf, - service->port); + ret = asprintf(&new_ipstr, "%s%s%s:%d", *ipstr_list, + IPSTR_LIST_SEP, addr_buf, + service->port); } else { /* IPv6 */ - asprintf(&new_ipstr, "%s%s[%s]:%d", - *ipstr_list, - IPSTR_LIST_SEP, - addr_buf, - service->port); + ret = asprintf(&new_ipstr, "%s%s[%s]:%d", *ipstr_list, + IPSTR_LIST_SEP, addr_buf, + service->port); } SAFE_FREE(*ipstr_list); } else { if (service->ss.ss_family == AF_INET) { /* IPv4 */ - asprintf(&new_ipstr, "%s:%d", - addr_buf, - service->port); + ret = asprintf(&new_ipstr, "%s:%d", addr_buf, + service->port); } else { /* IPv6 */ - asprintf(&new_ipstr, "[%s]:%d", - addr_buf, - service->port); + ret = asprintf(&new_ipstr, "[%s]:%d", addr_buf, + service->port); } } + if (ret == -1) { + return NULL; + } *ipstr_list = new_ipstr; return *ipstr_list; } diff --git a/source3/lib/util_tdb.c b/source3/lib/util_tdb.c index dd5ebcd7ab..724832ea5b 100644 --- a/source3/lib/util_tdb.c +++ b/source3/lib/util_tdb.c @@ -669,12 +669,13 @@ static void tdb_log(TDB_CONTEXT *tdb, enum tdb_debug_level level, const char *fo { va_list ap; char *ptr = NULL; + int ret; va_start(ap, format); - vasprintf(&ptr, format, ap); + ret = vasprintf(&ptr, format, ap); va_end(ap); - if (!ptr || !*ptr) + if ((ret == -1) || !*ptr) return; DEBUG((int)level, ("tdb(%s): %s", tdb_name(tdb) ? tdb_name(tdb) : "unnamed", ptr)); @@ -867,11 +868,8 @@ static void tdb_wrap_log(TDB_CONTEXT *tdb, enum tdb_debug_level level, va_list ap; char *ptr = NULL; int debuglevel = 0; + int ret; - va_start(ap, format); - vasprintf(&ptr, format, ap); - va_end(ap); - switch (level) { case TDB_DEBUG_FATAL: debug_level = 0; @@ -889,7 +887,11 @@ static void tdb_wrap_log(TDB_CONTEXT *tdb, enum tdb_debug_level level, debuglevel = 0; } - if (ptr != NULL) { + va_start(ap, format); + ret = vasprintf(&ptr, format, ap); + va_end(ap); + + if (ret != -1) { const char *name = tdb_name(tdb); DEBUG(debuglevel, ("tdb(%s): %s", name ? name : "unnamed", ptr)); free(ptr); |