From 01088ce45362d0538a2f27afb21ea539f73f0701 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Wed, 18 Jul 2012 09:43:19 +0400 Subject: [PATCH] Revert "Try fix of compile warnings about assigned but unused variables" This reverts commit 3d1a4ecaf7be21f0d31f5aa17cd36a43f4c2d492. Signed-off-by: Andrew Borodin --- 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, 66 insertions(+), 45 deletions(-) diff --git a/lib/util.c b/lib/util.c index 155eb1d7b..a56e2c83e 100644 --- a/lib/util.c +++ b/lib/util.c @@ -208,8 +208,9 @@ 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; { - (void) fflush (backup_fd); - (void) fclose (backup_fd); + int ret2; + ret2 = fflush (backup_fd); + ret2 = fclose (backup_fd); } g_free (contents); return ret1; diff --git a/lib/vfs/direntry.c b/lib/vfs/direntry.c index f9cdbbcb5..016f96d45 100644 --- a/lib/vfs/direntry.c +++ b/lib/vfs/direntry.c @@ -1523,8 +1523,10 @@ vfs_s_get_line (struct vfs_class *me, int sock, char *buf, int buf_len, char ter { if (logfile) { - (void) fwrite (&c, 1, 1, logfile); - (void) fflush (logfile); + size_t ret1; + int ret2; + ret1 = fwrite (&c, 1, 1, logfile); + ret2 = fflush (logfile); } if (c == '\n') return 1; diff --git a/src/background.c b/src/background.c index ce23fb8f3..a68fe8637 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; + ssize_t bytes, ret; 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 */ - (void) write (to_child_fd, &result, sizeof (int)); + ret = write (to_child_fd, &result, sizeof (int)); if (have_ctx && to_child_fd != -1) - (void) write (to_child_fd, ctx, sizeof (FileOpContext)); + ret = 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); - (void) write (to_child_fd, &len, sizeof (len)); + ret = write (to_child_fd, &len, sizeof (len)); if (len != 0) - (void) write (to_child_fd, resstr, len); + ret = write (to_child_fd, resstr, len); g_free (resstr); } else { len = 0; - (void) write (to_child_fd, &len, sizeof (len)); + ret = write (to_child_fd, &len, sizeof (len)); } } for (i = 0; i < argc; i++) @@ -398,16 +398,17 @@ static void parent_call_header (void *routine, int argc, enum ReturnType type, FileOpContext * ctx) { int have_ctx; + ssize_t ret; have_ctx = (ctx != NULL); - (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)); + 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)); if (have_ctx) - (void) write (parent_fd, ctx, sizeof (FileOpContext)); + ret = write (parent_fd, ctx, sizeof (FileOpContext)); } /* --------------------------------------------------------------------------------------------- */ @@ -416,6 +417,7 @@ 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); @@ -426,13 +428,13 @@ parent_va_call (void *routine, gpointer data, int argc, va_list ap) len = va_arg (ap, int); value = va_arg (ap, void *); - (void) write (parent_fd, &len, sizeof (int)); - (void) write (parent_fd, value, len); + ret = write (parent_fd, &len, sizeof (int)); + ret = write (parent_fd, value, len); } - (void) read (from_parent_fd, &i, sizeof (int)); + ret = read (from_parent_fd, &i, sizeof (int)); if (ctx) - (void) read (from_parent_fd, ctx, sizeof (FileOpContext)); + ret = read (from_parent_fd, ctx, sizeof (FileOpContext)); return i; } diff --git a/src/clipboard.c b/src/clipboard.c index cb9daa61e..5b04600e8 100644 --- a/src/clipboard.c +++ b/src/clipboard.c @@ -66,6 +66,7 @@ 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; @@ -80,7 +81,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) - (void) my_system (EXECUTE_AS_SHELL, shell, cmd); + res = my_system (EXECUTE_AS_SHELL, shell, cmd); g_free (cmd); g_free (tmp); @@ -126,6 +127,7 @@ 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; @@ -145,7 +147,7 @@ clipboard_text_to_file (const gchar * event_group_name, const gchar * event_name return TRUE; str_len = strlen (text); - (void) mc_write (file, (char *) text, str_len); + ret = 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 3dd6e03ea..3ccaa7c72 100644 --- a/src/cons.handler.c +++ b/src/cons.handler.c @@ -90,6 +90,7 @@ 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') @@ -104,29 +105,29 @@ show_console_contents_linux (int starty, unsigned char begin_line, unsigned char /* Send command to the console handler */ message = CONSOLE_CONTENTS; - (void) write (pipefd1[1], &message, 1); + ret = write (pipefd1[1], &message, 1); /* Check for outdated cons.saver */ - (void) read (pipefd2[0], &message, 1); + ret = read (pipefd2[0], &message, 1); if (message != CONSOLE_CONTENTS) return; /* Send the range of lines that we want */ - (void) write (pipefd1[1], &begin_line, 1); - (void) write (pipefd1[1], &end_line, 1); + ret = write (pipefd1[1], &begin_line, 1); + ret = write (pipefd1[1], &end_line, 1); /* Read the corresponding number of bytes */ - (void) read (pipefd2[0], &bytes, 2); + ret = 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); - (void) read (pipefd2[0], &message, 1); + ret = read (pipefd2[0], &message, 1); tty_print_char (message); } /* Read the value of the mc_global.tty.console_flag */ - (void) read (pipefd2[0], &message, 1); + ret = read (pipefd2[0], &message, 1); } /* --------------------------------------------------------------------------------------------- */ @@ -239,9 +240,10 @@ 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]); - (void) waitpid (cons_saver_pid, &status, 0); + ret = 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 ba88445ae..dea413b1f 100644 --- a/src/consaver/cons.saver.c +++ b/src/consaver/cons.saver.c @@ -143,7 +143,8 @@ send_contents (char *buffer, unsigned int columns, unsigned int rows) static void __attribute__ ((noreturn)) die (void) { unsigned char zero = 0; - (void) write (1, &zero, 1); + ssize_t ret; + ret = write (1, &zero, 1); exit (3); } diff --git a/src/diffviewer/ydiff.c b/src/diffviewer/ydiff.c index 95ac5d46a..b913b8ea4 100644 --- a/src/diffviewer/ydiff.c +++ b/src/diffviewer/ydiff.c @@ -2188,6 +2188,7 @@ 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); @@ -2234,7 +2235,7 @@ do_merge_hunk (WDiff * dview) } fflush (merge_file); fclose (merge_file); - rewrite_backup_content (merge_file_name_vpath, dview->file[0]); + res = rewrite_backup_content (merge_file_name_vpath, dview->file[0]); mc_unlink (merge_file_name_vpath); vfs_path_free (merge_file_name_vpath); } @@ -2974,7 +2975,7 @@ dview_ok_to_exit (WDiff * dview) break; case 1: /* No */ if (mc_util_restore_from_backup_if_possible (dview->file[0], "~~~")) - mc_util_unlink_backup_if_possible (dview->file[0], "~~~"); + res = 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 7c2170173..0bea40b3b 100644 --- a/src/filemanager/find.c +++ b/src/filemanager/find.c @@ -1693,9 +1693,10 @@ 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); - chdir (PATH_SEP_STR); + ret = chdir (PATH_SEP_STR); } panelize_save_panel (current_panel); } diff --git a/src/filemanager/panel.c b/src/filemanager/panel.c index fc53d038f..155795488 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); - mc_chdir (vpath); + err = mc_chdir (vpath); vfs_path_free (vpath); } g_free (curdir); diff --git a/src/filemanager/panelize.c b/src/filemanager/panelize.c index 529854642..fc05bdebe 100644 --- a/src/filemanager/panelize.c +++ b/src/filemanager/panelize.c @@ -387,8 +387,9 @@ 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); - chdir (PATH_SEP_STR); + ret = chdir (PATH_SEP_STR); } } else diff --git a/src/filemanager/tree.c b/src/filemanager/tree.c index a240a9c7f..ef14aa44e 100644 --- a/src/filemanager/tree.c +++ b/src/filemanager/tree.c @@ -736,6 +736,7 @@ 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 ()); @@ -745,7 +746,7 @@ tree_rescan (void *data) if (tree->selected_ptr != NULL && mc_chdir (tree->selected_ptr->name) == 0) { tree_store_rescan (tree->selected_ptr->name); - mc_chdir (old_vpath); + ret = mc_chdir (old_vpath); } vfs_path_free (old_vpath); } diff --git a/src/main.c b/src/main.c index 9f11363b4..8fecc39ed 100644 --- a/src/main.c +++ b/src/main.c @@ -603,8 +603,10 @@ main (int argc, char *argv[]) S_IRUSR | S_IWUSR); if (last_wd_fd != -1) { - (void) write (last_wd_fd, last_wd_string, strlen (last_wd_string)); - (void) close (last_wd_fd); + ssize_t ret1; + int ret2; + ret1 = write (last_wd_fd, last_wd_string, strlen (last_wd_string)); + ret2 = close (last_wd_fd); } } g_free (last_wd_string); diff --git a/src/subshell.c b/src/subshell.c index ad11fd2e0..7eefab554 100644 --- a/src/subshell.c +++ b/src/subshell.c @@ -252,7 +252,10 @@ 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 */ - chdir (mc_config_get_home_dir ()); /* FIXME? What about when we re-run the subshell? */ + { + int ret; + ret = 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 ffaeeaeab..bbda7ee4c 100644 --- a/src/vfs/fish/fish.c +++ b/src/vfs/fish/fish.c @@ -251,8 +251,9 @@ fish_command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply, c if (logfile) { - (void) fwrite (str, strlen (str), 1, logfile); - (void) fflush (logfile); + size_t ret; + ret = fwrite (str, strlen (str), 1, logfile); + ret = fflush (logfile); } tty_enable_interrupt_key (); @@ -329,13 +330,13 @@ fish_pipeopen (struct vfs_s_super *super, const char *path, const char *argv[]) } else { - (void) dup2 (fileset1[0], 0); + res = dup2 (fileset1[0], 0); close (fileset1[0]); close (fileset1[1]); - (void) dup2 (fileset2[1], 1); + res = dup2 (fileset2[1], 1); close (2); /* stderr to /dev/null */ - (void) open ("/dev/null", O_WRONLY); + res = 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 fa5f14ebe..fa9a13a5a 100644 --- a/src/vfs/ftpfs/ftpfs.c +++ b/src/vfs/ftpfs/ftpfs.c @@ -477,7 +477,8 @@ ftpfs_command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply, } else { - (void) fwrite (cmdstr, cmdlen, 1, MEDATA->logfile); + size_t ret; + ret = fwrite (cmdstr, cmdlen, 1, MEDATA->logfile); } fflush (MEDATA->logfile); -- 2.11.4.GIT