From 3d1a4ecaf7be21f0d31f5aa17cd36a43f4c2d492 Mon Sep 17 00:00:00 2001 From: Slava Zanko Date: Wed, 4 Jul 2012 11:20:52 +0300 Subject: [PATCH] Try fix of compile warnings about assigned but unused variables ...as returned values of functions declared with attribute warn_unused_result [-Wunused-result]. Signed-off-by: Slava Zanko --- lib/util.c | 5 ++--- lib/vfs/direntry.c | 6 ++---- src/background.c | 32 +++++++++++++++----------------- src/clipboard.c | 6 ++---- src/cons.handler.c | 18 ++++++++---------- src/consaver/cons.saver.c | 3 +-- src/diffviewer/ydiff.c | 5 ++--- src/filemanager/find.c | 3 +-- src/filemanager/panel.c | 2 +- src/filemanager/panelize.c | 3 +-- src/filemanager/tree.c | 3 +-- src/main.c | 6 ++---- src/subshell.c | 5 +---- src/vfs/fish/fish.c | 11 +++++------ src/vfs/ftpfs/ftpfs.c | 3 +-- 15 files changed, 45 insertions(+), 66 deletions(-) diff --git a/lib/util.c b/lib/util.c index 490bdfcac..327f52a8a 100644 --- a/lib/util.c +++ b/lib/util.c @@ -208,9 +208,8 @@ mc_util_write_backup_content (const char *from_file_name, const char *to_file_na if (fwrite ((const void *) contents, 1, length, backup_fd) != length) ret1 = FALSE; { - int ret2; - ret2 = fflush (backup_fd); - ret2 = fclose (backup_fd); + (void) fflush (backup_fd); + (void) fclose (backup_fd); } g_free (contents); return ret1; diff --git a/lib/vfs/direntry.c b/lib/vfs/direntry.c index 016f96d45..f9cdbbcb5 100644 --- a/lib/vfs/direntry.c +++ b/lib/vfs/direntry.c @@ -1523,10 +1523,8 @@ vfs_s_get_line (struct vfs_class *me, int sock, char *buf, int buf_len, char ter { if (logfile) { - size_t ret1; - int ret2; - ret1 = fwrite (&c, 1, 1, logfile); - ret2 = fflush (logfile); + (void) fwrite (&c, 1, 1, logfile); + (void) fflush (logfile); } if (c == '\n') return 1; diff --git a/src/background.c b/src/background.c index a68fe8637..ce23fb8f3 100644 --- a/src/background.c +++ b/src/background.c @@ -200,7 +200,7 @@ background_attention (int fd, void *closure) /* void *routine; */ int argc, i, result, status; char *data[MAXCALLARGS]; - ssize_t bytes, ret; + ssize_t bytes; struct TaskList *p; int to_child_fd = -1; enum ReturnType type; @@ -330,9 +330,9 @@ background_attention (int fd, void *closure) } /* Send the result code and the value for shared variables */ - ret = write (to_child_fd, &result, sizeof (int)); + (void) write (to_child_fd, &result, sizeof (int)); if (have_ctx && to_child_fd != -1) - ret = write (to_child_fd, ctx, sizeof (FileOpContext)); + (void) write (to_child_fd, ctx, sizeof (FileOpContext)); } else if (type == Return_String) { @@ -365,15 +365,15 @@ background_attention (int fd, void *closure) if (resstr) { len = strlen (resstr); - ret = write (to_child_fd, &len, sizeof (len)); + (void) write (to_child_fd, &len, sizeof (len)); if (len != 0) - ret = write (to_child_fd, resstr, len); + (void) write (to_child_fd, resstr, len); g_free (resstr); } else { len = 0; - ret = write (to_child_fd, &len, sizeof (len)); + (void) write (to_child_fd, &len, sizeof (len)); } } for (i = 0; i < argc; i++) @@ -398,17 +398,16 @@ static void parent_call_header (void *routine, int argc, enum ReturnType type, FileOpContext * ctx) { int have_ctx; - ssize_t ret; have_ctx = (ctx != NULL); - ret = write (parent_fd, &routine, sizeof (routine)); - ret = write (parent_fd, &argc, sizeof (int)); - ret = write (parent_fd, &type, sizeof (type)); - ret = write (parent_fd, &have_ctx, sizeof (have_ctx)); + (void) write (parent_fd, &routine, sizeof (routine)); + (void) write (parent_fd, &argc, sizeof (int)); + (void) write (parent_fd, &type, sizeof (type)); + (void) write (parent_fd, &have_ctx, sizeof (have_ctx)); if (have_ctx) - ret = write (parent_fd, ctx, sizeof (FileOpContext)); + (void) write (parent_fd, ctx, sizeof (FileOpContext)); } /* --------------------------------------------------------------------------------------------- */ @@ -417,7 +416,6 @@ static int parent_va_call (void *routine, gpointer data, int argc, va_list ap) { int i; - ssize_t ret; struct FileOpContext *ctx = (struct FileOpContext *) data; parent_call_header (routine, argc, Return_Integer, ctx); @@ -428,13 +426,13 @@ parent_va_call (void *routine, gpointer data, int argc, va_list ap) len = va_arg (ap, int); value = va_arg (ap, void *); - ret = write (parent_fd, &len, sizeof (int)); - ret = write (parent_fd, value, len); + (void) write (parent_fd, &len, sizeof (int)); + (void) write (parent_fd, value, len); } - ret = read (from_parent_fd, &i, sizeof (int)); + (void) read (from_parent_fd, &i, sizeof (int)); if (ctx) - ret = read (from_parent_fd, ctx, sizeof (FileOpContext)); + (void) read (from_parent_fd, ctx, sizeof (FileOpContext)); return i; } diff --git a/src/clipboard.c b/src/clipboard.c index 5b04600e8..cb9daa61e 100644 --- a/src/clipboard.c +++ b/src/clipboard.c @@ -66,7 +66,6 @@ clipboard_file_to_ext_clip (const gchar * event_group_name, const gchar * event_ gpointer init_data, gpointer data) { char *tmp, *cmd; - int res = 0; const char *d = getenv ("DISPLAY"); (void) event_group_name; @@ -81,7 +80,7 @@ clipboard_file_to_ext_clip (const gchar * event_group_name, const gchar * event_ cmd = g_strconcat (clipboard_store_path, " ", tmp, " 2>/dev/null", (char *) NULL); if (cmd != NULL) - res = my_system (EXECUTE_AS_SHELL, shell, cmd); + (void) my_system (EXECUTE_AS_SHELL, shell, cmd); g_free (cmd); g_free (tmp); @@ -127,7 +126,6 @@ clipboard_text_to_file (const gchar * event_group_name, const gchar * event_name { int file; vfs_path_t *fname_vpath = NULL; - ssize_t ret; size_t str_len; const char *text = (const char *) data; @@ -147,7 +145,7 @@ clipboard_text_to_file (const gchar * event_group_name, const gchar * event_name return TRUE; str_len = strlen (text); - ret = mc_write (file, (char *) text, str_len); + (void) mc_write (file, (char *) text, str_len); mc_close (file); return TRUE; } diff --git a/src/cons.handler.c b/src/cons.handler.c index c2a523ca6..31b24324a 100644 --- a/src/cons.handler.c +++ b/src/cons.handler.c @@ -90,7 +90,6 @@ show_console_contents_linux (int starty, unsigned char begin_line, unsigned char unsigned char message = 0; unsigned short bytes = 0; int i; - ssize_t ret; /* Is tty console? */ if (mc_global.tty.console_flag == '\0') @@ -105,29 +104,29 @@ show_console_contents_linux (int starty, unsigned char begin_line, unsigned char /* Send command to the console handler */ message = CONSOLE_CONTENTS; - ret = write (pipefd1[1], &message, 1); + (void) write (pipefd1[1], &message, 1); /* Check for outdated cons.saver */ - ret = read (pipefd2[0], &message, 1); + (void) read (pipefd2[0], &message, 1); if (message != CONSOLE_CONTENTS) return; /* Send the range of lines that we want */ - ret = write (pipefd1[1], &begin_line, 1); - ret = write (pipefd1[1], &end_line, 1); + (void) write (pipefd1[1], &begin_line, 1); + (void) write (pipefd1[1], &end_line, 1); /* Read the corresponding number of bytes */ - ret = read (pipefd2[0], &bytes, 2); + (void) read (pipefd2[0], &bytes, 2); /* Read the bytes and output them */ for (i = 0; i < bytes; i++) { if ((i % COLS) == 0) tty_gotoyx (starty + (i / COLS), 0); - ret = read (pipefd2[0], &message, 1); + (void) read (pipefd2[0], &message, 1); tty_print_char (message); } /* Read the value of the mc_global.tty.console_flag */ - ret = read (pipefd2[0], &message, 1); + (void) read (pipefd2[0], &message, 1); } /* --------------------------------------------------------------------------------------------- */ @@ -240,10 +239,9 @@ handle_console_linux (console_action_t action) if (action == CONSOLE_DONE || mc_global.tty.console_flag == '\0') { /* We are done -> Let's clean up */ - pid_t ret; close (pipefd1[1]); close (pipefd2[0]); - ret = waitpid (cons_saver_pid, &status, 0); + (void) waitpid (cons_saver_pid, &status, 0); mc_global.tty.console_flag = '\0'; } break; diff --git a/src/consaver/cons.saver.c b/src/consaver/cons.saver.c index dea413b1f..ba88445ae 100644 --- a/src/consaver/cons.saver.c +++ b/src/consaver/cons.saver.c @@ -143,8 +143,7 @@ send_contents (char *buffer, unsigned int columns, unsigned int rows) static void __attribute__ ((noreturn)) die (void) { unsigned char zero = 0; - ssize_t ret; - ret = write (1, &zero, 1); + (void) write (1, &zero, 1); exit (3); } diff --git a/src/diffviewer/ydiff.c b/src/diffviewer/ydiff.c index b913b8ea4..95ac5d46a 100644 --- a/src/diffviewer/ydiff.c +++ b/src/diffviewer/ydiff.c @@ -2188,7 +2188,6 @@ static void do_merge_hunk (WDiff * dview) { int from1, to1, from2, to2; - int res; int hunk; hunk = get_current_hunk (dview, &from1, &to1, &from2, &to2); @@ -2235,7 +2234,7 @@ do_merge_hunk (WDiff * dview) } fflush (merge_file); fclose (merge_file); - res = rewrite_backup_content (merge_file_name_vpath, dview->file[0]); + rewrite_backup_content (merge_file_name_vpath, dview->file[0]); mc_unlink (merge_file_name_vpath); vfs_path_free (merge_file_name_vpath); } @@ -2975,7 +2974,7 @@ dview_ok_to_exit (WDiff * dview) break; case 1: /* No */ if (mc_util_restore_from_backup_if_possible (dview->file[0], "~~~")) - res = mc_util_unlink_backup_if_possible (dview->file[0], "~~~"); + mc_util_unlink_backup_if_possible (dview->file[0], "~~~"); /* fall through */ default: res = TRUE; diff --git a/src/filemanager/find.c b/src/filemanager/find.c index 0bea40b3b..7c2170173 100644 --- a/src/filemanager/find.c +++ b/src/filemanager/find.c @@ -1693,10 +1693,9 @@ do_find (const char *start_dir, ssize_t start_dir_len, const char *ignore_dirs, /* absolute path */ if (start_dir_len < 0) { - int ret; vfs_path_free (current_panel->cwd_vpath); current_panel->cwd_vpath = vfs_path_from_str (PATH_SEP_STR); - ret = chdir (PATH_SEP_STR); + chdir (PATH_SEP_STR); } panelize_save_panel (current_panel); } diff --git a/src/filemanager/panel.c b/src/filemanager/panel.c index e2660283f..36f496f58 100644 --- a/src/filemanager/panel.c +++ b/src/filemanager/panel.c @@ -3958,7 +3958,7 @@ panel_new_with_dir (const char *panel_name, const char *wpath) vfs_path_t *vpath; vpath = vfs_path_from_str (curdir); - err = mc_chdir (vpath); + mc_chdir (vpath); vfs_path_free (vpath); } g_free (curdir); diff --git a/src/filemanager/panelize.c b/src/filemanager/panelize.c index fc05bdebe..529854642 100644 --- a/src/filemanager/panelize.c +++ b/src/filemanager/panelize.c @@ -387,9 +387,8 @@ do_external_panelize (char *command) current_panel->count = next_free; if (list->list[0].fname[0] == PATH_SEP) { - int ret; panel_set_cwd (current_panel, PATH_SEP_STR); - ret = chdir (PATH_SEP_STR); + chdir (PATH_SEP_STR); } } else diff --git a/src/filemanager/tree.c b/src/filemanager/tree.c index ef14aa44e..a240a9c7f 100644 --- a/src/filemanager/tree.c +++ b/src/filemanager/tree.c @@ -736,7 +736,6 @@ static void tree_rescan (void *data) { WTree *tree = data; - int ret; vfs_path_t *old_vpath; old_vpath = vfs_path_clone (vfs_get_raw_current_dir ()); @@ -746,7 +745,7 @@ tree_rescan (void *data) if (tree->selected_ptr != NULL && mc_chdir (tree->selected_ptr->name) == 0) { tree_store_rescan (tree->selected_ptr->name); - ret = mc_chdir (old_vpath); + mc_chdir (old_vpath); } vfs_path_free (old_vpath); } diff --git a/src/main.c b/src/main.c index 8fecc39ed..9f11363b4 100644 --- a/src/main.c +++ b/src/main.c @@ -603,10 +603,8 @@ main (int argc, char *argv[]) S_IRUSR | S_IWUSR); if (last_wd_fd != -1) { - ssize_t ret1; - int ret2; - ret1 = write (last_wd_fd, last_wd_string, strlen (last_wd_string)); - ret2 = close (last_wd_fd); + (void) write (last_wd_fd, last_wd_string, strlen (last_wd_string)); + (void) close (last_wd_fd); } } g_free (last_wd_string); diff --git a/src/subshell.c b/src/subshell.c index 7eefab554..410a88d1e 100644 --- a/src/subshell.c +++ b/src/subshell.c @@ -252,10 +252,7 @@ init_subshell_child (const char *pty_name) /* It simplifies things to change to our home directory here, */ /* and the user's startup file may do a `cd' command anyway */ - { - int ret; - ret = chdir (mc_config_get_home_dir ()); /* FIXME? What about when we re-run the subshell? */ - } + chdir (mc_config_get_home_dir ()); /* FIXME? What about when we re-run the subshell? */ /* Set MC_SID to prevent running one mc from another */ mc_sid = getsid (0); diff --git a/src/vfs/fish/fish.c b/src/vfs/fish/fish.c index bbda7ee4c..ffaeeaeab 100644 --- a/src/vfs/fish/fish.c +++ b/src/vfs/fish/fish.c @@ -251,9 +251,8 @@ fish_command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply, c if (logfile) { - size_t ret; - ret = fwrite (str, strlen (str), 1, logfile); - ret = fflush (logfile); + (void) fwrite (str, strlen (str), 1, logfile); + (void) fflush (logfile); } tty_enable_interrupt_key (); @@ -330,13 +329,13 @@ fish_pipeopen (struct vfs_s_super *super, const char *path, const char *argv[]) } else { - res = dup2 (fileset1[0], 0); + (void) dup2 (fileset1[0], 0); close (fileset1[0]); close (fileset1[1]); - res = dup2 (fileset2[1], 1); + (void) dup2 (fileset2[1], 1); close (2); /* stderr to /dev/null */ - res = open ("/dev/null", O_WRONLY); + (void) open ("/dev/null", O_WRONLY); close (fileset2[0]); close (fileset2[1]); execvp (path, const_cast (char **, argv)); diff --git a/src/vfs/ftpfs/ftpfs.c b/src/vfs/ftpfs/ftpfs.c index fa9a13a5a..fa5f14ebe 100644 --- a/src/vfs/ftpfs/ftpfs.c +++ b/src/vfs/ftpfs/ftpfs.c @@ -477,8 +477,7 @@ ftpfs_command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply, } else { - size_t ret; - ret = fwrite (cmdstr, cmdlen, 1, MEDATA->logfile); + (void) fwrite (cmdstr, cmdlen, 1, MEDATA->logfile); } fflush (MEDATA->logfile); -- 2.11.4.GIT