Check some error returns from *asprintf()
This avoids these compiler warnings on Ubuntu 18.04 gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) expand_path.c: In function ‘expand_token’: expand_path.c:493:17: warning: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result [-Wunused-result] asprintf(&arg, "%.*s", (int)(token_end - colon - 1), colon + 1); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ log.c: In function ‘fmtkv’: log.c:646:5: warning: ignoring return value of ‘vasprintf’, declared with attribute warn_unused_result [-Wunused-result] vasprintf(&buf1, fmt, ap); ^~~~~~~~~~~~~~~~~~~~~~~~~ mech/context.c: In function ‘gss_mg_set_error_string’: mech/context.c:212:5: warning: ignoring return value of ‘vasprintf’, declared with attribute warn_unused_result [-Wunused-result] (void) vasprintf(&str, fmt, ap); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mech/context.c: In function ‘_gss_mg_log_name’: mech/context.c:319:6: warning: ignoring return value of ‘vasprintf’, declared with attribute warn_unused_result [-Wunused-result] (void) vasprintf(&str, fmt, ap); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mech/context.c: In function ‘_gss_mg_log_cred’: mech/context.c:346:5: warning: ignoring return value of ‘vasprintf’, declared with attribute warn_unused_result [-Wunused-result] (void) vasprintf(&str, fmt, ap); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ kerberos5.c: In function ‘_kdc_set_e_text’: kerberos5.c:338:5: warning: ignoring return value of ‘vasprintf’, declared with attribute warn_unused_result [-Wunused-result] vasprintf(&e_text, fmt, ap); ^~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:

committed by
Jeffrey Altman

parent
f91f786dd6
commit
1a65611f61
@@ -638,18 +638,18 @@ fmtkv(int flags, const char *k, const char *fmt, va_list ap)
|
||||
__attribute__ ((__format__ (__printf__, 3, 0)))
|
||||
{
|
||||
heim_string_t str;
|
||||
size_t i,j;
|
||||
size_t i;
|
||||
ssize_t j;
|
||||
char *buf1;
|
||||
char *buf2;
|
||||
char *buf3;
|
||||
|
||||
vasprintf(&buf1, fmt, ap);
|
||||
if (!buf1)
|
||||
int ret = vasprintf(&buf1, fmt, ap);
|
||||
if (ret < 0 || !buf1)
|
||||
return NULL;;
|
||||
|
||||
j = asprintf(&buf2, "%s=%s", k, buf1);
|
||||
free(buf1);
|
||||
if (!buf2)
|
||||
if (j < 0 || !buf2)
|
||||
return NULL;;
|
||||
|
||||
/* We optionally eat the whitespace. */
|
||||
|
Reference in New Issue
Block a user