summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2008-02-25 15:24:49 +0100
committerVolker Lendecke <vl@samba.org>2008-02-25 16:09:26 +0100
commitad37b7b0aee265a3e4d8b7552610f4b9a105434d (patch)
tree56230430209f118f60cae5379b14576cc55590c4
parent71641f04d4e9a41775e898f2e4ac3c8792783cd3 (diff)
downloadsamba-ad37b7b0aee265a3e4d8b7552610f4b9a105434d.tar.gz
samba-ad37b7b0aee265a3e4d8b7552610f4b9a105434d.tar.xz
samba-ad37b7b0aee265a3e4d8b7552610f4b9a105434d.zip
Fix some warnings
warning: ignoring return value of 'asprintf', declared with attribute warn_unused_result
-rw-r--r--source/intl/lang_tdb.c11
-rw-r--r--source/lib/debug.c10
-rw-r--r--source/lib/gencache.c12
-rw-r--r--source/lib/util_sock.c3
-rw-r--r--source/lib/util_str.c30
-rw-r--r--source/lib/util_tdb.c16
-rw-r--r--source/libads/kerberos.c22
-rw-r--r--source/librpc/ndr/ndr.c22
-rw-r--r--source/librpc/ndr/ndr_basic.c3
-rw-r--r--source/librpc/ndr/ndr_string.c3
-rw-r--r--source/libsmb/clifsinfo.c3
-rw-r--r--source/param/loadparm.c3
-rw-r--r--source/passdb/machine_sid.c5
13 files changed, 86 insertions, 57 deletions
diff --git a/source/intl/lang_tdb.c b/source/intl/lang_tdb.c
index bb780c5feda..6ad9ef8496b 100644
--- a/source/intl/lang_tdb.c
+++ b/source/intl/lang_tdb.c
@@ -127,7 +127,11 @@ bool lang_tdb_init(const char *lang)
if (!lang)
return True;
- asprintf(&msg_path, "%s.msg", data_path((const char *)lang));
+ if (asprintf(&msg_path, "%s.msg",
+ data_path((const char *)lang)) == -1) {
+ DEBUG(0, ("asprintf failed\n"));
+ goto done;
+ }
if (stat(msg_path, &st) != 0) {
/* the msg file isn't available */
DEBUG(10, ("lang_tdb_init: %s: %s\n", msg_path,
@@ -135,7 +139,10 @@ bool lang_tdb_init(const char *lang)
goto done;
}
- asprintf(&path, "%s%s.tdb", lock_path("lang_"), lang);
+ if (asprintf(&path, "%s%s.tdb", lock_path("lang_"), lang) == -1) {
+ DEBUG(0, ("asprintf failed\n"));
+ goto done;
+ }
DEBUG(10, ("lang_tdb_init: loading %s\n", path));
diff --git a/source/lib/debug.c b/source/lib/debug.c
index 9ff267b6079..c4a0d1b47be 100644
--- a/source/lib/debug.c
+++ b/source/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/source/lib/gencache.c b/source/lib/gencache.c
index 663385cfe3d..6131269adbd 100644
--- a/source/lib/gencache.c
+++ b/source/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/source/lib/util_sock.c b/source/lib/util_sock.c
index e040f4631a0..a7c35c48878 100644
--- a/source/lib/util_sock.c
+++ b/source/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/source/lib/util_str.c b/source/lib/util_str.c
index f631dfffeed..cb8a100fa7b 100644
--- a/source/lib/util_str.c
+++ b/source/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/source/lib/util_tdb.c b/source/lib/util_tdb.c
index dd5ebcd7ab5..724832ea5bb 100644
--- a/source/lib/util_tdb.c
+++ b/source/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);
diff --git a/source/libads/kerberos.c b/source/libads/kerberos.c
index d47e8a3ff1c..b37b9a500fb 100644
--- a/source/libads/kerberos.c
+++ b/source/libads/kerberos.c
@@ -407,8 +407,8 @@ static char *kerberos_secrets_fetch_salting_principal(const char *service, int e
char *key = NULL;
char *ret = NULL;
- asprintf(&key, "%s/%s/enctype=%d", SECRETS_SALTING_PRINCIPAL, service, enctype);
- if (!key) {
+ if (asprintf(&key, "%s/%s/enctype=%d",
+ SECRETS_SALTING_PRINCIPAL, service, enctype) == -1) {
return NULL;
}
ret = (char *)secrets_fetch(key, NULL);
@@ -438,7 +438,10 @@ static char* des_salt_key( void )
{
char *key;
- asprintf(&key, "%s/DES/%s", SECRETS_SALTING_PRINCIPAL, lp_realm());
+ if (asprintf(&key, "%s/DES/%s", SECRETS_SALTING_PRINCIPAL,
+ lp_realm()) == -1) {
+ return NULL;
+ }
return key;
}
@@ -609,9 +612,13 @@ bool kerberos_secrets_store_salting_principal(const char *service,
return False;
}
if (strchr_m(service, '@')) {
- asprintf(&princ_s, "%s", service);
+ if (asprintf(&princ_s, "%s", service) == -1) {
+ goto out;
+ }
} else {
- asprintf(&princ_s, "%s@%s", service, lp_realm());
+ if (asprintf(&princ_s, "%s@%s", service, lp_realm()) == -1) {
+ goto out;
+ }
}
if (smb_krb5_parse_name(context, princ_s, &princ) != 0) {
@@ -622,8 +629,9 @@ bool kerberos_secrets_store_salting_principal(const char *service,
goto out;
}
- asprintf(&key, "%s/%s/enctype=%d", SECRETS_SALTING_PRINCIPAL, unparsed_name, enctype);
- if (!key) {
+ if (asprintf(&key, "%s/%s/enctype=%d",
+ SECRETS_SALTING_PRINCIPAL, unparsed_name, enctype)
+ == -1) {
goto out;
}
diff --git a/source/librpc/ndr/ndr.c b/source/librpc/ndr/ndr.c
index 62a88a88562..53eff00d59c 100644
--- a/source/librpc/ndr/ndr.c
+++ b/source/librpc/ndr/ndr.c
@@ -176,12 +176,16 @@ _PUBLIC_ void ndr_print_debug_helper(struct ndr_print *ndr, const char *format,
{
va_list ap;
char *s = NULL;
- int i;
+ int i, ret;
va_start(ap, format);
- vasprintf(&s, format, ap);
+ ret = vasprintf(&s, format, ap);
va_end(ap);
+ if (ret == -1) {
+ return;
+ }
+
for (i=0;i<ndr->depth;i++) {
DEBUGADD(0,(" "));
}
@@ -450,11 +454,16 @@ _PUBLIC_ enum ndr_err_code ndr_pull_error(struct ndr_pull *ndr,
{
char *s=NULL;
va_list ap;
+ int ret;
va_start(ap, format);
- vasprintf(&s, format, ap);
+ ret = vasprintf(&s, format, ap);
va_end(ap);
+ if (ret == -1) {
+ return NDR_ERR_ALLOC;
+ }
+
DEBUG(3,("ndr_pull_error(%u): %s\n", ndr_err, s));
free(s);
@@ -471,11 +480,16 @@ _PUBLIC_ enum ndr_err_code ndr_push_error(struct ndr_push *ndr,
{
char *s=NULL;
va_list ap;
+ int ret;
va_start(ap, format);
- vasprintf(&s, format, ap);
+ ret = vasprintf(&s, format, ap);
va_end(ap);
+ if (ret == -1) {
+ return NDR_ERR_ALLOC;
+ }
+
DEBUG(3,("ndr_push_error(%u): %s\n", ndr_err, s));
free(s);
diff --git a/source/librpc/ndr/ndr_basic.c b/source/librpc/ndr/ndr_basic.c
index 54397c9469b..f342c6e36f9 100644
--- a/source/librpc/ndr/ndr_basic.c
+++ b/source/librpc/ndr/ndr_basic.c
@@ -773,8 +773,7 @@ _PUBLIC_ void ndr_print_array_uint8(struct ndr_print *ndr, const char *name,
ndr->depth++;
for (i=0;i<count;i++) {
char *idx=NULL;
- asprintf(&idx, "[%d]", i);
- if (idx) {
+ if (asprintf(&idx, "[%d]", i) != -1) {
ndr_print_uint8(ndr, idx, data[i]);
free(idx);
}
diff --git a/source/librpc/ndr/ndr_string.c b/source/librpc/ndr/ndr_string.c
index 711dbce5383..e553443bd8a 100644
--- a/source/librpc/ndr/ndr_string.c
+++ b/source/librpc/ndr/ndr_string.c
@@ -633,8 +633,7 @@ _PUBLIC_ void ndr_print_string_array(struct ndr_print *ndr, const char *name, co
ndr->depth++;
for (i=0;i<count;i++) {
char *idx=NULL;
- asprintf(&idx, "[%d]", i);
- if (idx) {
+ if (asprintf(&idx, "[%d]", i) != -1) {
ndr_print_string(ndr, idx, a[i]);
free(idx);
}
diff --git a/source/libsmb/clifsinfo.c b/source/libsmb/clifsinfo.c
index fb923378ab4..f4945f812a3 100644
--- a/source/libsmb/clifsinfo.c
+++ b/source/libsmb/clifsinfo.c
@@ -497,8 +497,7 @@ static NTSTATUS make_cli_gss_blob(struct smb_trans_enc_state *es,
memset(&tok_out, '\0', sizeof(tok_out));
/* Get a ticket for the service@host */
- asprintf(&host_princ_s, "%s@%s", service, host);
- if (host_princ_s == NULL) {
+ if (asprintf(&host_princ_s, "%s@%s", service, host) == -1) {
return NT_STATUS_NO_MEMORY;
}
diff --git a/source/param/loadparm.c b/source/param/loadparm.c
index 4d067af5a50..86446d5b75f 100644
--- a/source/param/loadparm.c
+++ b/source/param/loadparm.c
@@ -2251,8 +2251,7 @@ static param_opt_struct *get_parametrics(int snum, const char *type, const char
data = ServicePtrs[snum]->param_opt;
}
- asprintf(&param_key, "%s:%s", type, option);
- if (!param_key) {
+ if (asprintf(&param_key, "%s:%s", type, option) == -1) {
DEBUG(0,("asprintf failed!\n"));
return NULL;
}
diff --git a/source/passdb/machine_sid.c b/source/passdb/machine_sid.c
index d1599047a7b..8fafcbbbd46 100644
--- a/source/passdb/machine_sid.c
+++ b/source/passdb/machine_sid.c
@@ -128,7 +128,10 @@ static DOM_SID *pdb_generate_sam_sid(void)
}
/* check for an old MACHINE.SID file for backwards compatibility */
- asprintf(&fname, "%s/MACHINE.SID", lp_private_dir());
+ if (asprintf(&fname, "%s/MACHINE.SID", lp_private_dir()) == -1) {
+ SAFE_FREE(sam_sid);
+ return NULL;
+ }
if (read_sid_from_file(fname, sam_sid)) {
/* remember it for future reference and unlink the old MACHINE.SID */