mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
Fix some warnings
warning: ignoring return value of 'asprintf', declared with attribute warn_unused_result
(This used to be commit ad37b7b0ae
)
This commit is contained in:
parent
cd95385207
commit
3176392878
@ -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));
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -2251,8 +2251,7 @@ static param_opt_struct *get_parametrics(int snum, const char *type, const char
|
||||
data = ServicePtrs[snum]->param_opt;
|
||||
}
|
||||
|
||||
asprintf(¶m_key, "%s:%s", type, option);
|
||||
if (!param_key) {
|
||||
if (asprintf(¶m_key, "%s:%s", type, option) == -1) {
|
||||
DEBUG(0,("asprintf failed!\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user