1
1

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 <slavazanko@gmail.com>
Этот коммит содержится в:
Slava Zanko 2012-07-04 11:20:52 +03:00 коммит произвёл Andrew Borodin
родитель 23c95d36ac
Коммит 6505f7d6fa
15 изменённых файлов: 45 добавлений и 66 удалений

Просмотреть файл

@ -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) if (fwrite ((const void *) contents, 1, length, backup_fd) != length)
ret1 = FALSE; ret1 = FALSE;
{ {
int ret2; (void) fflush (backup_fd);
ret2 = fflush (backup_fd); (void) fclose (backup_fd);
ret2 = fclose (backup_fd);
} }
g_free (contents); g_free (contents);
return ret1; return ret1;

Просмотреть файл

@ -1523,10 +1523,8 @@ vfs_s_get_line (struct vfs_class *me, int sock, char *buf, int buf_len, char ter
{ {
if (logfile) if (logfile)
{ {
size_t ret1; (void) fwrite (&c, 1, 1, logfile);
int ret2; (void) fflush (logfile);
ret1 = fwrite (&c, 1, 1, logfile);
ret2 = fflush (logfile);
} }
if (c == '\n') if (c == '\n')
return 1; return 1;

Просмотреть файл

@ -200,7 +200,7 @@ background_attention (int fd, void *closure)
/* void *routine; */ /* void *routine; */
int argc, i, result, status; int argc, i, result, status;
char *data[MAXCALLARGS]; char *data[MAXCALLARGS];
ssize_t bytes, ret; ssize_t bytes;
struct TaskList *p; struct TaskList *p;
int to_child_fd = -1; int to_child_fd = -1;
enum ReturnType type; enum ReturnType type;
@ -330,9 +330,9 @@ background_attention (int fd, void *closure)
} }
/* Send the result code and the value for shared variables */ /* 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) 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) else if (type == Return_String)
{ {
@ -365,15 +365,15 @@ background_attention (int fd, void *closure)
if (resstr) if (resstr)
{ {
len = strlen (resstr); len = strlen (resstr);
ret = write (to_child_fd, &len, sizeof (len)); (void) write (to_child_fd, &len, sizeof (len));
if (len != 0) if (len != 0)
ret = write (to_child_fd, resstr, len); (void) write (to_child_fd, resstr, len);
g_free (resstr); g_free (resstr);
} }
else else
{ {
len = 0; len = 0;
ret = write (to_child_fd, &len, sizeof (len)); (void) write (to_child_fd, &len, sizeof (len));
} }
} }
for (i = 0; i < argc; i++) for (i = 0; i < argc; i++)
@ -398,17 +398,16 @@ static void
parent_call_header (void *routine, int argc, enum ReturnType type, FileOpContext * ctx) parent_call_header (void *routine, int argc, enum ReturnType type, FileOpContext * ctx)
{ {
int have_ctx; int have_ctx;
ssize_t ret;
have_ctx = (ctx != NULL); have_ctx = (ctx != NULL);
ret = write (parent_fd, &routine, sizeof (routine)); (void) write (parent_fd, &routine, sizeof (routine));
ret = write (parent_fd, &argc, sizeof (int)); (void) write (parent_fd, &argc, sizeof (int));
ret = write (parent_fd, &type, sizeof (type)); (void) write (parent_fd, &type, sizeof (type));
ret = write (parent_fd, &have_ctx, sizeof (have_ctx)); (void) write (parent_fd, &have_ctx, sizeof (have_ctx));
if (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) parent_va_call (void *routine, gpointer data, int argc, va_list ap)
{ {
int i; int i;
ssize_t ret;
struct FileOpContext *ctx = (struct FileOpContext *) data; struct FileOpContext *ctx = (struct FileOpContext *) data;
parent_call_header (routine, argc, Return_Integer, ctx); 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); len = va_arg (ap, int);
value = va_arg (ap, void *); value = va_arg (ap, void *);
ret = write (parent_fd, &len, sizeof (int)); (void) write (parent_fd, &len, sizeof (int));
ret = write (parent_fd, value, len); (void) write (parent_fd, value, len);
} }
ret = read (from_parent_fd, &i, sizeof (int)); (void) read (from_parent_fd, &i, sizeof (int));
if (ctx) if (ctx)
ret = read (from_parent_fd, ctx, sizeof (FileOpContext)); (void) read (from_parent_fd, ctx, sizeof (FileOpContext));
return i; return i;
} }

Просмотреть файл

@ -66,7 +66,6 @@ clipboard_file_to_ext_clip (const gchar * event_group_name, const gchar * event_
gpointer init_data, gpointer data) gpointer init_data, gpointer data)
{ {
char *tmp, *cmd; char *tmp, *cmd;
int res = 0;
const char *d = getenv ("DISPLAY"); const char *d = getenv ("DISPLAY");
(void) event_group_name; (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); cmd = g_strconcat (clipboard_store_path, " ", tmp, " 2>/dev/null", (char *) NULL);
if (cmd != 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 (cmd);
g_free (tmp); g_free (tmp);
@ -127,7 +126,6 @@ clipboard_text_to_file (const gchar * event_group_name, const gchar * event_name
{ {
int file; int file;
vfs_path_t *fname_vpath = NULL; vfs_path_t *fname_vpath = NULL;
ssize_t ret;
size_t str_len; size_t str_len;
const char *text = (const char *) data; 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; return TRUE;
str_len = strlen (text); str_len = strlen (text);
ret = mc_write (file, (char *) text, str_len); (void) mc_write (file, (char *) text, str_len);
mc_close (file); mc_close (file);
return TRUE; return TRUE;
} }

Просмотреть файл

@ -90,7 +90,6 @@ show_console_contents_linux (int starty, unsigned char begin_line, unsigned char
unsigned char message = 0; unsigned char message = 0;
unsigned short bytes = 0; unsigned short bytes = 0;
int i; int i;
ssize_t ret;
/* Is tty console? */ /* Is tty console? */
if (mc_global.tty.console_flag == '\0') 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 */ /* Send command to the console handler */
message = CONSOLE_CONTENTS; message = CONSOLE_CONTENTS;
ret = write (pipefd1[1], &message, 1); (void) write (pipefd1[1], &message, 1);
/* Check for outdated cons.saver */ /* Check for outdated cons.saver */
ret = read (pipefd2[0], &message, 1); (void) read (pipefd2[0], &message, 1);
if (message != CONSOLE_CONTENTS) if (message != CONSOLE_CONTENTS)
return; return;
/* Send the range of lines that we want */ /* Send the range of lines that we want */
ret = write (pipefd1[1], &begin_line, 1); (void) write (pipefd1[1], &begin_line, 1);
ret = write (pipefd1[1], &end_line, 1); (void) write (pipefd1[1], &end_line, 1);
/* Read the corresponding number of bytes */ /* Read the corresponding number of bytes */
ret = read (pipefd2[0], &bytes, 2); (void) read (pipefd2[0], &bytes, 2);
/* Read the bytes and output them */ /* Read the bytes and output them */
for (i = 0; i < bytes; i++) for (i = 0; i < bytes; i++)
{ {
if ((i % COLS) == 0) if ((i % COLS) == 0)
tty_gotoyx (starty + (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); tty_print_char (message);
} }
/* Read the value of the mc_global.tty.console_flag */ /* 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') if (action == CONSOLE_DONE || mc_global.tty.console_flag == '\0')
{ {
/* We are done -> Let's clean up */ /* We are done -> Let's clean up */
pid_t ret;
close (pipefd1[1]); close (pipefd1[1]);
close (pipefd2[0]); close (pipefd2[0]);
ret = waitpid (cons_saver_pid, &status, 0); (void) waitpid (cons_saver_pid, &status, 0);
mc_global.tty.console_flag = '\0'; mc_global.tty.console_flag = '\0';
} }
break; break;

Просмотреть файл

@ -143,8 +143,7 @@ send_contents (char *buffer, unsigned int columns, unsigned int rows)
static void __attribute__ ((noreturn)) die (void) static void __attribute__ ((noreturn)) die (void)
{ {
unsigned char zero = 0; unsigned char zero = 0;
ssize_t ret; (void) write (1, &zero, 1);
ret = write (1, &zero, 1);
exit (3); exit (3);
} }

Просмотреть файл

@ -2148,7 +2148,6 @@ static void
do_merge_hunk (WDiff * dview) do_merge_hunk (WDiff * dview)
{ {
int from1, to1, from2, to2; int from1, to1, from2, to2;
int res;
int hunk; int hunk;
hunk = get_current_hunk (dview, &from1, &to1, &from2, &to2); hunk = get_current_hunk (dview, &from1, &to1, &from2, &to2);
@ -2195,7 +2194,7 @@ do_merge_hunk (WDiff * dview)
} }
fflush (merge_file); fflush (merge_file);
fclose (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); mc_unlink (merge_file_name_vpath);
vfs_path_free (merge_file_name_vpath); vfs_path_free (merge_file_name_vpath);
} }
@ -2977,7 +2976,7 @@ dview_ok_to_exit (WDiff * dview)
break; break;
case 1: /* No */ case 1: /* No */
if (mc_util_restore_from_backup_if_possible (dview->file[0], "~~~")) 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 */ /* fall through */
default: default:
res = TRUE; res = TRUE;

Просмотреть файл

@ -1694,10 +1694,9 @@ do_find (const char *start_dir, ssize_t start_dir_len, const char *ignore_dirs,
/* absolute path */ /* absolute path */
if (start_dir_len < 0) if (start_dir_len < 0)
{ {
int ret;
vfs_path_free (current_panel->cwd_vpath); vfs_path_free (current_panel->cwd_vpath);
current_panel->cwd_vpath = vfs_path_from_str (PATH_SEP_STR); 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); panelize_save_panel (current_panel);
} }

Просмотреть файл

@ -4123,7 +4123,7 @@ panel_new_with_dir (const char *panel_name, const char *wpath)
vfs_path_t *vpath; vfs_path_t *vpath;
vpath = vfs_path_from_str (curdir); vpath = vfs_path_from_str (curdir);
err = mc_chdir (vpath); mc_chdir (vpath);
vfs_path_free (vpath); vfs_path_free (vpath);
} }
g_free (curdir); g_free (curdir);

Просмотреть файл

@ -388,9 +388,8 @@ do_external_panelize (char *command)
current_panel->count = next_free; current_panel->count = next_free;
if (list->list[0].fname[0] == PATH_SEP) if (list->list[0].fname[0] == PATH_SEP)
{ {
int ret;
panel_set_cwd (current_panel, PATH_SEP_STR); panel_set_cwd (current_panel, PATH_SEP_STR);
ret = chdir (PATH_SEP_STR); chdir (PATH_SEP_STR);
} }
} }
else else

Просмотреть файл

@ -739,7 +739,6 @@ static void
tree_rescan (void *data) tree_rescan (void *data)
{ {
WTree *tree = data; WTree *tree = data;
int ret;
vfs_path_t *old_vpath; vfs_path_t *old_vpath;
old_vpath = vfs_path_clone (vfs_get_raw_current_dir ()); old_vpath = vfs_path_clone (vfs_get_raw_current_dir ());
@ -749,7 +748,7 @@ tree_rescan (void *data)
if (tree->selected_ptr != NULL && mc_chdir (tree->selected_ptr->name) == 0) if (tree->selected_ptr != NULL && mc_chdir (tree->selected_ptr->name) == 0)
{ {
tree_store_rescan (tree->selected_ptr->name); tree_store_rescan (tree->selected_ptr->name);
ret = mc_chdir (old_vpath); mc_chdir (old_vpath);
} }
vfs_path_free (old_vpath); vfs_path_free (old_vpath);
} }

Просмотреть файл

@ -603,10 +603,8 @@ main (int argc, char *argv[])
S_IRUSR | S_IWUSR); S_IRUSR | S_IWUSR);
if (last_wd_fd != -1) if (last_wd_fd != -1)
{ {
ssize_t ret1; (void) write (last_wd_fd, last_wd_string, strlen (last_wd_string));
int ret2; (void) close (last_wd_fd);
ret1 = write (last_wd_fd, last_wd_string, strlen (last_wd_string));
ret2 = close (last_wd_fd);
} }
} }
g_free (last_wd_string); g_free (last_wd_string);

Просмотреть файл

@ -252,10 +252,7 @@ init_subshell_child (const char *pty_name)
/* It simplifies things to change to our home directory here, */ /* It simplifies things to change to our home directory here, */
/* and the user's startup file may do a `cd' command anyway */ /* 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 */ /* Set MC_SID to prevent running one mc from another */
mc_sid = getsid (0); mc_sid = getsid (0);

Просмотреть файл

@ -251,9 +251,8 @@ fish_command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply, c
if (logfile) if (logfile)
{ {
size_t ret; (void) fwrite (str, strlen (str), 1, logfile);
ret = fwrite (str, strlen (str), 1, logfile); (void) fflush (logfile);
ret = fflush (logfile);
} }
tty_enable_interrupt_key (); tty_enable_interrupt_key ();
@ -330,13 +329,13 @@ fish_pipeopen (struct vfs_s_super *super, const char *path, const char *argv[])
} }
else else
{ {
res = dup2 (fileset1[0], 0); (void) dup2 (fileset1[0], 0);
close (fileset1[0]); close (fileset1[0]);
close (fileset1[1]); close (fileset1[1]);
res = dup2 (fileset2[1], 1); (void) dup2 (fileset2[1], 1);
close (2); close (2);
/* stderr to /dev/null */ /* stderr to /dev/null */
res = open ("/dev/null", O_WRONLY); (void) open ("/dev/null", O_WRONLY);
close (fileset2[0]); close (fileset2[0]);
close (fileset2[1]); close (fileset2[1]);
execvp (path, const_cast (char **, argv)); execvp (path, const_cast (char **, argv));

Просмотреть файл

@ -477,8 +477,7 @@ ftpfs_command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply,
} }
else else
{ {
size_t ret; (void) fwrite (cmdstr, cmdlen, 1, MEDATA->logfile);
ret = fwrite (cmdstr, cmdlen, 1, MEDATA->logfile);
} }
fflush (MEDATA->logfile); fflush (MEDATA->logfile);