Skip to content

Commit

Permalink
Fixing basic CodeQL alerts (#384)
Browse files Browse the repository at this point in the history
* Fixing basic CodeQL alerts

Many of these are just typing problems in debug logs and such. However,
more-defined behavior is better than undefined, so we'll center on
those. This may change some log lines but that's not really a surface
whose behaviors we plan to guarantee.
  • Loading branch information
SpamapS authored Nov 24, 2023
1 parent 0fcbe18 commit 581f757
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions libgearman-server/connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ void gearman_server_con_free(gearman_server_con_st *con)

if (con->is_cleaned_up)
{
gearmand_log_error(GEARMAN_DEFAULT_LOG_PARAM, "con %llu is already cleaned-up. returning", con);
gearmand_log_error(GEARMAN_DEFAULT_LOG_PARAM, "con %p is already cleaned-up. returning", con);
return;
}

Expand Down Expand Up @@ -334,7 +334,7 @@ void gearman_server_con_set_id(gearman_server_con_st *con,

gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM,
"identifier set to %.*s",
min_size, con->id);
(uint32_t)min_size, con->id);
}

void gearman_server_con_free_worker(gearman_server_con_st *con,
Expand Down Expand Up @@ -692,7 +692,7 @@ gearmand_error_t gearman_server_con_add_job_timeout(gearman_server_con_st *con,
worker->timeout= 1000;
}

gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, "Adding timeout on %s for %s (%dl)",
gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, "Adding timeout on %s for %s (%ld)",
job->function->function_name,
job->job_handle,
worker->timeout);
Expand Down
2 changes: 1 addition & 1 deletion libgearman-server/plugins/queue/redis/queue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ static gearmand_error_t _hiredis_add(gearman_server_st *, void *context,
return gearmand_log_gerror(
GEARMAN_DEFAULT_LOG_PARAM,
GEARMAND_QUEUE_ERROR,
"failed to insert '%.*s' into redis", key.size(), &key[0]);
"failed to insert '%.*s' into redis", (uint32_t)key.size(), &key[0]);
}

static gearmand_error_t _hiredis_flush(gearman_server_st *, void *)
Expand Down
8 changes: 4 additions & 4 deletions libgearman-server/text.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ gearmand_error_t server_run_text(gearman_server_con_st *server_con,
if (packet->argc)
{
gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, "text command %.*s %d arguments",
packet->arg_size[0], packet->arg[0],
int(packet->argc));
(uint32_t)packet->arg_size[0], packet->arg[0],
packet->argc);
}

#if 0
Expand Down Expand Up @@ -370,8 +370,8 @@ gearmand_error_t server_run_text(gearman_server_con_st *server_con,
}
else
{
gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, "Failed to find command %.*s(%" PRIu64 ")",
packet->arg_size[0], packet->arg[0],
gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, "Failed to find command %.*s(%zu)",
(uint32_t)packet->arg_size[0], packet->arg[0],
packet->arg_size[0]);
data.vec_printf(TEXT_ERROR_UNKNOWN_COMMAND, (int)packet->arg_size[0], (char *)(packet->arg[0]));
}
Expand Down
2 changes: 1 addition & 1 deletion libgearman-server/thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ gearman_server_thread_run(gearman_server_thread_st *thread,
if (server_con->is_dead && server_con->proc_removed)
gearman_server_con_free(server_con);
else
gearmand_log_error(GEARMAN_DEFAULT_LOG_PARAM, "con %llu isn't dead %d or proc removed %d, but is in to_be_freed_list",
gearmand_log_error(GEARMAN_DEFAULT_LOG_PARAM, "con %p isn't dead %d or proc removed %d, but is in to_be_freed_list",
server_con, server_con->is_dead, server_con->proc_removed);
}

Expand Down
8 changes: 4 additions & 4 deletions libgearman/check.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ gearman_return_t CancelCheck::success(gearman_connection_st* con)

return gearman_universal_set_error(_universal, maybe_server_error, GEARMAN_AT, "%s:%s %.*s:%.*s",
con->host(), con->service(),
con->_packet.arg_size[0], con->_packet.arg[0],
con->_packet.arg_size[1], con->_packet.arg[1]
(uint32_t)con->_packet.arg_size[0], con->_packet.arg[0],
(uint32_t)con->_packet.arg_size[1], con->_packet.arg[1]
);
}

Expand All @@ -127,13 +127,13 @@ gearman_return_t OptionCheck::success(gearman_connection_st* con)

return gearman_universal_set_error(_universal, maybe_server_error, GEARMAN_AT, "%s:%s Invalid option %.*s",
con->host(), con->service(),
con->_packet.arg_size[0], con->_packet.arg[0]
(uint32_t)con->_packet.arg_size[0], con->_packet.arg[0]
);
}

return gearman_universal_set_error(_universal, GEARMAN_INVALID_SERVER_OPTION, GEARMAN_AT, "%s:%s Invalid option %.*s",
con->host(), con->service(),
con->_packet.arg_size[0], con->_packet.arg[0]
(uint32_t)con->_packet.arg_size[0], con->_packet.arg[0]
);
}

Expand Down

0 comments on commit 581f757

Please sign in to comment.