From 581f757f59e186b9a8d41f1b09967961c21cf7e2 Mon Sep 17 00:00:00 2001 From: Clint Byrum Date: Fri, 24 Nov 2023 07:39:29 -0800 Subject: [PATCH] Fixing basic CodeQL alerts (#384) * 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. --- libgearman-server/connection.cc | 6 +++--- libgearman-server/plugins/queue/redis/queue.cc | 2 +- libgearman-server/text.cc | 8 ++++---- libgearman-server/thread.cc | 2 +- libgearman/check.cc | 8 ++++---- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/libgearman-server/connection.cc b/libgearman-server/connection.cc index f9cc62942..22b1428af 100644 --- a/libgearman-server/connection.cc +++ b/libgearman-server/connection.cc @@ -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; } @@ -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, @@ -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); diff --git a/libgearman-server/plugins/queue/redis/queue.cc b/libgearman-server/plugins/queue/redis/queue.cc index 93ab1d684..a0ff30161 100644 --- a/libgearman-server/plugins/queue/redis/queue.cc +++ b/libgearman-server/plugins/queue/redis/queue.cc @@ -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 *) diff --git a/libgearman-server/text.cc b/libgearman-server/text.cc index bd99d98e7..abc10a7b2 100644 --- a/libgearman-server/text.cc +++ b/libgearman-server/text.cc @@ -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 @@ -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])); } diff --git a/libgearman-server/thread.cc b/libgearman-server/thread.cc index 7219e55a4..247611719 100644 --- a/libgearman-server/thread.cc +++ b/libgearman-server/thread.cc @@ -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); } diff --git a/libgearman/check.cc b/libgearman/check.cc index 5ee18734e..f39e7ed39 100644 --- a/libgearman/check.cc +++ b/libgearman/check.cc @@ -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] ); } @@ -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] ); }