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>
This commit is contained in:
Slava Zanko 2012-07-04 11:20:52 +03:00 committed by Andrew Borodin
parent 23c95d36ac
commit 6505f7d6fa
15 changed files with 45 additions and 66 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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);
}

View File

@ -2148,7 +2148,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);
@ -2195,7 +2194,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);
}
@ -2977,7 +2976,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;

View File

@ -1694,10 +1694,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);
}

View File

@ -4123,7 +4123,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);

View File

@ -388,9 +388,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

View File

@ -739,7 +739,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 ());
@ -749,7 +748,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);
}

View File

@ -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);

View File

@ -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);

View File

@ -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));

View File

@ -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);