From e14cef28ac9652579535807afb5619af71a4f9ef Mon Sep 17 00:00:00 2001 From: davidpanderson Date: Tue, 5 Nov 2019 23:25:06 -0800 Subject: [PATCH] Fix more compiler warnings (snprintf, sigaction). No functional changes. --- client/app.cpp | 2 +- client/app_control.cpp | 4 ++-- client/app_start.cpp | 10 +++++----- client/boinc_cmd.cpp | 2 +- client/client_msgs.cpp | 4 ++-- client/cpu_sched.cpp | 4 +++- client/cs_files.cpp | 6 +++--- client/cs_notice.cpp | 4 ++-- client/cs_scheduler.cpp | 2 +- client/file_names.cpp | 2 +- client/file_xfer.h | 2 +- client/gpu_detect.cpp | 2 +- client/gui_rpc_server_ops.cpp | 2 +- client/hostinfo_unix.cpp | 4 ++-- client/http_curl.cpp | 2 +- client/http_curl.h | 2 +- client/main.cpp | 2 +- client/sandbox.cpp | 2 +- lib/diagnostics.cpp | 4 ++-- lib/diagnostics.h | 4 ++-- 20 files changed, 34 insertions(+), 32 deletions(-) diff --git a/client/app.cpp b/client/app.cpp index 42adabc6fc..d715f50e79 100644 --- a/client/app.cpp +++ b/client/app.cpp @@ -1082,7 +1082,7 @@ int ACTIVE_TASK::handle_upload_files() { "Can't find uploadable file %s", p ); } - snprintf(path, sizeof(path), "%s/%s", slot_dir, buf); + snprintf(path, sizeof(path), "%.*s/%.*s", DIR_LEN, slot_dir, FILE_LEN, buf); delete_project_owned_file(path, true); // delete the link file } } diff --git a/client/app_control.cpp b/client/app_control.cpp index eca833180b..d85053885c 100644 --- a/client/app_control.cpp +++ b/client/app_control.cpp @@ -542,7 +542,7 @@ void ACTIVE_TASK::handle_exited_app(int stat) { snprintf(err_msg, sizeof(err_msg), "process exited with code %d (0x%x, %d)", result->exit_status, result->exit_status, - (-1<<8)|result->exit_status + (~0xff)|result->exit_status ); gstate.report_result_error(*result, err_msg); } else { @@ -1554,7 +1554,7 @@ void ACTIVE_TASK_SET::get_msgs() { } if (atp->get_app_status_msg()) { if (old_time != atp->checkpoint_cpu_time) { - char buf[256]; + char buf[512]; sprintf(buf, "%s checkpointed", atp->result->name); if (atp->overdue_checkpoint) { gstate.request_schedule_cpus(buf); diff --git a/client/app_start.cpp b/client/app_start.cpp index a7c48e9815..95ecacd3c7 100644 --- a/client/app_start.cpp +++ b/client/app_start.cpp @@ -351,7 +351,7 @@ static int create_dirs_for_logical_name( static void prepend_prefix(APP_VERSION* avp, char* in, char* out, int len) { if (strlen(avp->file_prefix)) { - snprintf(out, len, "%s/%s", avp->file_prefix, in); + snprintf(out, len, "%.16s/%.200s", avp->file_prefix, in); } else { strlcpy(out, in, len); } @@ -467,7 +467,7 @@ int ACTIVE_TASK::link_user_files() { } int ACTIVE_TASK::copy_output_files() { - char slotfile[256], projfile[256], open_name[256]; + char slotfile[MAXPATHLEN], projfile[256], open_name[256]; unsigned int i; for (i=0; ioutput_files.size(); i++) { FILE_REF& fref = result->output_files[i]; @@ -476,7 +476,7 @@ int ACTIVE_TASK::copy_output_files() { prepend_prefix( app_version, fref.open_name, open_name, sizeof(open_name) ); - snprintf(slotfile, sizeof(slotfile), "%s/%s", slot_dir, open_name); + snprintf(slotfile, sizeof(slotfile), "%.*s/%.*s", DIR_LEN, slot_dir, FILE_LEN, open_name); get_pathname(fip, projfile, sizeof(projfile)); int retval = boinc_rename(slotfile, projfile); // the rename fails if the output file isn't there. @@ -1108,7 +1108,7 @@ int ACTIVE_TASK::start(bool test) { if (test) { strcpy(buf, exec_path); } else { - snprintf(buf, sizeof(buf), "../../%s", exec_path); + snprintf(buf, sizeof(buf), "../../%.1024s", exec_path); } if (g_use_sandbox) { char switcher_path[MAXPATHLEN]; @@ -1167,7 +1167,7 @@ error: // gstate.input_files_available(result, true); char err_msg[4096]; - snprintf(err_msg, sizeof(err_msg), "couldn't start app: %s", buf); + snprintf(err_msg, sizeof(err_msg), "couldn't start app: %.256s", buf); gstate.report_result_error(*result, err_msg); if (log_flags.task_debug) { msg_printf(wup->project, MSG_INFO, diff --git a/client/boinc_cmd.cpp b/client/boinc_cmd.cpp index a02607f0f1..369acd63d8 100644 --- a/client/boinc_cmd.cpp +++ b/client/boinc_cmd.cpp @@ -423,7 +423,7 @@ int main(int argc, char** argv) { } } else if (!strcmp(cmd, "--set_host_info")) { HOST_INFO h; - memset(&h, 0, sizeof(h)); + h.clear(); char* pn = next_arg(argc, argv, i); safe_strcpy(h.product_name, pn); retval = rpc.set_host_info(h); diff --git a/client/client_msgs.cpp b/client/client_msgs.cpp index 29347bf52b..90ce434851 100644 --- a/client/client_msgs.cpp +++ b/client/client_msgs.cpp @@ -75,10 +75,10 @@ void show_message( // switch (priority) { case MSG_INTERNAL_ERROR: - snprintf(event_msg, sizeof(event_msg), "[error] %s", message); + snprintf(event_msg, sizeof(event_msg), "[error] %.512s", message); break; case MSG_SCHEDULER_ALERT: - snprintf(event_msg, sizeof(event_msg), "%s: %s", + snprintf(event_msg, sizeof(event_msg), "%.64s: %.512s", _("Message from server"), message ); break; diff --git a/client/cpu_sched.cpp b/client/cpu_sched.cpp index 661ebd7089..bce568d608 100644 --- a/client/cpu_sched.cpp +++ b/client/cpu_sched.cpp @@ -1227,7 +1227,7 @@ bool CLIENT_STATE::enforce_run_list(vector& run_list) { // and prune those that can't be assigned // assign_coprocs(run_list); - bool scheduled_mt = false; + //bool scheduled_mt = false; // prune jobs that don't fit in RAM or that exceed CPU usage limits. // Mark the rest as SCHEDULED @@ -1337,9 +1337,11 @@ bool CLIENT_STATE::enforce_run_list(vector& run_list) { continue; } +#if 0 if (rp->avp->avg_ncpus > 1) { scheduled_mt = true; } +#endif ncpus_used += rp->avp->avg_ncpus; atp->next_scheduler_state = CPU_SCHED_SCHEDULED; ram_left -= wss; diff --git a/client/cs_files.cpp b/client/cs_files.cpp index da53db6600..cce0230ab2 100644 --- a/client/cs_files.cpp +++ b/client/cs_files.cpp @@ -193,7 +193,7 @@ int FILE_INFO::verify_file( // if (download_gzipped && !boinc_file_exists(pathname)) { char gzpath[MAXPATHLEN]; - snprintf(gzpath, sizeof(gzpath), "%s.gz", pathname); + snprintf(gzpath, sizeof(gzpath), "%.2048s.gz", pathname); if (boinc_file_exists(gzpath) ) { if (allow_async && nbytes > ASYNC_FILE_THRESHOLD) { ASYNC_VERIFY* avp = new ASYNC_VERIFY; @@ -419,8 +419,8 @@ bool CLIENT_STATE::create_and_delete_pers_file_xfers() { if (fip->download_gzipped) { char path[MAXPATHLEN], from_path[MAXPATHLEN], to_path[MAXPATHLEN]; get_pathname(fip, path, sizeof(path)); - snprintf(from_path, sizeof(from_path), "%s.gzt", path); - snprintf(to_path, sizeof(to_path), "%s.gz", path); + snprintf(from_path, sizeof(from_path), "%.2048s.gzt", path); + snprintf(to_path, sizeof(to_path), "%.2048s.gz", path); boinc_rename(from_path, to_path); } diff --git a/client/cs_notice.cpp b/client/cs_notice.cpp index c8bcde0066..6448c56073 100644 --- a/client/cs_notice.cpp +++ b/client/cs_notice.cpp @@ -59,7 +59,7 @@ static bool cmp(NOTICE n1, NOTICE n2) { static void project_feed_list_file_name(PROJ_AM* p, char* buf, int len) { char url[256]; escape_project_url(p->master_url, url); - snprintf(buf, len, "notices/feeds_%s.xml", url); + snprintf(buf, len, "notices/feeds_%.128s.xml", url); } // parse feed descs from scheduler reply or feed list file @@ -619,7 +619,7 @@ void NOTICES::write(int seqno, GUI_RPC_CONN& grc, bool public_only) { void RSS_FEED::feed_file_name(char* path, int len) { char buf[256]; escape_project_url(url_base, buf); - snprintf(path, len, NOTICES_DIR"/%s.xml", buf); + snprintf(path, len, NOTICES_DIR"/%.128s.xml", buf); } void RSS_FEED::archive_file_name(char* path, int len) { diff --git a/client/cs_scheduler.cpp b/client/cs_scheduler.cpp index 37000151b5..03eea3b805 100644 --- a/client/cs_scheduler.cpp +++ b/client/cs_scheduler.cpp @@ -1188,7 +1188,7 @@ void CLIENT_STATE::check_project_timeout() { if (p->possibly_backed_off && now > p->min_rpc_time) { p->possibly_backed_off = false; char buf[256]; - snprintf(buf, sizeof(buf), "Backoff ended for %s", p->get_project_name()); + snprintf(buf, sizeof(buf), "Backoff ended for %.128s", p->get_project_name()); request_work_fetch(buf); } } diff --git a/client/file_names.cpp b/client/file_names.cpp index 3909737bfb..ca86e29ef8 100644 --- a/client/file_names.cpp +++ b/client/file_names.cpp @@ -243,7 +243,7 @@ void delete_old_slot_dirs() { // Clean these up here. (We must do this before deleting the // INIT_DATA_FILE, if any, from each slot directory.) // - snprintf(init_data_path, sizeof(init_data_path), "%s/%s", path, INIT_DATA_FILE); + snprintf(init_data_path, sizeof(init_data_path), "%.*s/%.*s", DIR_LEN, path, FILE_LEN, INIT_DATA_FILE); shmem_seg_name = ftok(init_data_path, 1); if (shmem_seg_name != -1) { destroy_shmem(shmem_seg_name); diff --git a/client/file_xfer.h b/client/file_xfer.h index 7a5dbb83d2..63c4814439 100644 --- a/client/file_xfer.h +++ b/client/file_xfer.h @@ -34,7 +34,7 @@ class FILE_XFER : public HTTP_OP { public: FILE_INFO* fip; char pathname[256]; - char header[4096]; + char header[8192]; bool file_size_query; bool is_upload; double starting_size; diff --git a/client/gpu_detect.cpp b/client/gpu_detect.cpp index 550ddc39c1..01b8870a7a 100644 --- a/client/gpu_detect.cpp +++ b/client/gpu_detect.cpp @@ -201,7 +201,7 @@ void COPROCS::correlate_gpus( IGNORE_GPU_INSTANCE &ignore_gpu_instance ) { unsigned int i; - char buf[256], buf2[256]; + char buf[256], buf2[1024]; nvidia.correlate(use_all, ignore_gpu_instance[PROC_TYPE_NVIDIA_GPU]); ati.correlate(use_all, ignore_gpu_instance[PROC_TYPE_AMD_GPU]); diff --git a/client/gui_rpc_server_ops.cpp b/client/gui_rpc_server_ops.cpp index 272868c698..a0967f0b42 100644 --- a/client/gui_rpc_server_ops.cpp +++ b/client/gui_rpc_server_ops.cpp @@ -1349,7 +1349,7 @@ vector auth_infos; // check HTTP authentication info // bool valid_auth(int id, long seqno, char* hash, char* request) { - char buf[256], my_hash[256]; + char buf[1024], my_hash[256]; //printf("valid_auth: id %d seqno %ld hash %s\n", id, seqno, hash); for (unsigned int i=0; i get_tty_list() { // Create a list of all terminal devices on the system. char devname[1024]; - char fullname[1024]; + char fullname[MAXPATHLEN]; int done,i=0; vector tty_list; @@ -1594,7 +1594,7 @@ vector get_tty_list() { if (!done && (strstr(devname,tty_patterns[i].dev) == devname)) { // don't add anything starting with . if (devname[0] != '.') { - sprintf(fullname,"%s/%s",tty_patterns[i].dir,devname); + sprintf(fullname,"%s/%s", tty_patterns[i].dir, devname); tty_list.push_back(fullname); } } diff --git a/client/http_curl.cpp b/client/http_curl.cpp index a006432e88..68556d2e6b 100644 --- a/client/http_curl.cpp +++ b/client/http_curl.cpp @@ -77,7 +77,7 @@ static void get_user_agent_string() { ); if (strlen(gstate.client_brand)) { char buf[256]; - snprintf(buf, sizeof(buf), " (%s)", gstate.client_brand); + snprintf(buf, sizeof(buf), " (%.80s)", gstate.client_brand); safe_strcat(g_user_agent_string, buf); } } diff --git a/client/http_curl.h b/client/http_curl.h index d3f6dfd769..a5153b3259 100644 --- a/client/http_curl.h +++ b/client/http_curl.h @@ -60,7 +60,7 @@ public: char m_url[1024]; char m_curl_ca_bundle_location[256]; // string needed for ssl support - char m_curl_user_credentials[128]; + char m_curl_user_credentials[1024]; // string needed for proxy username/password int content_length; diff --git a/client/main.cpp b/client/main.cpp index df8b762895..90c49378a3 100644 --- a/client/main.cpp +++ b/client/main.cpp @@ -158,7 +158,7 @@ void log_message_error(const char* msg, int error_code) { } #ifndef _WIN32 -static void signal_handler(int signum) { +static void signal_handler(int signum, siginfo_t*, void*) { msg_printf(NULL, MSG_INFO, "Received signal %d", signum); switch(signum) { case SIGHUP: diff --git a/client/sandbox.cpp b/client/sandbox.cpp index 7916d69733..b8d576f21b 100644 --- a/client/sandbox.cpp +++ b/client/sandbox.cpp @@ -346,7 +346,7 @@ int client_clean_out_dir( if (except && !strcmp(except, filename)) { continue; } - snprintf(path, sizeof(path), "%s/%s", dirpath, filename); + snprintf(path, sizeof(path), "%.*s/%.*s", DIR_LEN, dirpath, FILE_LEN, filename); if (is_dir(path)) { retval = client_clean_out_dir(path, NULL); if (retval) final_retval = retval; diff --git a/lib/diagnostics.cpp b/lib/diagnostics.cpp index b6d955e8ba..f694ba0d42 100644 --- a/lib/diagnostics.cpp +++ b/lib/diagnostics.cpp @@ -696,7 +696,7 @@ extern "C" void boinc_set_signal_handler(int sig, handler_t handler) { struct sigaction temp; sigaction(sig, NULL, &temp); if (temp.sa_handler != SIG_IGN) { - temp.sa_handler = (void (*)(int))handler; + temp.sa_sigaction = handler; sigaction(sig, &temp, NULL); } #else @@ -755,7 +755,7 @@ static char *xtoa(size_t x) { #ifdef ANDROID_VOODOO void boinc_catch_signal(int signal, struct siginfo *siginfo, void *sigcontext) { #else -void boinc_catch_signal(int signal, struct siginfo *, void *) { +void boinc_catch_signal(int signal, siginfo_t*, void *) { #endif // ANDROID #else void boinc_catch_signal(int signal) { diff --git a/lib/diagnostics.h b/lib/diagnostics.h index efdf5215a0..23b8a83c42 100644 --- a/lib/diagnostics.h +++ b/lib/diagnostics.h @@ -129,8 +129,8 @@ extern UINT WINAPI diagnostics_unhandled_exception_monitor(LPVOID lpParameter); extern LONG CALLBACK boinc_catch_signal(EXCEPTION_POINTERS *ExceptionInfo); #else #ifdef HAVE_SIGACTION -typedef void (*handler_t)(int, struct siginfo *, void *); -extern void boinc_catch_signal(int signal, struct siginfo *siginfo, void *sigcontext); +typedef void (*handler_t)(int, siginfo_t*, void *); +extern void boinc_catch_signal(int signal, siginfo_t *siginfo, void *sigcontext); #else typedef void (*handler_t)(int); extern void boinc_catch_signal(int signal);