Skip to content

Commit

Permalink
Fix format issues found by static analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
vstakhov committed Nov 11, 2015
1 parent e4abacb commit f3585bb
Show file tree
Hide file tree
Showing 26 changed files with 58 additions and 55 deletions.
2 changes: 1 addition & 1 deletion src/client/rspamc.c
Expand Up @@ -606,7 +606,7 @@ rspamc_uptime_output (FILE *out, ucl_object_t *obj)
}
/* If uptime is less than 1 minute print only seconds */
else if (seconds / 60 == 0) {
rspamd_printf ("%L second%s\n", (gint)seconds,
rspamd_printf ("%L second%s\n", seconds,
(gint)seconds > 1 ? "s" : "");
}
/* Else print the minutes and seconds. */
Expand Down
2 changes: 1 addition & 1 deletion src/controller.c
Expand Up @@ -1688,7 +1688,7 @@ rspamd_controller_handle_savemap (struct rspamd_http_connection_entry *conn_ent,
}

if (!found) {
msg_info_session ("map not found: %d", id);
msg_info_session ("map not found: %L", id);
rspamd_controller_send_error (conn_ent, 404, "Map id not found");
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/fuzzy_storage.c
Expand Up @@ -470,7 +470,7 @@ accept_fuzzy_socket (gint fd, short what, void *arg)
else {
/* Discard input */
server_stat->fuzzy_hashes_checked[RSPAMD_FUZZY_EPOCH6]++;
msg_debug ("invalid fuzzy command of size %d received", r);
msg_debug ("invalid fuzzy command of size %z received", r);
}

REF_RELEASE (session);
Expand Down
8 changes: 4 additions & 4 deletions src/libmime/images.c
Expand Up @@ -90,15 +90,15 @@ process_png_image (struct rspamd_task *task, GByteArray *data)
guint8 *p;

if (data->len < 24) {
msg_info_task ("bad png detected (maybe striped): <%s>", task->message_id);
msg_info_task ("bad png detected (maybe striped)");
return NULL;
}

/* In png we should find iHDR section and get data from it */
/* Skip signature and read header section */
p = data->data + 12;
if (memcmp (p, "IHDR", 4) != 0) {
msg_info_task ("png doesn't begins with IHDR section", task->message_id);
msg_info_task ("png doesn't begins with IHDR section");
return NULL;
}

Expand Down Expand Up @@ -154,7 +154,7 @@ process_gif_image (struct rspamd_task *task, GByteArray *data)
guint16 t;

if (data->len < 10) {
msg_info_task ("bad gif detected (maybe striped): <%s>", task->message_id);
msg_info_task ("bad gif detected (maybe striped)");
return NULL;
}

Expand All @@ -179,7 +179,7 @@ process_bmp_image (struct rspamd_task *task, GByteArray *data)
guint8 *p;

if (data->len < 28) {
msg_info_task ("bad bmp detected (maybe striped): <%s>", task->message_id);
msg_info_task ("bad bmp detected (maybe striped)");
return NULL;
}

Expand Down
2 changes: 1 addition & 1 deletion src/libmime/mime_expressions.c
Expand Up @@ -778,7 +778,7 @@ tree_url_callback (gpointer key, gpointer value, void *data)

if (G_UNLIKELY (param->re->is_test)) {
msg_info_task ("process test regexp %s for url %s returned FALSE",
struri (url));
param->re->regexp_text, struri (url));
}
}

Expand Down
5 changes: 2 additions & 3 deletions src/libmime/smtp_utils.c
Expand Up @@ -225,9 +225,8 @@ make_smtp_tempfile (struct smtp_session *session)
session->temp_name = rspamd_mempool_alloc (session->pool, r);
rspamd_snprintf (session->temp_name,
r,
"%s%crspamd-XXXXXX",
session->cfg->temp_dir,
G_DIR_SEPARATOR);
"%s/rspamd-XXXXXX",
session->cfg->temp_dir);
#ifdef HAVE_MKSTEMP
/* Umask is set before */
session->temp_fd = mkstemp (session->temp_name);
Expand Down
3 changes: 2 additions & 1 deletion src/libserver/cfg_rcl.c
Expand Up @@ -2186,7 +2186,8 @@ rspamd_rcl_parse_struct_keypair (rspamd_mempool_t *pool,
rspamd_snprintf (keybuf, sizeof (keybuf), "%s%s", sk, pk);
}
else {
rspamd_snprintf (keybuf, sizeof (keybuf), "%*s%s", sem - sk, sk, pk);
rspamd_snprintf (keybuf, sizeof (keybuf), "%*s%s", (gint)(sem - sk),
sk, pk);
}

key = rspamd_http_connection_make_key (keybuf, strlen (keybuf));
Expand Down
3 changes: 2 additions & 1 deletion src/libserver/cfg_utils.c
Expand Up @@ -1202,7 +1202,8 @@ rspamd_config_add_metric_symbol (struct rspamd_config *cfg,

if (g_hash_table_lookup (cfg->metrics_symbols, symbol) != NULL &&
!rewrite_existing) {
msg_debug_config ("symbol %s has been already registered, do not override");
msg_debug_config ("symbol %s has been already registered, do not override",
symbol);
return FALSE;
}

Expand Down
2 changes: 1 addition & 1 deletion src/libserver/dns.c
Expand Up @@ -215,7 +215,7 @@ dns_resolver_init (rspamd_logger_t *logger,
priority = strtoul (p, &err, 10);
if (err != NULL && *err != '\0') {
msg_info_config (
"bad character '%x', must be 'm' or 's' or a numeric priority",
"bad character '%xc', must be 'm' or 's' or a numeric priority",
*err);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/libserver/fuzzy_backend.c
Expand Up @@ -503,7 +503,7 @@ rspamd_fuzzy_backend_check (struct rspamd_fuzzy_backend *backend,
else {
shingle_values[i] = -1;
}
msg_debug_fuzzy_backend ("looking for shingle %d -> %L: %d", i,
msg_debug_fuzzy_backend ("looking for shingle %L -> %L: %d", i,
shcmd->sgl.hashes[i], rc);
}
rspamd_fuzzy_backend_cleanup_stmt (backend,
Expand Down Expand Up @@ -638,7 +638,7 @@ rspamd_fuzzy_backend_add (struct rspamd_fuzzy_backend *backend,
rspamd_fuzzy_backend_run_stmt (backend,
RSPAMD_FUZZY_BACKEND_INSERT_SHINGLE,
shcmd->sgl.hashes[i], i, id);
msg_debug_fuzzy_backend ("add shingle %d -> %L: %d",
msg_debug_fuzzy_backend ("add shingle %d -> %L: %L",
i,
shcmd->sgl.hashes[i],
id);
Expand Down
2 changes: 1 addition & 1 deletion src/libserver/protocol.c
Expand Up @@ -370,7 +370,7 @@ rspamd_protocol_handle_headers (struct rspamd_task *task,
IF_HEADER (RCPT_HEADER) {
if (!rspamd_task_add_recipient (task,
rspamd_mempool_ftokdup (task->task_pool, hv_tok))) {
msg_err_task ("bad from header: '%V'", h->value);
msg_err_task ("bad from header: '%T'", h->value);
}
debug_task ("read rcpt header, value: %V", hv);
}
Expand Down
2 changes: 1 addition & 1 deletion src/libserver/spf.c
Expand Up @@ -1608,7 +1608,7 @@ start_spf_parse (struct spf_record *rec, struct spf_resolved_element *resolved,
"<%s>: spf error for domain %s: bad spf record version: %*s",
rec->task->message_id,
rec->sender_domain,
sizeof (SPF_VER1_STR) - 1,
(gint)sizeof (SPF_VER1_STR) - 1,
begin);
return FALSE;
}
Expand Down
6 changes: 3 additions & 3 deletions src/libserver/task.c
Expand Up @@ -340,7 +340,7 @@ rspamd_task_load_message (struct rspamd_task *task,
task->msg.len = len;

if (task->msg.len == 0) {
msg_warn_task ("message has invalid message length: %ud",
msg_warn_task ("message has invalid message length: %uz",
task->msg.len);
g_set_error (&task->err, rspamd_task_quark(), RSPAMD_PROTOCOL_ERROR,
"Invalid length");
Expand All @@ -350,7 +350,7 @@ rspamd_task_load_message (struct rspamd_task *task,
if (task->flags & RSPAMD_TASK_FLAG_HAS_CONTROL) {
/* We have control chunk, so we need to process it separately */
if (task->msg.len < task->message_len) {
msg_warn_task ("message has invalid message length: %ud and total len: %ud",
msg_warn_task ("message has invalid message length: %ul and total len: %ul",
task->message_len, task->msg.len);
g_set_error (&task->err, rspamd_task_quark(), RSPAMD_PROTOCOL_ERROR,
"Invalid length");
Expand Down Expand Up @@ -495,7 +495,7 @@ rspamd_task_process (struct rspamd_task *task, guint stages)
task->processed_stages |= RSPAMD_TASK_STAGE_DONE;
}

msg_debug_task ("task is processed", st);
msg_debug_task ("task is processed");

return ret;
}
Expand Down
8 changes: 4 additions & 4 deletions src/libstat/stat_process.c
Expand Up @@ -330,8 +330,8 @@ preprocess_init_stat_token (gpointer k, gpointer v, gpointer d)

if (cl_runtime->clcf->max_tokens > 0 &&
cl_runtime->processed_tokens > cl_runtime->clcf->max_tokens) {
msg_debug_task ("<%s> contains more tokens than allowed for %s classifier: "
"%ud > %ud", cbdata->task, cl_runtime->clcf->name,
msg_debug_task ("message contains more tokens than allowed for %s classifier: "
"%uL > %ud", cl_runtime->clcf->name,
cl_runtime->processed_tokens,
cl_runtime->clcf->max_tokens);

Expand Down Expand Up @@ -638,8 +638,8 @@ rspamd_stat_learn_token (gpointer k, gpointer v, gpointer d)

if (cl_runtime->clcf->max_tokens > 0 &&
cl_runtime->processed_tokens > cl_runtime->clcf->max_tokens) {
msg_debug_task ("<%s> contains more tokens than allowed for %s classifier: "
"%ud > %ud", cbdata->task, cl_runtime->clcf->name,
msg_debug_task ("message contains more tokens than allowed for %s classifier: "
"%uL > %ud", cl_runtime->clcf->name,
cl_runtime->processed_tokens,
cl_runtime->clcf->max_tokens);

Expand Down
2 changes: 1 addition & 1 deletion src/libstat/tokenizers/osb.c
Expand Up @@ -125,7 +125,7 @@ rspamd_tokenizer_osb_config_from_ucl (rspamd_mempool_t * pool,
key = rspamd_decode_base32 (ucl_object_tostring (elt),
0, &keylen);
if (keylen < sizeof (rspamd_sipkey_t)) {
msg_warn ("siphash key is too short: %s", keylen);
msg_warn ("siphash key is too short: %z", keylen);
g_free (key);
}
else {
Expand Down
2 changes: 1 addition & 1 deletion src/libstat/tokenizers/tokenizers.c
Expand Up @@ -259,7 +259,7 @@ rspamd_tokenizer_get_word (rspamd_ftok_t * buf,
break;
case process_signature:
if (*p == '\r' || *p == '\n') {
msg_debug ("signature found: %*s", siglen, sig);
msg_debug ("signature found: %*s", (gint)siglen, sig);
return FALSE;
}
else if (*p != ' ' && *p != '-' && *p != '_') {
Expand Down
1 change: 0 additions & 1 deletion src/libutil/addr.c
Expand Up @@ -930,7 +930,6 @@ rspamd_parse_host_port_priority_strv (gchar **tokens,
errno = ERANGE;
msg_warn ("cannot parse port: %s, error: %s",
tokens[1],
*err_str,
strerror (errno));
hints.ai_flags ^= AI_NUMERICSERV;
}
Expand Down
2 changes: 1 addition & 1 deletion src/libutil/logger.c
Expand Up @@ -842,7 +842,7 @@ file_log_function (const gchar *log_domain,
mremain -= mr;
}
else {
mr = rspamd_snprintf (m, mremain, ": ", function);
mr = rspamd_snprintf (m, mremain, ": ");
m += mr;
mremain -= mr;
}
Expand Down
4 changes: 2 additions & 2 deletions src/libutil/map.c
Expand Up @@ -903,7 +903,7 @@ rspamd_hosts_fin (rspamd_mempool_t * pool, struct map_cb_data *data)
g_hash_table_destroy (data->prev_data);
}
if (data->cur_data) {
msg_info_pool ("read hash of %z elements", g_hash_table_size
msg_info_pool ("read hash of %d elements", g_hash_table_size
(data->cur_data));
}
}
Expand Down Expand Up @@ -932,7 +932,7 @@ rspamd_kv_list_fin (rspamd_mempool_t * pool, struct map_cb_data *data)
g_hash_table_destroy (data->prev_data);
}
if (data->cur_data) {
msg_info_pool ("read hash of %z elements", g_hash_table_size
msg_info_pool ("read hash of %d elements", g_hash_table_size
(data->cur_data));
}
}
Expand Down
33 changes: 18 additions & 15 deletions src/libutil/radix.c
Expand Up @@ -136,7 +136,7 @@ radix_find_compressed (radix_compressed_t * tree, guint8 *key, gsize keylen)
while (node && kremain) {
if (node->skipped) {
msg_debug_radix ("finding in the compressed node: %p at level %d",
node->value, cur_level);
(gpointer)node->value, cur_level);
/* It is obviously a leaf node */
if (radix_compare_compressed (node, key, keylen, cur_level)) {
return node->value;
Expand All @@ -151,7 +151,7 @@ radix_find_compressed (radix_compressed_t * tree, guint8 *key, gsize keylen)

msg_debug_radix ("finding value cur value: %p, left: %p, "
"right: %p, go %s, level: %d",
node->value, node->d.n.left,
(gpointer)node->value, node->d.n.left,
node->d.n.right, (kv & bit) ? "right" : "left",
cur_level);
if (kv & bit) {
Expand All @@ -175,7 +175,7 @@ radix_find_compressed (radix_compressed_t * tree, guint8 *key, gsize keylen)
/* We still have a node but no more key, so we can search for skipped node */
if (node->skipped) {
msg_debug_radix ("finding in the compressed node: %p at level %d",
node->value, cur_level);
(gpointer)node->value, cur_level);
/* It is obviously a leaf node */
if (radix_compare_compressed (node, key, keylen, cur_level)) {
return node->value;
Expand Down Expand Up @@ -230,7 +230,7 @@ radix_uncompress_path (radix_compressed_t *tree,
}

msg_debug_radix ("uncompress path for node: %p, left: %p, "
"right: %p, go %s", node->value, node->d.n.left,
"right: %p, go %s", (gpointer)node->value, node->d.n.left,
node->d.n.right, (*nkey & bit) ? "right" : "left");

bit >>= 1;
Expand All @@ -244,7 +244,7 @@ radix_uncompress_path (radix_compressed_t *tree,

/* Attach leaf node, that was previously a compressed node */
msg_debug_radix ("attach leaf node to %s with value %p", (*nkey & bit) ? "right" : "left",
leaf->value);
(gpointer)leaf->value);
if (*nkey & bit) {
node->d.n.right = leaf;
node->d.n.left = NULL;
Expand Down Expand Up @@ -281,7 +281,7 @@ radix_make_leaf_node (radix_compressed_t *tree,
}
node->value = value;
msg_debug_radix ("insert new leaf node with value %p to level %d",
value, level);
(gpointer)value, level);

return node;
}
Expand Down Expand Up @@ -322,13 +322,13 @@ radix_replace_node (radix_compressed_t *tree,
oldval = node->value;
node->value = value;
msg_debug_radix ("replace value for leaf node with: %p, old value: %p",
value, oldval);
(gpointer)value, (gpointer)oldval);
}
else {
oldval = node->value;
node->value = value;
msg_debug_radix ("replace value for node with: %p, old value: %p",
value, oldval);
(gpointer)value, (gpointer)oldval);
}

return oldval;
Expand Down Expand Up @@ -400,7 +400,8 @@ radix_uncompress_node (radix_compressed_t *tree,
* - otherwise we insert new compressed leaf node
*/
if (cur_level == target_level) {
msg_debug_radix ("insert detached leaf node with value: %p", value);
msg_debug_radix ("insert detached leaf node with value: %p",
(gpointer)value);
nnode->value = value;
}
else if (masked) {
Expand All @@ -415,8 +416,9 @@ radix_uncompress_node (radix_compressed_t *tree,
leaf = nnode->d.n.right;
}
msg_debug_radix ("move leaf node with value: %p, to level %ud, "
"set leaf node value to %p and level %ud", nnode->value,
cur_level, value, target_level);
"set leaf node value to %p and level %ud", (gpointer)nnode->value,
cur_level,
(gpointer)value, target_level);
radix_move_up_compressed_leaf (tree, leaf, nnode, value, key, keylen,
target_level);
}
Expand Down Expand Up @@ -456,7 +458,7 @@ radix_insert_compressed (radix_compressed_t * tree,

g_assert (keybits >= masklen);
msg_debug_radix ("want insert value %p with mask %z, key: %*xs",
value, masklen, (int)keylen, key);
(gpointer)value, masklen, (int)keylen, key);

node = tree->root;
next = node;
Expand Down Expand Up @@ -500,7 +502,7 @@ radix_insert_compressed (radix_compressed_t * tree,
tree->size ++;
}
else if (next->value == RADIX_NO_VALUE) {
msg_debug_radix ("insert value node with %p", value);
msg_debug_radix ("insert value node with %p", (gpointer)value);
next->value = value;
tree->size ++;
}
Expand Down Expand Up @@ -539,8 +541,9 @@ radix_insert_compressed (radix_compressed_t * tree,
target_level, value, TRUE);
*prev = next;
msg_debug_radix ("move leaf node with value: %p, to level %ud, "
"set leaf node value to %p and level %ud", next->value,
cur_level, value, target_level);
"set leaf node value to %p and level %ud", (gpointer)next->value,
cur_level,
(gpointer)value, target_level);
next->skipped = FALSE;
if (*k & bit) {
next->d.n.right = node;
Expand Down
6 changes: 3 additions & 3 deletions src/libutil/rrd.c
Expand Up @@ -743,7 +743,7 @@ rspamd_rrd_update_pdp_prep (struct rspamd_rrd_file *file,
rspamd_strlcpy (file->pdp_prep[i].last_ds, "U",
sizeof (file->pdp_prep[i].last_ds));
pdp_new[i] = NAN;
msg_debug_rrd ("adding unknown point interval %.3f is less than heartbeat %.3f",
msg_debug_rrd ("adding unknown point interval %.3f is less than heartbeat %l",
interval, file->ds_def[i].par[RRD_DS_mrhb_cnt].lv);
}
else {
Expand Down Expand Up @@ -1167,7 +1167,7 @@ rspamd_rrd_add_record (struct rspamd_rrd_file *file,
rra_steps[i] = 0;
}

msg_debug_rrd ("cdp: %d, rra steps: %d(%d), pdp steps: %d",
msg_debug_rrd ("cdp: %ud, rra steps: %ul(%ul), pdp steps: %ul",
i, rra_steps[i], pdp_offset, pdp_steps);

/* Update this specific CDP */
Expand Down Expand Up @@ -1238,7 +1238,7 @@ rspamd_rrd_file_default (const gchar *path,

if (file->stat_head->ds_cnt != 4 || file->stat_head->rra_cnt != 4) {
msg_err_rrd ("rrd file is not suitable for rspamd: it has "
"%d ds and %d rra", file->stat_head->ds_cnt,
"%ul ds and %ul rra", file->stat_head->ds_cnt,
file->stat_head->rra_cnt);
g_set_error (err, rrd_error_quark (), EINVAL, "bad rrd file");
rspamd_rrd_close (file);
Expand Down

0 comments on commit f3585bb

Please sign in to comment.