Fix compiler warnings.
Mostly harmless cases of warn_unused_result.
This commit is contained in:
parent
0fad94a21f
commit
8018b9d3ee
@ -533,7 +533,9 @@ void handle_new_passfd()
|
||||
exit(1);
|
||||
}
|
||||
// let client know what fd has been allocated
|
||||
write(fd, &fd, sizeof(fd));
|
||||
if (write(fd, &fd, sizeof(fd)) != sizeof(fd)) {
|
||||
perror("write to client");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -80,10 +80,16 @@ int main(int argc, char **argv)
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
local_fd[i] = connect_unix_socket();
|
||||
read(local_fd[i], &remote_fd[i], sizeof(remote_fd[i]));
|
||||
if (read(local_fd[i], &remote_fd[i], sizeof(remote_fd[i])) != sizeof(remote_fd[i])) {
|
||||
perror("read client fd");
|
||||
exit(1);
|
||||
}
|
||||
if (i != 2 || getenv("PASS_LOCAL_STDERR")) {
|
||||
char *env;
|
||||
asprintf(&env, "SAVED_FD_%d=%d", i, dup(i));
|
||||
if (asprintf(&env, "SAVED_FD_%d=%d", i, dup(i)) < 0) {
|
||||
perror("prepare SAVED_FD_");
|
||||
exit(1);
|
||||
}
|
||||
putenv(env);
|
||||
dup2(local_fd[i], i);
|
||||
close(local_fd[i]);
|
||||
@ -98,7 +104,12 @@ int main(int argc, char **argv)
|
||||
sizeof(params.process_fds.ident), "%d %d %d",
|
||||
remote_fd[0], remote_fd[1], remote_fd[2]);
|
||||
|
||||
write(trigger_fd, ¶ms, sizeof(params));
|
||||
if (write(trigger_fd, ¶ms, sizeof(params)) < 0) {
|
||||
if (!getenv("PASS_LOCAL_STDERR"))
|
||||
perror("write to agent");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
close(trigger_fd);
|
||||
|
||||
abs_exec_path = strdup(argv[3]);
|
||||
|
@ -18,8 +18,11 @@ static void produce_message(const char * type, const char *fmt, va_list args)
|
||||
char *dialog_msg;
|
||||
char buf[1024];
|
||||
(void) vsnprintf(buf, sizeof(buf), fmt, args);
|
||||
asprintf(&dialog_msg, "%s: %s: %s (error type: %s)",
|
||||
program_invocation_short_name, type, buf, strerror(errno));
|
||||
if (asprintf(&dialog_msg, "%s: %s: %s (error type: %s)",
|
||||
program_invocation_short_name, type, buf, strerror(errno)) < 0) {
|
||||
fprintf(stderr, "Failed to allocate memory for error message :(\n");
|
||||
return;
|
||||
}
|
||||
fprintf(stderr, "%s\n", dialog_msg);
|
||||
switch (fork()) {
|
||||
case -1:
|
||||
|
@ -5,8 +5,10 @@ char *get_abs_path(const char *cwd, const char *pathname)
|
||||
char *ret;
|
||||
if (pathname[0] == '/')
|
||||
return strdup(pathname);
|
||||
asprintf(&ret, "%s/%s", cwd, pathname);
|
||||
return ret;
|
||||
if (asprintf(&ret, "%s/%s", cwd, pathname) < 0)
|
||||
return NULL;
|
||||
else
|
||||
return ret;
|
||||
}
|
||||
|
||||
int do_fs_walk(const char *file)
|
||||
@ -28,9 +30,13 @@ int do_fs_walk(const char *file)
|
||||
char *fname = ent->d_name;
|
||||
if (!strcmp(fname, ".") || !strcmp(fname, ".."))
|
||||
continue;
|
||||
asprintf(&newfile, "%s/%s", file, fname);
|
||||
do_fs_walk(newfile);
|
||||
free(newfile);
|
||||
if (asprintf(&newfile, "%s/%s", file, fname) >= 0) {
|
||||
do_fs_walk(newfile);
|
||||
free(newfile);
|
||||
} else {
|
||||
fprintf(stderr, "asprintf failed\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
closedir(dir);
|
||||
// directory metadata is resent; this makes the code simple,
|
||||
@ -68,9 +74,11 @@ int main(int argc, char **argv)
|
||||
("Internal error: nonabsolute filenames not allowed");
|
||||
*sep = 0;
|
||||
} while (sep[1] == 0);
|
||||
if (entry[0] == 0)
|
||||
chdir("/");
|
||||
else if (chdir(entry))
|
||||
if (entry[0] == 0) {
|
||||
if (chdir("/") < 0) {
|
||||
gui_fatal("Internal error: chdir(\"/\") failed?!");
|
||||
}
|
||||
} else if (chdir(entry))
|
||||
gui_fatal("chdir to %s", entry);
|
||||
do_fs_walk(sep + 1);
|
||||
free(entry);
|
||||
|
@ -27,21 +27,25 @@ void do_notify_progress(long long total, int flag)
|
||||
const char *du_size_env = getenv("FILECOPY_TOTAL_SIZE");
|
||||
const char *progress_type_env = getenv("PROGRESS_TYPE");
|
||||
const char *saved_stdout_env = getenv("SAVED_FD_1");
|
||||
int ignore;
|
||||
if (!progress_type_env)
|
||||
return;
|
||||
if (!strcmp(progress_type_env, "console") && du_size_env) {
|
||||
char msg[256];
|
||||
snprintf(msg, sizeof(msg), "sent %lld/%lld KB\r",
|
||||
total / 1024, strtoull(du_size_env, NULL, 0));
|
||||
write(2, msg, strlen(msg));
|
||||
ignore = write(2, msg, strlen(msg));
|
||||
if (flag == PROGRESS_FLAG_DONE)
|
||||
write(2, "\n", 1);
|
||||
ignore = write(2, "\n", 1);
|
||||
}
|
||||
if (!strcmp(progress_type_env, "gui") && saved_stdout_env) {
|
||||
char msg[256];
|
||||
snprintf(msg, sizeof(msg), "%lld\n", total);
|
||||
write(strtoul(saved_stdout_env, NULL, 0), msg,
|
||||
strlen(msg));
|
||||
ignore = write(strtoul(saved_stdout_env, NULL, 0), msg,
|
||||
strlen(msg));
|
||||
}
|
||||
if (ignore < 0) {
|
||||
/* silence gcc warning */
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,21 +51,21 @@ void recv_file_nowrite(const char *fname)
|
||||
{
|
||||
char *tempfile;
|
||||
char *errmsg;
|
||||
int tmpfd;
|
||||
int tmpfd = -1;
|
||||
|
||||
asprintf(&tempfile, "/tmp/file_edited_in_dvm.XXXXXX");
|
||||
tmpfd = mkstemp(tempfile);
|
||||
if (asprintf(&tempfile, "/tmp/file_edited_in_dvm.XXXXXX") != -1)
|
||||
tmpfd = mkstemp(tempfile);
|
||||
if (tmpfd < 0)
|
||||
gui_fatal("unable to create any temporary file, aborting");
|
||||
if (!copy_and_return_nonemptiness(tmpfd)) {
|
||||
unlink(tempfile);
|
||||
return;
|
||||
}
|
||||
asprintf(&errmsg,
|
||||
if (asprintf(&errmsg,
|
||||
"The file %s has been edited in Disposable VM and the modified content has been received, "
|
||||
"but this file is in nonwritable directory and thus cannot be modified safely. The edited file has been "
|
||||
"saved to %s", fname, tempfile);
|
||||
gui_nonfatal(errmsg);
|
||||
"saved to %s", fname, tempfile) != -1)
|
||||
gui_nonfatal(errmsg);
|
||||
}
|
||||
|
||||
void actually_recv_file(const char *fname, const char *tempfile, int tmpfd)
|
||||
@ -80,10 +80,11 @@ void actually_recv_file(const char *fname, const char *tempfile, int tmpfd)
|
||||
|
||||
void recv_file(const char *fname)
|
||||
{
|
||||
int tmpfd;
|
||||
int tmpfd = -1;
|
||||
char *tempfile;
|
||||
asprintf(&tempfile, "%s.XXXXXX", fname);
|
||||
tmpfd = mkstemp(tempfile);
|
||||
if (asprintf(&tempfile, "%s.XXXXXX", fname) != -1) {
|
||||
tmpfd = mkstemp(tempfile);
|
||||
}
|
||||
if (tmpfd < 0)
|
||||
recv_file_nowrite(fname);
|
||||
else
|
||||
|
@ -956,7 +956,7 @@ int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
char *entry;
|
||||
int fd;
|
||||
int fd = -1;
|
||||
int use_stdin = 1;
|
||||
struct filters filters;
|
||||
|
||||
@ -1013,6 +1013,10 @@ int main(int argc, char **argv)
|
||||
set_block(0);
|
||||
fd = 0;
|
||||
}
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "No input file provided\n");
|
||||
exit(1);
|
||||
}
|
||||
tar_file_processor(fd, &filters);
|
||||
|
||||
|
||||
|
@ -214,7 +214,7 @@ main()
|
||||
snprintf(cmd, sizeof(cmd),
|
||||
"HOME=/home/user DISPLAY=:0 /usr/bin/zenity --error --text 'Unable to handle mimetype of the requested file (exit status: %d)!' > /tmp/kdialog.log 2>&1 </dev/null", status);
|
||||
#endif
|
||||
system(cmd);
|
||||
status = system(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user