1
1

Ticket #1897: Build breaks on ignored return values

Changes into lib directory

 * samba: handling result of system() call
 * rpc: handling write errors
 * ftpfs: ignoring result of fwrite() on logfile (make compiler happy ;-))
 * fish: proper handling of file io calls
 * ignoring result of fwrite() on logfile (make compiler happy ;-))
 * lib/util.c: handling fwrite() call errors in mc_util_write_backup_content()
 * lib/utilunix.c:
  * handling possible error on dup() in close_error_pipe()
  * handling possible error on getcwd() in mc_realpath()

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
Этот коммит содержится в:
Enrico Weigelt, metux IT service 2009-12-28 23:53:09 +01:00 коммит произвёл Slava Zanko
родитель 66ff918624
Коммит 303833d590
8 изменённых файлов: 80 добавлений и 36 удалений

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

@ -1241,6 +1241,7 @@ mc_util_write_backup_content (const char *from_file_name, const char *to_file_na
FILE *backup_fd;
char *contents;
gsize length;
gboolean ret1 = TRUE;
if (!g_file_get_contents (from_file_name, &contents, &length, NULL))
return FALSE;
@ -1252,12 +1253,15 @@ mc_util_write_backup_content (const char *from_file_name, const char *to_file_na
return FALSE;
}
fwrite ((const void *) contents, length, 1, backup_fd);
fflush (backup_fd);
fclose (backup_fd);
if (fwrite ((const void *) contents, length, 1, backup_fd) != length)
ret1 = FALSE;
{
int ret2;
ret2 = fflush (backup_fd);
ret2 = fclose (backup_fd);
}
g_free (contents);
return TRUE;
return ret1;
}
/* Finds out a relative path from first to second, i.e. goes as many ..

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

@ -410,8 +410,11 @@ close_error_pipe (int error, const char *text)
else
title = _("Warning");
if (old_error >= 0){
close (2);
dup (old_error);
if (dup2 (old_error, 2))
{
message (error, MSG_ERROR, "%s", _("Error dup'ing old error pipe"));
return 1;
}
close (old_error);
len = read (error_pipe[0], msg, MAX_PIPE_SIZE - 1);
@ -617,13 +620,20 @@ mc_realpath (const char *path, char resolved_path[])
max_path = copy_path + PATH_MAX - 2;
/* If it's a relative pathname use getwd for starters. */
if (*path != '/') {
/* Ohoo... */
#ifdef HAVE_GETCWD
getcwd (new_path, PATH_MAX - 1);
#else
getwd (new_path);
#endif
new_path += strlen (new_path);
new_path = g_get_current_dir ();
if (new_path == NULL)
{
strcpy(got_path, "");
}
else
{
g_snprintf(got_path, PATH_MAX, "%s", new_path);
g_free(new_path);
new_path = got_path;
}
new_path += strlen (got_path);
if (new_path[-1] != '/')
*new_path++ = '/';
} else {

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

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

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

@ -706,7 +706,7 @@ extfs_resolve_symlinks_int (struct entry *entry, GSList * list)
looping = g_slist_prepend (list, entry);
pent = extfs_find_entry_int (entry->dir, entry->inode->linkname, looping, FALSE, FALSE);
g_slist_delete_link (looping, looping);
looping = g_slist_delete_link (looping, looping);
if (pent == NULL)
my_errno = ENOENT;

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

@ -159,8 +159,9 @@ fish_command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply, c
if (logfile)
{
fwrite (str, strlen (str), 1, logfile);
fflush (logfile);
size_t ret;
ret = fwrite (str, strlen (str), 1, logfile);
ret = fflush (logfile);
}
tty_enable_interrupt_key ();
@ -217,15 +218,13 @@ fish_pipeopen (struct vfs_s_super *super, const char *path, const char *argv[])
}
else
{
close (0);
dup (fileset1[0]);
res = dup2 (fileset1[0], 0);
close (fileset1[0]);
close (fileset1[1]);
close (1);
res = dup2 (fileset2[1], 1);
close (2);
dup (fileset2[1]);
/* stderr to /dev/null */
open ("/dev/null", O_WRONLY);
res = open ("/dev/null", O_WRONLY);
close (fileset2[0]);
close (fileset2[1]);
execvp (path, const_cast (char **, argv));
@ -294,7 +293,6 @@ fish_open_archive_int (struct vfs_class *me, struct vfs_s_super *super)
print_vfs_message ("%s", answer);
if (strstr (answer, "assword"))
{
/* Currently, this does not work. ssh reads passwords from
/dev/tty, not from stdin :-(. */
@ -312,8 +310,16 @@ fish_open_archive_int (struct vfs_class *me, struct vfs_s_super *super)
SUP.password = op;
}
print_vfs_message (_("fish: Sending password..."));
write (SUP.sockw, SUP.password, strlen (SUP.password));
write (SUP.sockw, "\n", 1);
{
size_t str_len;
str_len = strlen (SUP.password);
if ((write (SUP.sockw, SUP.password, str_len ) != (ssize_t) str_len)
|| (write (SUP.sockw, "\n", 1) != 1))
{
ERRNOR(EIO, -1);
}
}
}
}

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

@ -361,8 +361,10 @@ ftpfs_command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply,
if (MEDATA->logfile) {
if (strncmp (cmdstr, "PASS ", 5) == 0) {
fputs ("PASS <Password not logged>\r\n", MEDATA->logfile);
} else
fwrite (cmdstr, cmdlen, 1, MEDATA->logfile);
} else {
size_t ret;
ret = fwrite (cmdstr, cmdlen, 1, MEDATA->logfile);
}
fflush (MEDATA->logfile);
}

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

@ -113,7 +113,11 @@ rpc_send (int sock, ...)
case RPC_INT:
tmp = htonl (va_arg (ap, int));
write (sock, &tmp, sizeof (tmp));
if (write (sock, &tmp, sizeof (tmp)) != sizeof(tmp))
{
vfs_die ( "RPC: write failed (RPC_INT)" );
break;
}
CHECK_SIG_PIPE (sock);
break;
@ -121,9 +125,17 @@ rpc_send (int sock, ...)
text = va_arg (ap, char *);
len = strlen (text);
tmp = htonl (len);
write (sock, &tmp, sizeof (tmp));
if (write (sock, &tmp, sizeof (tmp)) != sizeof(tmp))
{
vfs_die ( "RPC: write failed (RPC_STRING)" );
break;
}
CHECK_SIG_PIPE (sock);
write (sock, text, len);
if (write (sock, text, len) != len)
{
vfs_die ( "RPC: write failed (RPC_STRING)" );
break;
}
CHECK_SIG_PIPE (sock);
break;
@ -131,7 +143,11 @@ rpc_send (int sock, ...)
len = va_arg (ap, int);
text = va_arg (ap, char *);
tmp = htonl (len);
write (sock, text, len);
if (write (sock, text, len) != len)
{
vfs_die ( "RPC: write failed (RPC_BLOCK)" );
break;
}
CHECK_SIG_PIPE (sock);
break;

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

@ -2330,7 +2330,9 @@ void smb_panic(const char *why)
{
const char *cmd = lp_panic_action();
if (cmd && *cmd) {
system(cmd);
if (system(cmd)) {
DEBUG(0,("PANIC: cannot run panic handler command \"%s\"\n", cmd));
}
}
DEBUG(0,("PANIC: %s\n", why));
dbgflush();