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);
|
exit(1);
|
||||||
}
|
}
|
||||||
// let client know what fd has been allocated
|
// 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++) {
|
for (i = 0; i < 3; i++) {
|
||||||
local_fd[i] = connect_unix_socket();
|
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")) {
|
if (i != 2 || getenv("PASS_LOCAL_STDERR")) {
|
||||||
char *env;
|
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);
|
putenv(env);
|
||||||
dup2(local_fd[i], i);
|
dup2(local_fd[i], i);
|
||||||
close(local_fd[i]);
|
close(local_fd[i]);
|
||||||
@ -98,7 +104,12 @@ int main(int argc, char **argv)
|
|||||||
sizeof(params.process_fds.ident), "%d %d %d",
|
sizeof(params.process_fds.ident), "%d %d %d",
|
||||||
remote_fd[0], remote_fd[1], remote_fd[2]);
|
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);
|
close(trigger_fd);
|
||||||
|
|
||||||
abs_exec_path = strdup(argv[3]);
|
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 *dialog_msg;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
(void) vsnprintf(buf, sizeof(buf), fmt, args);
|
(void) vsnprintf(buf, sizeof(buf), fmt, args);
|
||||||
asprintf(&dialog_msg, "%s: %s: %s (error type: %s)",
|
if (asprintf(&dialog_msg, "%s: %s: %s (error type: %s)",
|
||||||
program_invocation_short_name, type, buf, strerror(errno));
|
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);
|
fprintf(stderr, "%s\n", dialog_msg);
|
||||||
switch (fork()) {
|
switch (fork()) {
|
||||||
case -1:
|
case -1:
|
||||||
|
@ -5,8 +5,10 @@ char *get_abs_path(const char *cwd, const char *pathname)
|
|||||||
char *ret;
|
char *ret;
|
||||||
if (pathname[0] == '/')
|
if (pathname[0] == '/')
|
||||||
return strdup(pathname);
|
return strdup(pathname);
|
||||||
asprintf(&ret, "%s/%s", cwd, pathname);
|
if (asprintf(&ret, "%s/%s", cwd, pathname) < 0)
|
||||||
return ret;
|
return NULL;
|
||||||
|
else
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int do_fs_walk(const char *file)
|
int do_fs_walk(const char *file)
|
||||||
@ -28,9 +30,13 @@ int do_fs_walk(const char *file)
|
|||||||
char *fname = ent->d_name;
|
char *fname = ent->d_name;
|
||||||
if (!strcmp(fname, ".") || !strcmp(fname, ".."))
|
if (!strcmp(fname, ".") || !strcmp(fname, ".."))
|
||||||
continue;
|
continue;
|
||||||
asprintf(&newfile, "%s/%s", file, fname);
|
if (asprintf(&newfile, "%s/%s", file, fname) >= 0) {
|
||||||
do_fs_walk(newfile);
|
do_fs_walk(newfile);
|
||||||
free(newfile);
|
free(newfile);
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "asprintf failed\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
// directory metadata is resent; this makes the code simple,
|
// 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");
|
("Internal error: nonabsolute filenames not allowed");
|
||||||
*sep = 0;
|
*sep = 0;
|
||||||
} while (sep[1] == 0);
|
} while (sep[1] == 0);
|
||||||
if (entry[0] == 0)
|
if (entry[0] == 0) {
|
||||||
chdir("/");
|
if (chdir("/") < 0) {
|
||||||
else if (chdir(entry))
|
gui_fatal("Internal error: chdir(\"/\") failed?!");
|
||||||
|
}
|
||||||
|
} else if (chdir(entry))
|
||||||
gui_fatal("chdir to %s", entry);
|
gui_fatal("chdir to %s", entry);
|
||||||
do_fs_walk(sep + 1);
|
do_fs_walk(sep + 1);
|
||||||
free(entry);
|
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 *du_size_env = getenv("FILECOPY_TOTAL_SIZE");
|
||||||
const char *progress_type_env = getenv("PROGRESS_TYPE");
|
const char *progress_type_env = getenv("PROGRESS_TYPE");
|
||||||
const char *saved_stdout_env = getenv("SAVED_FD_1");
|
const char *saved_stdout_env = getenv("SAVED_FD_1");
|
||||||
|
int ignore;
|
||||||
if (!progress_type_env)
|
if (!progress_type_env)
|
||||||
return;
|
return;
|
||||||
if (!strcmp(progress_type_env, "console") && du_size_env) {
|
if (!strcmp(progress_type_env, "console") && du_size_env) {
|
||||||
char msg[256];
|
char msg[256];
|
||||||
snprintf(msg, sizeof(msg), "sent %lld/%lld KB\r",
|
snprintf(msg, sizeof(msg), "sent %lld/%lld KB\r",
|
||||||
total / 1024, strtoull(du_size_env, NULL, 0));
|
total / 1024, strtoull(du_size_env, NULL, 0));
|
||||||
write(2, msg, strlen(msg));
|
ignore = write(2, msg, strlen(msg));
|
||||||
if (flag == PROGRESS_FLAG_DONE)
|
if (flag == PROGRESS_FLAG_DONE)
|
||||||
write(2, "\n", 1);
|
ignore = write(2, "\n", 1);
|
||||||
}
|
}
|
||||||
if (!strcmp(progress_type_env, "gui") && saved_stdout_env) {
|
if (!strcmp(progress_type_env, "gui") && saved_stdout_env) {
|
||||||
char msg[256];
|
char msg[256];
|
||||||
snprintf(msg, sizeof(msg), "%lld\n", total);
|
snprintf(msg, sizeof(msg), "%lld\n", total);
|
||||||
write(strtoul(saved_stdout_env, NULL, 0), msg,
|
ignore = write(strtoul(saved_stdout_env, NULL, 0), msg,
|
||||||
strlen(msg));
|
strlen(msg));
|
||||||
|
}
|
||||||
|
if (ignore < 0) {
|
||||||
|
/* silence gcc warning */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,21 +51,21 @@ void recv_file_nowrite(const char *fname)
|
|||||||
{
|
{
|
||||||
char *tempfile;
|
char *tempfile;
|
||||||
char *errmsg;
|
char *errmsg;
|
||||||
int tmpfd;
|
int tmpfd = -1;
|
||||||
|
|
||||||
asprintf(&tempfile, "/tmp/file_edited_in_dvm.XXXXXX");
|
if (asprintf(&tempfile, "/tmp/file_edited_in_dvm.XXXXXX") != -1)
|
||||||
tmpfd = mkstemp(tempfile);
|
tmpfd = mkstemp(tempfile);
|
||||||
if (tmpfd < 0)
|
if (tmpfd < 0)
|
||||||
gui_fatal("unable to create any temporary file, aborting");
|
gui_fatal("unable to create any temporary file, aborting");
|
||||||
if (!copy_and_return_nonemptiness(tmpfd)) {
|
if (!copy_and_return_nonemptiness(tmpfd)) {
|
||||||
unlink(tempfile);
|
unlink(tempfile);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
asprintf(&errmsg,
|
if (asprintf(&errmsg,
|
||||||
"The file %s has been edited in Disposable VM and the modified content has been received, "
|
"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 "
|
"but this file is in nonwritable directory and thus cannot be modified safely. The edited file has been "
|
||||||
"saved to %s", fname, tempfile);
|
"saved to %s", fname, tempfile) != -1)
|
||||||
gui_nonfatal(errmsg);
|
gui_nonfatal(errmsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void actually_recv_file(const char *fname, const char *tempfile, int tmpfd)
|
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)
|
void recv_file(const char *fname)
|
||||||
{
|
{
|
||||||
int tmpfd;
|
int tmpfd = -1;
|
||||||
char *tempfile;
|
char *tempfile;
|
||||||
asprintf(&tempfile, "%s.XXXXXX", fname);
|
if (asprintf(&tempfile, "%s.XXXXXX", fname) != -1) {
|
||||||
tmpfd = mkstemp(tempfile);
|
tmpfd = mkstemp(tempfile);
|
||||||
|
}
|
||||||
if (tmpfd < 0)
|
if (tmpfd < 0)
|
||||||
recv_file_nowrite(fname);
|
recv_file_nowrite(fname);
|
||||||
else
|
else
|
||||||
|
@ -956,7 +956,7 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char *entry;
|
char *entry;
|
||||||
int fd;
|
int fd = -1;
|
||||||
int use_stdin = 1;
|
int use_stdin = 1;
|
||||||
struct filters filters;
|
struct filters filters;
|
||||||
|
|
||||||
@ -1013,6 +1013,10 @@ int main(int argc, char **argv)
|
|||||||
set_block(0);
|
set_block(0);
|
||||||
fd = 0;
|
fd = 0;
|
||||||
}
|
}
|
||||||
|
if (fd < 0) {
|
||||||
|
fprintf(stderr, "No input file provided\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
tar_file_processor(fd, &filters);
|
tar_file_processor(fd, &filters);
|
||||||
|
|
||||||
|
|
||||||
|
@ -214,7 +214,7 @@ main()
|
|||||||
snprintf(cmd, sizeof(cmd),
|
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);
|
"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
|
#endif
|
||||||
system(cmd);
|
status = system(cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user