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)
|
if (!lang)
|
||||||
return True;
|
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) {
|
if (stat(msg_path, &st) != 0) {
|
||||||
/* the msg file isn't available */
|
/* the msg file isn't available */
|
||||||
DEBUG(10, ("lang_tdb_init: %s: %s\n", msg_path,
|
DEBUG(10, ("lang_tdb_init: %s: %s\n", msg_path,
|
||||||
@ -135,7 +139,10 @@ bool lang_tdb_init(const char *lang)
|
|||||||
goto done;
|
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));
|
DEBUG(10, ("lang_tdb_init: loading %s\n", path));
|
||||||
|
|
||||||
|
@ -827,6 +827,7 @@ void check_log_size( void )
|
|||||||
};
|
};
|
||||||
int priority;
|
int priority;
|
||||||
char *msgbuf = NULL;
|
char *msgbuf = NULL;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if( syslog_level >= ( sizeof(priority_map) / sizeof(priority_map[0]) ) || syslog_level < 0)
|
if( syslog_level >= ( sizeof(priority_map) / sizeof(priority_map[0]) ) || syslog_level < 0)
|
||||||
priority = LOG_DEBUG;
|
priority = LOG_DEBUG;
|
||||||
@ -834,10 +835,10 @@ void check_log_size( void )
|
|||||||
priority = priority_map[syslog_level];
|
priority = priority_map[syslog_level];
|
||||||
|
|
||||||
va_start(ap, format_str);
|
va_start(ap, format_str);
|
||||||
vasprintf(&msgbuf, format_str, ap);
|
ret = vasprintf(&msgbuf, format_str, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if (msgbuf) {
|
if (ret == -1) {
|
||||||
syslog(priority, "%s", msgbuf);
|
syslog(priority, "%s", msgbuf);
|
||||||
}
|
}
|
||||||
SAFE_FREE(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;
|
va_list ap;
|
||||||
char *msgbuf = NULL;
|
char *msgbuf = NULL;
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
int res;
|
||||||
|
|
||||||
va_start(ap, format_str);
|
va_start(ap, format_str);
|
||||||
vasprintf(&msgbuf, format_str, ap);
|
res = vasprintf(&msgbuf, format_str, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if (msgbuf) {
|
if (res != -1) {
|
||||||
format_debug_text(msgbuf);
|
format_debug_text(msgbuf);
|
||||||
} else {
|
} else {
|
||||||
ret = false;
|
ret = false;
|
||||||
|
@ -120,9 +120,9 @@ bool gencache_set(const char *keystr, const char *value, time_t timeout)
|
|||||||
|
|
||||||
if (!gencache_init()) return False;
|
if (!gencache_init()) return False;
|
||||||
|
|
||||||
asprintf(&valstr, CACHE_DATA_FMT, (int)timeout, value);
|
if (asprintf(&valstr, CACHE_DATA_FMT, (int)timeout, value) == -1) {
|
||||||
if (!valstr)
|
|
||||||
return False;
|
return False;
|
||||||
|
}
|
||||||
|
|
||||||
databuf = string_term_tdb_data(valstr);
|
databuf = string_term_tdb_data(valstr);
|
||||||
DEBUG(10, ("Adding cache entry with key = %s; value = %s and timeout ="
|
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;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
asprintf(&valstr, "%12u/%s", (int)timeout, BLOB_TYPE);
|
if (asprintf(&valstr, "%12u/%s", (int)timeout, BLOB_TYPE) == -1) {
|
||||||
if (!valstr) {
|
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -452,8 +451,9 @@ void gencache_iterate(void (*fn)(const char* key, const char *value, time_t time
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
asprintf(&fmt, READ_CACHE_DATA_FMT_TEMPLATE, (unsigned int)databuf.dsize - TIMEOUT_LEN);
|
if (asprintf(&fmt, READ_CACHE_DATA_FMT_TEMPLATE,
|
||||||
if (!fmt) {
|
(unsigned int)databuf.dsize - TIMEOUT_LEN)
|
||||||
|
== -1) {
|
||||||
SAFE_FREE(valstr);
|
SAFE_FREE(valstr);
|
||||||
SAFE_FREE(entry);
|
SAFE_FREE(entry);
|
||||||
SAFE_FREE(keystr);
|
SAFE_FREE(keystr);
|
||||||
|
@ -1904,8 +1904,7 @@ int create_pipe_sock(const char *socket_dir,
|
|||||||
goto out_close;
|
goto out_close;
|
||||||
}
|
}
|
||||||
|
|
||||||
asprintf(&path, "%s/%s", socket_dir, socket_name);
|
if (asprintf(&path, "%s/%s", socket_dir, socket_name) == -1) {
|
||||||
if (!path) {
|
|
||||||
goto out_close;
|
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 *new_ipstr = NULL;
|
||||||
char addr_buf[INET6_ADDRSTRLEN];
|
char addr_buf[INET6_ADDRSTRLEN];
|
||||||
|
int ret;
|
||||||
|
|
||||||
/* arguments checking */
|
/* arguments checking */
|
||||||
if (!ipstr_list || !service) {
|
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 (*ipstr_list) {
|
||||||
if (service->ss.ss_family == AF_INET) {
|
if (service->ss.ss_family == AF_INET) {
|
||||||
/* IPv4 */
|
/* IPv4 */
|
||||||
asprintf(&new_ipstr, "%s%s%s:%d",
|
ret = asprintf(&new_ipstr, "%s%s%s:%d", *ipstr_list,
|
||||||
*ipstr_list,
|
IPSTR_LIST_SEP, addr_buf,
|
||||||
IPSTR_LIST_SEP,
|
service->port);
|
||||||
addr_buf,
|
|
||||||
service->port);
|
|
||||||
} else {
|
} else {
|
||||||
/* IPv6 */
|
/* IPv6 */
|
||||||
asprintf(&new_ipstr, "%s%s[%s]:%d",
|
ret = asprintf(&new_ipstr, "%s%s[%s]:%d", *ipstr_list,
|
||||||
*ipstr_list,
|
IPSTR_LIST_SEP, addr_buf,
|
||||||
IPSTR_LIST_SEP,
|
service->port);
|
||||||
addr_buf,
|
|
||||||
service->port);
|
|
||||||
}
|
}
|
||||||
SAFE_FREE(*ipstr_list);
|
SAFE_FREE(*ipstr_list);
|
||||||
} else {
|
} else {
|
||||||
if (service->ss.ss_family == AF_INET) {
|
if (service->ss.ss_family == AF_INET) {
|
||||||
/* IPv4 */
|
/* IPv4 */
|
||||||
asprintf(&new_ipstr, "%s:%d",
|
ret = asprintf(&new_ipstr, "%s:%d", addr_buf,
|
||||||
addr_buf,
|
service->port);
|
||||||
service->port);
|
|
||||||
} else {
|
} else {
|
||||||
/* IPv6 */
|
/* IPv6 */
|
||||||
asprintf(&new_ipstr, "[%s]:%d",
|
ret = asprintf(&new_ipstr, "[%s]:%d", addr_buf,
|
||||||
addr_buf,
|
service->port);
|
||||||
service->port);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (ret == -1) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
*ipstr_list = new_ipstr;
|
*ipstr_list = new_ipstr;
|
||||||
return *ipstr_list;
|
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;
|
va_list ap;
|
||||||
char *ptr = NULL;
|
char *ptr = NULL;
|
||||||
|
int ret;
|
||||||
|
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
vasprintf(&ptr, format, ap);
|
ret = vasprintf(&ptr, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if (!ptr || !*ptr)
|
if ((ret == -1) || !*ptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DEBUG((int)level, ("tdb(%s): %s", tdb_name(tdb) ? tdb_name(tdb) : "unnamed", ptr));
|
DEBUG((int)level, ("tdb(%s): %s", tdb_name(tdb) ? tdb_name(tdb) : "unnamed", ptr));
|
||||||
@ -867,10 +868,7 @@ static void tdb_wrap_log(TDB_CONTEXT *tdb, enum tdb_debug_level level,
|
|||||||
va_list ap;
|
va_list ap;
|
||||||
char *ptr = NULL;
|
char *ptr = NULL;
|
||||||
int debuglevel = 0;
|
int debuglevel = 0;
|
||||||
|
int ret;
|
||||||
va_start(ap, format);
|
|
||||||
vasprintf(&ptr, format, ap);
|
|
||||||
va_end(ap);
|
|
||||||
|
|
||||||
switch (level) {
|
switch (level) {
|
||||||
case TDB_DEBUG_FATAL:
|
case TDB_DEBUG_FATAL:
|
||||||
@ -889,7 +887,11 @@ static void tdb_wrap_log(TDB_CONTEXT *tdb, enum tdb_debug_level level,
|
|||||||
debuglevel = 0;
|
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);
|
const char *name = tdb_name(tdb);
|
||||||
DEBUG(debuglevel, ("tdb(%s): %s", name ? name : "unnamed", ptr));
|
DEBUG(debuglevel, ("tdb(%s): %s", name ? name : "unnamed", ptr));
|
||||||
free(ptr);
|
free(ptr);
|
||||||
|
@ -407,8 +407,8 @@ static char *kerberos_secrets_fetch_salting_principal(const char *service, int e
|
|||||||
char *key = NULL;
|
char *key = NULL;
|
||||||
char *ret = NULL;
|
char *ret = NULL;
|
||||||
|
|
||||||
asprintf(&key, "%s/%s/enctype=%d", SECRETS_SALTING_PRINCIPAL, service, enctype);
|
if (asprintf(&key, "%s/%s/enctype=%d",
|
||||||
if (!key) {
|
SECRETS_SALTING_PRINCIPAL, service, enctype) == -1) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
ret = (char *)secrets_fetch(key, NULL);
|
ret = (char *)secrets_fetch(key, NULL);
|
||||||
@ -438,7 +438,10 @@ static char* des_salt_key( void )
|
|||||||
{
|
{
|
||||||
char *key;
|
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;
|
return key;
|
||||||
}
|
}
|
||||||
@ -609,9 +612,13 @@ bool kerberos_secrets_store_salting_principal(const char *service,
|
|||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
if (strchr_m(service, '@')) {
|
if (strchr_m(service, '@')) {
|
||||||
asprintf(&princ_s, "%s", service);
|
if (asprintf(&princ_s, "%s", service) == -1) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
} else {
|
} 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) {
|
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;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
asprintf(&key, "%s/%s/enctype=%d", SECRETS_SALTING_PRINCIPAL, unparsed_name, enctype);
|
if (asprintf(&key, "%s/%s/enctype=%d",
|
||||||
if (!key) {
|
SECRETS_SALTING_PRINCIPAL, unparsed_name, enctype)
|
||||||
|
== -1) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,12 +176,16 @@ _PUBLIC_ void ndr_print_debug_helper(struct ndr_print *ndr, const char *format,
|
|||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
char *s = NULL;
|
char *s = NULL;
|
||||||
int i;
|
int i, ret;
|
||||||
|
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
vasprintf(&s, format, ap);
|
ret = vasprintf(&s, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
|
if (ret == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (i=0;i<ndr->depth;i++) {
|
for (i=0;i<ndr->depth;i++) {
|
||||||
DEBUGADD(0,(" "));
|
DEBUGADD(0,(" "));
|
||||||
}
|
}
|
||||||
@ -450,11 +454,16 @@ _PUBLIC_ enum ndr_err_code ndr_pull_error(struct ndr_pull *ndr,
|
|||||||
{
|
{
|
||||||
char *s=NULL;
|
char *s=NULL;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
int ret;
|
||||||
|
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
vasprintf(&s, format, ap);
|
ret = vasprintf(&s, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
|
if (ret == -1) {
|
||||||
|
return NDR_ERR_ALLOC;
|
||||||
|
}
|
||||||
|
|
||||||
DEBUG(3,("ndr_pull_error(%u): %s\n", ndr_err, s));
|
DEBUG(3,("ndr_pull_error(%u): %s\n", ndr_err, s));
|
||||||
|
|
||||||
free(s);
|
free(s);
|
||||||
@ -471,11 +480,16 @@ _PUBLIC_ enum ndr_err_code ndr_push_error(struct ndr_push *ndr,
|
|||||||
{
|
{
|
||||||
char *s=NULL;
|
char *s=NULL;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
int ret;
|
||||||
|
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
vasprintf(&s, format, ap);
|
ret = vasprintf(&s, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
|
if (ret == -1) {
|
||||||
|
return NDR_ERR_ALLOC;
|
||||||
|
}
|
||||||
|
|
||||||
DEBUG(3,("ndr_push_error(%u): %s\n", ndr_err, s));
|
DEBUG(3,("ndr_push_error(%u): %s\n", ndr_err, s));
|
||||||
|
|
||||||
free(s);
|
free(s);
|
||||||
|
@ -773,8 +773,7 @@ _PUBLIC_ void ndr_print_array_uint8(struct ndr_print *ndr, const char *name,
|
|||||||
ndr->depth++;
|
ndr->depth++;
|
||||||
for (i=0;i<count;i++) {
|
for (i=0;i<count;i++) {
|
||||||
char *idx=NULL;
|
char *idx=NULL;
|
||||||
asprintf(&idx, "[%d]", i);
|
if (asprintf(&idx, "[%d]", i) != -1) {
|
||||||
if (idx) {
|
|
||||||
ndr_print_uint8(ndr, idx, data[i]);
|
ndr_print_uint8(ndr, idx, data[i]);
|
||||||
free(idx);
|
free(idx);
|
||||||
}
|
}
|
||||||
|
@ -633,8 +633,7 @@ _PUBLIC_ void ndr_print_string_array(struct ndr_print *ndr, const char *name, co
|
|||||||
ndr->depth++;
|
ndr->depth++;
|
||||||
for (i=0;i<count;i++) {
|
for (i=0;i<count;i++) {
|
||||||
char *idx=NULL;
|
char *idx=NULL;
|
||||||
asprintf(&idx, "[%d]", i);
|
if (asprintf(&idx, "[%d]", i) != -1) {
|
||||||
if (idx) {
|
|
||||||
ndr_print_string(ndr, idx, a[i]);
|
ndr_print_string(ndr, idx, a[i]);
|
||||||
free(idx);
|
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));
|
memset(&tok_out, '\0', sizeof(tok_out));
|
||||||
|
|
||||||
/* Get a ticket for the service@host */
|
/* Get a ticket for the service@host */
|
||||||
asprintf(&host_princ_s, "%s@%s", service, host);
|
if (asprintf(&host_princ_s, "%s@%s", service, host) == -1) {
|
||||||
if (host_princ_s == NULL) {
|
|
||||||
return NT_STATUS_NO_MEMORY;
|
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;
|
data = ServicePtrs[snum]->param_opt;
|
||||||
}
|
}
|
||||||
|
|
||||||
asprintf(¶m_key, "%s:%s", type, option);
|
if (asprintf(¶m_key, "%s:%s", type, option) == -1) {
|
||||||
if (!param_key) {
|
|
||||||
DEBUG(0,("asprintf failed!\n"));
|
DEBUG(0,("asprintf failed!\n"));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,10 @@ static DOM_SID *pdb_generate_sam_sid(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* check for an old MACHINE.SID file for backwards compatibility */
|
/* 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)) {
|
if (read_sid_from_file(fname, sam_sid)) {
|
||||||
/* remember it for future reference and unlink the old MACHINE.SID */
|
/* remember it for future reference and unlink the old MACHINE.SID */
|
||||||
|
Loading…
Reference in New Issue
Block a user