1
0
mirror of https://github.com/moparisthebest/sslh synced 2024-11-21 16:45:03 -05:00

check asprintf return value

The current asprintf usage triggers many warnings like:

sslh-main.c: In function 'print_usage':
sslh-main.c:86:17: warning: ignoring return value of 'asprintf',
	declared with attribute warn_unused_result [-Wunused-result]

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
This commit is contained in:
Mike Frysinger 2013-09-17 00:26:44 -04:00
parent b8ea0699c4
commit 2d23cdc9f4
3 changed files with 10 additions and 4 deletions

View File

@ -487,9 +487,11 @@ void setup_signals(void)
* banner is made up of basename(bin_name)+"[pid]" */
void setup_syslog(const char* bin_name) {
char *name1, *name2;
int res;
name1 = strdup(bin_name);
asprintf(&name2, "%s[%d]", basename(name1), getpid());
res = asprintf(&name2, "%s[%d]", basename(name1), getpid());
CHECK_RES_DIE(res, "asprintf");
openlog(name2, LOG_CONS, LOG_AUTH);
free(name1);
/* Don't free name2, as openlog(3) uses it (at least in glibc) */

View File

@ -63,7 +63,8 @@ int get_num_builtins(void) {
/* Sets the protocol name to connect to in case of timeout */
void set_ontimeout(const char* name)
{
asprintf(&on_timeout, "%s", name);
int res = asprintf(&on_timeout, "%s", name);
CHECK_RES_DIE(res, "asprintf");
}
/* Returns the protocol to connect to in case of timeout;

View File

@ -79,11 +79,14 @@ static void print_usage(void)
{
struct proto *p;
int i;
int res;
char *prots = "";
p = get_builtins();
for (i = 0; i < get_num_builtins(); i++)
asprintf(&prots, "%s\t[--%s <addr>]\n", prots, p[i].description);
for (i = 0; i < get_num_builtins(); i++) {
res = asprintf(&prots, "%s\t[--%s <addr>]\n", prots, p[i].description);
CHECK_RES_DIE(res, "asprintf");
}
fprintf(stderr, USAGE_STRING, prots);
}