Commit e14cef28 authored by davidpanderson's avatar davidpanderson

Fix more compiler warnings (snprintf, sigaction). No functional changes.

parent 22de12f7
......@@ -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
}
}
......
......@@ -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);
......
......@@ -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; i<result->output_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,
......
......@@ -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);
......
......@@ -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;
......
......@@ -1227,7 +1227,7 @@ bool CLIENT_STATE::enforce_run_list(vector<RESULT*>& 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<RESULT*>& 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;
......
......@@ -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);
}
......
......@@ -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) {
......
......@@ -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);
}
}
......
......@@ -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);
......
......@@ -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;
......
......@@ -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]);
......
......@@ -1349,7 +1349,7 @@ vector<AUTH_INFO> 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<auth_infos.size(); i++) {
AUTH_INFO& ai = auth_infos[i];
......
......@@ -1580,7 +1580,7 @@ static const struct dir_tty_dev {
vector<string> 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<string> tty_list;
......@@ -1594,7 +1594,7 @@ vector<string> 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);
}
}
......
......@@ -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);
}
}
......
......@@ -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;
......
......@@ -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:
......
......@@ -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;
......
......@@ -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) {
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment