Check return value of asprintf
This commit is contained in:
parent
77f09c2858
commit
d90b4ffddd
@ -110,6 +110,11 @@ ckpool_t *global_ckp;
|
||||
|
||||
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 */
|
||||
#define LOGMSG(_loglevel, fmt, ...) do { \
|
||||
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; \
|
||||
int LOGFD = global_ckp->logfd; \
|
||||
\
|
||||
asprintf(&BUF, fmt, ##__VA_ARGS__); \
|
||||
ASPRINTF(&BUF, fmt, ##__VA_ARGS__); \
|
||||
now_t = time(NULL); \
|
||||
tm = localtime(&now_t); \
|
||||
if (LOGFD) { \
|
||||
|
||||
@ -658,7 +658,7 @@ static bool parse_reconnect(proxy_instance_t *proxi, json_t *val)
|
||||
si->url, new_url);
|
||||
goto out;
|
||||
}
|
||||
asprintf(&url, "%s:%d", new_url, new_port);
|
||||
ASPRINTF(&url, "%s:%d", new_url, new_port);
|
||||
} else
|
||||
url = strdup(si->url);
|
||||
LOGINFO("Processing reconnect request to %s", url);
|
||||
|
||||
@ -854,7 +854,7 @@ static void block_solve(ckpool_t *ckp)
|
||||
|
||||
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);
|
||||
free(msg);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user