Various: Fix some compile warnings; from Gianfranco

This commit is contained in:
David Anderson 2013-07-09 10:34:32 -07:00
parent 0feedfe811
commit a8485f3d3f
11 changed files with 52 additions and 27 deletions

View File

@ -191,8 +191,11 @@ static void boinc_glut_init(int *argc, char** argv) {
FILE *f = boinc_fopen("gfx_info", "r");
if (f) {
// ToDo: change this to XML parsing
fscanf(f, "%d %d %d %d\n", &xpos, &ypos, &width, &height);
int n = fscanf(f, "%d %d %d %d\n", &xpos, &ypos, &width, &height);
fclose(f);
if (n != 4) {
fprintf(stderr, "failed to parse gfx_info");
}
}
glutInit (argc, argv);

View File

@ -595,8 +595,8 @@ bool ACTIVE_TASK::temporary_exit_file_present(double& x, char* buf) {
} else {
x = y;
}
fgets(buf, 256, f); // read the \n
fgets(buf, 256, f);
(void) fgets(buf, 256, f); // read the \n
(void) fgets(buf, 256, f);
strip_whitespace(buf);
fclose(f);
return true;
@ -1446,7 +1446,7 @@ void ACTIVE_TASK::read_task_state_file() {
FILE* f = fopen(path, "r");
if (!f) return;
buf[0] = 0;
fread(buf, 1, 4096, f);
(void) fread(buf, 1, 4096, f);
fclose(f);
buf[4095] = 0;
double x;

View File

@ -858,7 +858,10 @@ int ACTIVE_TASK::start(bool test) {
char* argv[100];
char current_dir[1024];
getcwd(current_dir, sizeof(current_dir));
if (getcwd(current_dir, sizeof(current_dir)) == NULL) {
sprintf(buf, "Can't get cwd");
goto error;
}
sprintf(cmdline, "%s %s",
wup->command_line.c_str(), app_version->cmdline
@ -1005,7 +1008,7 @@ int ACTIVE_TASK::start(bool test) {
// hook up stderr to a specially-named file
//
freopen(STDERR_FILE, "a", stderr);
(void) freopen(STDERR_FILE, "a", stderr);
if (!config.no_priority_change) {
#if HAVE_SETPRIORITY

View File

@ -142,7 +142,7 @@ void CLIENT_STATE::detect_platforms() {
strlcat(cmdline," -m",256);
if ((f=popen(cmdline,"r"))) {
while (!std::feof(f)) {
fgets(cmdline,256,f);
if (!fgets(cmdline,256,f)) break;
if (strstr(cmdline,"x86_64")) support64=1;
}
pclose(f);
@ -191,7 +191,7 @@ void CLIENT_STATE::detect_platforms() {
f = popen(cmdline, "r");
if (f) {
while (!std::feof(f)) {
fgets(cmdline,256,f);
if (!fgets(cmdline,256,f)) break;
// If the library is 32-bit ELF, then we're
// golden.
if (strstr(cmdline, "ELF") && strstr(cmdline, "32-bit")) support32=1;

0
client/gpu_detect.cpp Executable file → Normal file
View File

View File

@ -1244,11 +1244,12 @@ int HOST_INFO::get_virtualbox_version() {
#endif
fd = popen(cmd, "r");
if (fd) {
fgets(virtualbox_version, sizeof(virtualbox_version), fd);
newlinePtr = strchr(virtualbox_version, '\n');
if (newlinePtr) *newlinePtr = '\0';
newlinePtr = strchr(virtualbox_version, '\r');
if (newlinePtr) *newlinePtr = '\0';
if (fgets(virtualbox_version, sizeof(virtualbox_version), fd)) {
newlinePtr = strchr(virtualbox_version, '\n');
if (newlinePtr) *newlinePtr = '\0';
newlinePtr = strchr(virtualbox_version, '\r');
if (newlinePtr) *newlinePtr = '\0';
}
pclose(fd);
}
}

View File

@ -519,7 +519,12 @@ int read_config_file(bool init, const char* fname) {
#ifdef _WIN32
_chdir(config.data_dir);
#else
chdir(config.data_dir);
if (chdir(config.data_dir)) {
msg_printf(NULL, MSG_INFO,
"Couldn't change to config.data_dir"
);
return ERR_OPENDIR;
}
#endif
}
} else {

View File

@ -67,19 +67,25 @@ int main(int /*argc*/, char** argv) {
pw = getpwuid(getuid());
if (pw) strcpy(user_name, pw->pw_name);
grp = getgrgid(getgid());
if (grp) strcpy(group_name, grp->gr_gid);
if (grp) {
strcpy(group_name, grp->gr_gid);
}
#endif
// We are running setuid root, so setgid() sets real group ID,
// effective group ID and saved set_group-ID for this process
grp = getgrnam(group_name);
if (grp) setgid(grp->gr_gid);
if (grp) {
(void) setgid(grp->gr_gid);
}
// We are running setuid root, so setuid() sets real user ID,
// effective user ID and saved set_user-ID for this process
pw = getpwnam(user_name);
if (pw) setuid(pw->pw_uid);
if (pw) {
(void) setuid(pw->pw_uid);
}
// For unknown reasons, the LD_LIBRARY_PATH and DYLD_LIBRARY_PATH
// environment variables are not passed in to switcher, though all

View File

@ -208,14 +208,17 @@ int scan_key_hex(FILE* f, KEY* key, int size) {
}
if (j != len) return ERR_NULL;
#else
fscanf(f, "%d", &num_bits);
int fs = fscanf(f, "%d", &num_bits);
if (fs != 1) return ERR_NULL;
key->bits = num_bits;
len = size - sizeof(key->bits);
for (i=0; i<len; i++) {
fscanf(f, "%2x", &n);
fs = fscanf(f, "%2x", &n);
if (fs != 1) return ERR_NULL;
key->data[i] = n;
}
fscanf(f, ".");
fs = fscanf(f, ".");
if (fs == EOF) return ERR_NULL;
#endif
return 0;
}

View File

@ -608,7 +608,7 @@ void boinc_catch_signal(int signal) {
size = backtrace (array, 64);
// Anything that calls malloc here (i.e *printf()) will probably fail
// so we'll do it the hard way.
write(fileno(stderr),"Stack trace (",strlen("Stack trace ("));
(void) write(fileno(stderr),"Stack trace (",strlen("Stack trace ("));
char mbuf[10];
char *p=mbuf+9;
int i=size;
@ -617,10 +617,10 @@ void boinc_catch_signal(int signal) {
*(p--)=i%10+'0';
i/=10;
}
write(fileno(stderr),p+1,strlen(p+1));
write(fileno(stderr)," frames):",strlen(" frames):"));
(void) write(fileno(stderr),p+1,strlen(p+1));
(void) write(fileno(stderr)," frames):",strlen(" frames):"));
mbuf[0]=10;
write(fileno(stderr),mbuf,1);
(void) write(fileno(stderr),mbuf,1);
backtrace_symbols_fd(array, size, fileno(stderr));
#endif

View File

@ -47,9 +47,10 @@
#include <procfs.h> // definitions for solaris /proc structs
#endif
#include "error_numbers.h"
#include "filesys.h"
#include "str_util.h"
#include "str_replace.h"
#include "filesys.h"
#include "procinfo.h"
@ -219,8 +220,11 @@ int procinfo_setup(PROC_MAP& pm) {
sprintf(pidpath, "/proc/%s/stat", piddir->d_name);
fd = fopen(pidpath, "r");
if (fd) {
fgets(buf, sizeof(buf), fd);
retval = ps.parse(buf);
if (fgets(buf, sizeof(buf), fd) == NULL) {
retval = ERR_NULL;
} else {
retval = ps.parse(buf);
}
fclose(fd);
if (retval) {