Browse Source

make LOG* macros typecheck and fix related errors/warnings

master
kanoi 10 years ago
parent
commit
503ec09f27
  1. 4
      src/ckdb.c
  2. 2
      src/ckdb.h
  3. 2
      src/ckdb_btc.c
  4. 2
      src/ckdb_cmd.c
  5. 8
      src/ckdb_data.c
  6. 12
      src/connector.c
  7. 27
      src/libckpool.h
  8. 36
      src/stratifier.c

4
src/ckdb.c

@ -3160,7 +3160,7 @@ static void confirm_reload()
}
if (confirm_last_workinfoid == 0) {
LOGWARNING("%s(): there are no unconfirmed sharesummary records in the DB",
__func__, buf);
__func__);
return;
}
@ -3230,7 +3230,7 @@ static void confirm_reload()
// last from default
if (confirm_last_workinfoid < confirm_first_workinfoid) {
LOGWARNING("%s(): no unconfirmed sharesummary records before start",
__func__, buf);
__func__);
return;
}
first_reason = "start range";

2
src/ckdb.h

@ -52,7 +52,7 @@
#define DB_VLOCK "1"
#define DB_VERSION "0.9.6"
#define CKDB_VERSION DB_VERSION"-0.667"
#define CKDB_VERSION DB_VERSION"-0.700"
#define WHERE_FFL " - from %s %s() line %d"
#define WHERE_FFL_HERE __FILE__, __func__, __LINE__

2
src/ckdb_btc.c

@ -329,7 +329,7 @@ void btc_blockstatus(BLOCKS *blocks)
len = strlen(blocks->blockhash);
if (len != SHA256SIZHEX) {
LOGERR("%s() invalid blockhash size %d (%d) for block %d",
__func__, len, SHA256SIZHEX, blocks->height);
__func__, (int)len, SHA256SIZHEX, blocks->height);
/* So we don't keep repeating the message
* This should never happen */

2
src/ckdb_cmd.c

@ -1665,7 +1665,7 @@ awconf:
return strdup(reply);
}
LOGERR("%s.bad.cmd %s", cmd);
LOGERR("%s.bad.cmd %s", id, cmd);
return strdup("bad.cmd");
}

8
src/ckdb_data.c

@ -488,7 +488,7 @@ K_ITEM *_optional_name(K_TREE *trf_root, char *name, int len, char *patt,
dlen = 0;
if (!mvalue || (int)dlen < len) {
if (!mvalue) {
LOGERR("%s(): field '%s' NULL (%d) from %s():%d",
LOGERR("%s(): field '%s' NULL (%d:%d) from %s():%d",
__func__, name, (int)dlen, len, func, line);
} else
snprintf(reply, siz, "failed.short %s", name);
@ -1749,8 +1749,8 @@ void auto_age_older(PGconn *conn, int64_t workinfoid, char *poolinstance,
min_buf, max_buf);
}
LOGWARNING("%s() Auto-aged %"PRId64"(%"PRId64") "
"share%s %d sharesummar%s %d workinfoid%s "
"%s %s",
"share%s %"PRId64" sharesummar%s %"PRId32
" workinfoid%s %s %s",
__func__,
s_count_tot, s_diff_tot,
(s_count_tot == 1) ? "" : "s",
@ -2028,7 +2028,7 @@ void set_block_share_counters()
LOGEMERG("%s(): ERROR workmarker %"PRId64" has an invalid"
" workinfoid range start=%"PRId64" end=%"PRId64
" due to pool lastblock=%"PRId32
" workinfoid="PRId64,
" workinfoid=%"PRId64,
__func__, workmarkers->markerid,
workmarkers->workinfoidstart,
workmarkers->workinfoidend,

12
src/connector.c

@ -176,7 +176,7 @@ static int drop_client(conn_instance_t *ci, client_instance_t *client)
ck_wunlock(&ci->lock);
if (fd > -1)
LOGINFO("Connector dropped client %d fd %d", client->id, fd);
LOGINFO("Connector dropped client %"PRId64" fd %d", client->id, fd);
return fd;
}
@ -261,7 +261,7 @@ reparse:
if (!(val = json_loads(msg, 0, NULL))) {
char *buf = strdup("Invalid JSON, disconnecting\n");
LOGINFO("Client id %d sent invalid json message %s", client->id, msg);
LOGINFO("Client id %"PRId64" sent invalid json message %s", client->id, msg);
send_client(ci, client->id, buf);
invalidate_client(ckp, ci, client);
return;
@ -421,13 +421,13 @@ void *sender(void *arg)
ret = wait_write_select(fd, 0);
if (ret < 1) {
if (ret < 0) {
LOGINFO("Client id %d fd %d interrupted", client->id, fd);
LOGINFO("Client id %"PRId64" fd %d interrupted", client->id, fd);
invalidate_client(ckp, ci, client);
free(sender_send->buf);
free(sender_send);
continue;
}
LOGDEBUG("Client %d not ready for writes", client->id);
LOGDEBUG("Client %"PRId64" not ready for writes", client->id);
/* Append it to the tail of the delayed sends list.
* This is the only function that alters it so no
@ -439,7 +439,7 @@ void *sender(void *arg)
while (sender_send->len) {
ret = send(fd, sender_send->buf + ofs, sender_send->len , 0);
if (unlikely(ret < 0)) {
LOGINFO("Client id %d fd %d disconnected", client->id, fd);
LOGINFO("Client id %"PRId64" fd %d disconnected", client->id, fd);
invalidate_client(ckp, ci, client);
break;
}
@ -519,7 +519,7 @@ static void passthrough_client(conn_instance_t *ci, client_instance_t *client)
{
char *buf;
LOGINFO("Connector adding passthrough client %d", client->id);
LOGINFO("Connector adding passthrough client %"PRId64, client->id);
client->passthrough = true;
ASPRINTF(&buf, "{\"result\": true}\n");
send_client(ci, client->id, buf);

27
src/libckpool.h

@ -190,14 +190,25 @@ static inline void flip_80(void *dest_p, const void *src_p)
void logmsg(int loglevel, const char *fmt, ...);
#define LOGEMERG(fmt, ...) logmsg(LOG_EMERG, fmt, ##__VA_ARGS__)
#define LOGALERT(fmt, ...) logmsg(LOG_ALERT, fmt, ##__VA_ARGS__)
#define LOGCRIT(fmt, ...) logmsg(LOG_CRIT, fmt, ##__VA_ARGS__)
#define LOGERR(fmt, ...) logmsg(LOG_ERR, fmt, ##__VA_ARGS__)
#define LOGWARNING(fmt, ...) logmsg(LOG_WARNING, fmt, ##__VA_ARGS__)
#define LOGNOTICE(fmt, ...) logmsg(LOG_NOTICE, fmt, ##__VA_ARGS__)
#define LOGINFO(fmt, ...) logmsg(LOG_INFO, fmt, ##__VA_ARGS__)
#define LOGDEBUG(fmt, ...) logmsg(LOG_DEBUG, fmt, ##__VA_ARGS__)
#define DEFLOGBUFSIZ 512
#define LOGMSGSIZ(__siz, __lvl, __fmt, ...) do { \
char tmp42[__siz]; \
snprintf(tmp42, sizeof(tmp42), __fmt, ##__VA_ARGS__); \
logmsg(__lvl, "%s", tmp42); \
} while(0)
#define LOGMSG(_lvl, _fmt, ...) \
LOGMSGSIZ(DEFLOGBUFSIZ, _lvl, _fmt, ##__VA_ARGS__)
#define LOGEMERG(fmt, ...) LOGMSG(LOG_EMERG, fmt, ##__VA_ARGS__)
#define LOGALERT(fmt, ...) LOGMSG(LOG_ALERT, fmt, ##__VA_ARGS__)
#define LOGCRIT(fmt, ...) LOGMSG(LOG_CRIT, fmt, ##__VA_ARGS__)
#define LOGERR(fmt, ...) LOGMSG(LOG_ERR, fmt, ##__VA_ARGS__)
#define LOGWARNING(fmt, ...) LOGMSG(LOG_WARNING, fmt, ##__VA_ARGS__)
#define LOGNOTICE(fmt, ...) LOGMSG(LOG_NOTICE, fmt, ##__VA_ARGS__)
#define LOGINFO(fmt, ...) LOGMSG(LOG_INFO, fmt, ##__VA_ARGS__)
#define LOGDEBUG(fmt, ...) LOGMSG(LOG_DEBUG, fmt, ##__VA_ARGS__)
#define IN_FMT_FFL " in %s %s():%d"
#define quitfrom(status, _file, _func, _line, fmt, ...) do { \

36
src/stratifier.c

@ -2500,12 +2500,12 @@ out:
if (client->first_invalid < client->last_share.tv_sec || !client->first_invalid)
client->first_invalid = now_t;
else if (client->first_invalid && client->first_invalid < now_t - 120) {
LOGNOTICE("Client %d rejecting for 120s, disconnecting", client->id);
LOGNOTICE("Client %"PRId64" rejecting for 120s, disconnecting", client->id);
stratum_send_message(client, "Disconnecting for continuous invalid shares");
client->reject = 2;
} else if (client->first_invalid && client->first_invalid < now_t - 60) {
if (!client->reject) {
LOGINFO("Client %d rejecting for 60s, sending diff", client->id);
LOGINFO("Client %"PRId64" rejecting for 60s, sending diff", client->id);
stratum_send_diff(client);
client->reject = 1;
}
@ -2625,8 +2625,10 @@ static void set_worker_mindiff(ckpool_t *ckp, const char *workername, int mindif
ck_runlock(&instance_lock);
/* They may just have not connected yet */
if (!instance)
return LOGINFO("Failed to find user %s in set_worker_mindiff", username);
if (!instance) {
LOGINFO("Failed to find user %s in set_worker_mindiff", username);
return;
}
/* Then find the matching worker instance */
ck_rlock(&instance_lock);
@ -2639,11 +2641,15 @@ static void set_worker_mindiff(ckpool_t *ckp, const char *workername, int mindif
ck_runlock(&instance_lock);
/* They may just not be connected at the moment */
if (!worker)
return LOGINFO("Failed to find worker %s in set_worker_mindiff", workername);
if (!worker) {
LOGINFO("Failed to find worker %s in set_worker_mindiff", workername);
return;
}
if (mindiff < 1)
return LOGINFO("Worker %s requested invalid diff %ld", worker->workername, mindiff);
if (mindiff < 1) {
LOGINFO("Worker %s requested invalid diff %d", worker->workername, mindiff);
return;
}
if (mindiff < ckp->mindiff)
mindiff = ckp->mindiff;
if (mindiff == worker->mindiff)
@ -2676,12 +2682,16 @@ static void suggest_diff(stratum_instance_t *client, const char *method, json_t
json_t *arr_val = json_array_get(params_val, 0);
int64_t sdiff;
if (unlikely(!client->authorised))
return LOGWARNING("Attempted to suggest diff on unauthorised client %ld", client->id);
if (unlikely(!client->authorised)) {
LOGWARNING("Attempted to suggest diff on unauthorised client %ld", client->id);
return;
}
if (arr_val && json_is_integer(arr_val))
sdiff = json_integer_value(arr_val);
else if (sscanf(method, "mining.suggest_difficulty(%ld", &sdiff) != 1)
return LOGINFO("Failed to parse suggest_difficulty for client %ld", client->id);
else if (sscanf(method, "mining.suggest_difficulty(%ld", &sdiff) != 1) {
LOGINFO("Failed to parse suggest_difficulty for client %"PRId64, client->id);
return;
}
if (sdiff == client->suggest_diff)
return;
client->suggest_diff = sdiff;
@ -2711,7 +2721,7 @@ static void parse_method(const int64_t client_id, json_t *id_val, json_t *method
}
if (unlikely(client->reject == 2)) {
LOGINFO("Dropping client %d tagged for lazy invalidation", client_id);
LOGINFO("Dropping client %"PRId64" tagged for lazy invalidation", client_id);
snprintf(buf, 255, "dropclient=%ld", client->id);
send_proc(client->ckp->connector, buf);
return;

Loading…
Cancel
Save