Commit 22de12f7 authored by davidpanderson's avatar davidpanderson

Fix compiler warnings. No functional change

parent 26e28eb5
......@@ -430,7 +430,7 @@ int RESULT::write_gui(MIOFILE& out) {
}
} else if (avp->missing_coproc) {
snprintf(resources, sizeof(resources),
"%.3g %s + %s GPU (missing)",
"%.3g %s + %.12s GPU (missing)",
avp->avg_ncpus,
cpu_string(avp->avg_ncpus),
avp->missing_coproc_name
......
......@@ -718,7 +718,7 @@ int APP_CONFIG::parse_gpu_versions(
continue;
}
if (log_flags.unparsed_xml) {
snprintf(buf, sizeof(buf), "Unparsed line in app_config.xml: %s", xp.parsed_tag);
snprintf(buf, sizeof(buf), "Unparsed line in app_config.xml: %.128s", xp.parsed_tag);
mv.push_back(string(buf));
}
}
......@@ -755,7 +755,7 @@ int APP_CONFIG::parse(XML_PARSER& xp, MSG_VEC& mv, LOG_FLAGS& log_flags) {
// unparsed XML not considered an error; maybe it should be?
//
if (log_flags.unparsed_xml) {
snprintf(buf, sizeof(buf), "Unparsed line in app_config.xml: %s", xp.parsed_tag);
snprintf(buf, sizeof(buf), "Unparsed line in app_config.xml: %.128s", xp.parsed_tag);
mv.push_back(string(buf));
}
xp.skip_unexpected(log_flags.unparsed_xml, "APP_CONFIG::parse");
......@@ -773,7 +773,7 @@ int APP_VERSION_CONFIG::parse(
while (!xp.get_tag()) {
if (!xp.is_tag) {
snprintf(buf, sizeof(buf), "unexpected text '%s' in app_config.xml", xp.parsed_tag);
snprintf(buf, sizeof(buf), "unexpected text '%.128s' in app_config.xml", xp.parsed_tag);
mv.push_back(string(buf));
return ERR_XML_PARSE;
}
......@@ -784,7 +784,7 @@ int APP_VERSION_CONFIG::parse(
if (xp.parse_double("avg_ncpus", avg_ncpus)) continue;
if (xp.parse_double("ngpus", ngpus)) continue;
if (log_flags.unparsed_xml) {
snprintf(buf, sizeof(buf), "Unparsed line in app_config.xml: %s", xp.parsed_tag);
snprintf(buf, sizeof(buf), "Unparsed line in app_config.xml: %.128s", xp.parsed_tag);
mv.push_back(string(buf));
}
xp.skip_unexpected(log_flags.unparsed_xml, "APP_VERSION_CONFIG::parse");
......@@ -799,7 +799,7 @@ int APP_CONFIGS::parse(XML_PARSER& xp, MSG_VEC& mv, LOG_FLAGS& log_flags) {
clear();
while (!xp.get_tag()) {
if (!xp.is_tag) {
snprintf(buf, sizeof(buf), "unexpected text '%s' in app_config.xml", xp.parsed_tag);
snprintf(buf, sizeof(buf), "unexpected text '%.128s' in app_config.xml", xp.parsed_tag);
mv.push_back(string(buf));
return ERR_XML_PARSE;
}
......@@ -834,7 +834,7 @@ int APP_CONFIGS::parse(XML_PARSER& xp, MSG_VEC& mv, LOG_FLAGS& log_flags) {
if (xp.parse_bool("report_results_immediately", report_results_immediately)) {
continue;
}
snprintf(buf, sizeof(buf), "Unknown tag in app_config.xml: %s", xp.parsed_tag);
snprintf(buf, sizeof(buf), "Unknown tag in app_config.xml: %.128s", xp.parsed_tag);
mv.push_back(string(buf));
xp.skip_unexpected(log_flags.unparsed_xml, "APP_CONFIGS::parse");
......
......@@ -740,7 +740,7 @@ char *check_validity(
char file[MAXPATHLEN];
while (!dir_scan(file, dir, sizeof(file))) {
char fpath[MAXPATHLEN];
snprintf(fpath, sizeof(fpath), "%s/%s", certPath, file);
snprintf(fpath, sizeof(fpath), "%.*s/%.*s", DIR_LEN, certPath, FILE_LEN, file);
// TODO : replace '128'
if (check_validity_of_cert(fpath, md5_md, signature, 128, caPath)) {
dir_close(dir);
......
......@@ -83,7 +83,6 @@ static _CrtMemState difference_snapshot;
#endif
static int diagnostics_initialized = false;
static int flags;
static char stdout_log[MAXPATHLEN];
......@@ -295,10 +294,10 @@ int diagnostics_init(
boinc_mkdir(user_dir);
}
snprintf(stdout_log, sizeof(stdout_log), "%s/%s.txt", user_dir, stdout_prefix);
snprintf(stdout_archive, sizeof(stdout_archive), "%s/%s.old", user_dir, stdout_prefix);
snprintf(stderr_log, sizeof(stderr_log), "%s/%s.txt", user_dir, stderr_prefix);
snprintf(stderr_archive, sizeof(stderr_archive), "%s/%s.old", user_dir, stderr_prefix);
snprintf(stdout_log, sizeof(stdout_log), "%.*s/%.*s.txt", DIR_LEN, user_dir, FILE_LEN, stdout_prefix);
snprintf(stdout_archive, sizeof(stdout_archive), "%.*s/%.*s.old", DIR_LEN, user_dir, FILE_LEN, stdout_prefix);
snprintf(stderr_log, sizeof(stderr_log), "%.*s/%.*s.txt", DIR_LEN, user_dir, FILE_LEN, stderr_prefix);
snprintf(stderr_archive, sizeof(stderr_archive), "%.*s/%.*s.old", DIR_LEN, user_dir, FILE_LEN, stderr_prefix);
} else {
......
......@@ -403,7 +403,7 @@ int clean_out_dir(const char* dirpath) {
retval = dir_scan(filename, dirp, sizeof(filename));
if (retval) break;
snprintf(path, sizeof(path), "%s/%s", dirpath, filename);
snprintf(path, sizeof(path), "%.*s/%.*s", DIR_LEN, dirpath, FILE_LEN, filename);
path[sizeof(path)-1] = 0;
clean_out_dir(path);
......@@ -443,7 +443,7 @@ int dir_size(const char* dirpath, double& size, bool recurse) {
dsize = 0.0;
snprintf(buf, sizeof(buf), "%s/%s", dirpath, findData.cFileName);
snprintf(buf, sizeof(buf), "%.*s/%.*s", DIR_LEN, dirpath, FILE_LEN, findData.cFileName);
buf[sizeof(buf)-1] = 0;
dir_size(buf, dsize, true);
......@@ -467,7 +467,7 @@ int dir_size(const char* dirpath, double& size, bool recurse) {
retval = dir_scan(filename, dirp, sizeof(filename));
if (retval) break;
snprintf(subdir, sizeof(subdir), "%s/%s", dirpath, filename);
snprintf(subdir, sizeof(subdir), "%.*s/%.*s", DIR_LEN, dirpath, FILE_LEN, filename);
subdir[sizeof(subdir)-1] = 0;
if (is_dir(subdir)) {
......@@ -773,7 +773,7 @@ int boinc_make_dirs(const char* dirpath, const char* filepath) {
p = strchr(q, '/');
if (!p) break;
*p = 0;
snprintf(newpath, sizeof(newpath), "%s/%s", oldpath, q);
snprintf(newpath, sizeof(newpath), "%.*s/%.*s", DIR_LEN, oldpath, FILE_LEN, q);
newpath[sizeof(newpath)-1] = 0;
retval = boinc_mkdir(newpath);
if (retval) return retval;
......
......@@ -36,6 +36,11 @@
#define MAXPATHLEN 4096
#endif
// use the following in format codes in snprintf
//
#define DIR_LEN 2048
#define FILE_LEN 256
#define FILE_RETRY_INTERVAL 5
// On Windows, retry for this period of time, since some other program
// (virus scan, defrag, index) may have the file open.
......
......@@ -269,7 +269,7 @@ int RPC_CLIENT::init_unix_domain() {
int RPC_CLIENT::authorize(const char* passwd) {
bool found=false, authorized;
int retval, n;
char nonce[256], nonce_hash[256], buf[256];
char nonce[256], nonce_hash[256], buf[1024];
RPC rpc(this);
XML_PARSER xp(&rpc.fin);
......
......@@ -88,7 +88,7 @@ int MFILE::vprintf(const char* format, va_list ap) {
);
exit(1);
}
strncpy(buf+len, buf2, n);
strncpy(buf+len, buf2, n+1);
len += n;
buf[len] = 0;
return k;
......@@ -142,7 +142,7 @@ int MFILE::puts(const char* p) {
);
exit(1);
}
strncpy(buf+len, p, n);
strncpy(buf+len, p, n+1);
len += n;
buf[len] = 0;
return n;
......
......@@ -265,14 +265,14 @@ int OPENCL_DEVICE_PROP::get_opencl_driver_revision() {
}
void OPENCL_DEVICE_PROP::description(char* buf, int buflen, const char* type) {
char s1[256], s2[256];
char s1[256], s2[1024];
int n;
// openCL_device_version may have a trailing space
strlcpy(s1, opencl_device_version, sizeof(s1));
n = (int)strlen(s1) - 1;
if ((n > 0) && (s1[n] == ' ')) s1[n] = '\0';
snprintf(s2, sizeof(s2),
"%s (driver version %s, device version %s, %.0fMB, %.0fMB available, %.0f GFLOPS peak)",
"%.64s (driver version %.64s, device version %.64s, %.0fMB, %.0fMB available, %.0f GFLOPS peak)",
name, opencl_driver_version,
s1, global_mem_size/MEGA,
opencl_available_ram/MEGA, peak_flops/1.e9
......
......@@ -915,7 +915,7 @@ int XML_PARSER::copy_element(string& out) {
out = "<";
out += parsed_tag;
out += ">";
snprintf(end_tag, sizeof(end_tag), "</%s>", parsed_tag);
snprintf(end_tag, sizeof(end_tag), "</%.256s>", parsed_tag);
int retval = element_contents(end_tag, buf, sizeof(buf));
if (retval) return retval;
out += buf;
......
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