Browse Source

Check return value of asprintf

master
Con Kolivas 11 years ago
parent
commit
d90b4ffddd
  1. 7
      src/ckpool.h
  2. 2
      src/generator.c
  3. 2
      src/stratifier.c

7
src/ckpool.h

@ -110,6 +110,11 @@ ckpool_t *global_ckp;
int process_exit(ckpool_t *ckp, proc_instance_t *pi, int ret); int process_exit(ckpool_t *ckp, proc_instance_t *pi, int ret);
#define ASPRINTF(strp, fmt, ...) do { \
if (unlikely(asprintf(strp, fmt, ##__VA_ARGS__))) \
quitfrom(1, __FILE__, __func__, __LINE__, "Failed to asprintf"); \
} while (0)
/* Log everything to the logfile, but display warnings on the console as well */ /* Log everything to the logfile, but display warnings on the console as well */
#define LOGMSG(_loglevel, fmt, ...) do { \ #define LOGMSG(_loglevel, fmt, ...) do { \
if (global_ckp->loglevel >= _loglevel && fmt) { \ if (global_ckp->loglevel >= _loglevel && fmt) { \
@ -118,7 +123,7 @@ int process_exit(ckpool_t *ckp, proc_instance_t *pi, int ret);
time_t now_t; \ time_t now_t; \
int LOGFD = global_ckp->logfd; \ int LOGFD = global_ckp->logfd; \
\ \
asprintf(&BUF, fmt, ##__VA_ARGS__); \ ASPRINTF(&BUF, fmt, ##__VA_ARGS__); \
now_t = time(NULL); \ now_t = time(NULL); \
tm = localtime(&now_t); \ tm = localtime(&now_t); \
if (LOGFD) { \ if (LOGFD) { \

2
src/generator.c

@ -658,7 +658,7 @@ static bool parse_reconnect(proxy_instance_t *proxi, json_t *val)
si->url, new_url); si->url, new_url);
goto out; goto out;
} }
asprintf(&url, "%s:%d", new_url, new_port); ASPRINTF(&url, "%s:%d", new_url, new_port);
} else } else
url = strdup(si->url); url = strdup(si->url);
LOGINFO("Processing reconnect request to %s", url); LOGINFO("Processing reconnect request to %s", url);

2
src/stratifier.c

@ -854,7 +854,7 @@ static void block_solve(ckpool_t *ckp)
LOGWARNING("Total shares from all users: %.0f pplns window %.0f", total, window); LOGWARNING("Total shares from all users: %.0f pplns window %.0f", total, window);
asprintf(&msg, "Block solved by %s after %.0f shares!", ckp->name, total); ASPRINTF(&msg, "Block solved by %s after %.0f shares!", ckp->name, total);
stratum_broadcast_message(msg); stratum_broadcast_message(msg);
free(msg); free(msg);
} }

Loading…
Cancel
Save