mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 12:32:40 +03:00
Reduce cppcheck warnings (style) in src subdirectory.
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
9fcff743a7
commit
b136b2fa9f
@ -250,8 +250,8 @@ handle_console_linux (console_action_t action)
|
||||
close (pipefd1[1]);
|
||||
close (pipefd2[0]);
|
||||
ret = waitpid (cons_saver_pid, &status, 0);
|
||||
mc_global.tty.console_flag = '\0';
|
||||
(void) ret;
|
||||
mc_global.tty.console_flag = '\0';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -957,7 +957,7 @@ mkdir_cmd (void)
|
||||
_("Enter directory name:"), MC_HISTORY_FM_MKDIR, name,
|
||||
INPUT_COMPLETE_FILENAMES);
|
||||
|
||||
if (dir != NULL && dir != '\0')
|
||||
if (dir != NULL && *dir != '\0')
|
||||
{
|
||||
vfs_path_t *absdir;
|
||||
|
||||
|
@ -117,9 +117,6 @@ my_mkdir (const vfs_path_t * s_vpath, mode_t mode)
|
||||
vfs_path_t *my_s;
|
||||
|
||||
my_s = get_absolute_name (s_vpath);
|
||||
#ifdef FIXME
|
||||
tree_add_entry (tree, my_s);
|
||||
#endif
|
||||
vfs_path_free (my_s);
|
||||
}
|
||||
return result;
|
||||
@ -132,9 +129,6 @@ my_rmdir (const char *s)
|
||||
{
|
||||
int result;
|
||||
vfs_path_t *vpath;
|
||||
#ifdef FIXME
|
||||
WTree *tree = 0;
|
||||
#endif
|
||||
|
||||
vpath = vfs_path_from_str_flags (s, VPF_NO_CANON);
|
||||
/* FIXME: Should receive a Wtree! */
|
||||
@ -144,9 +138,6 @@ my_rmdir (const char *s)
|
||||
vfs_path_t *my_s;
|
||||
|
||||
my_s = get_absolute_name (vpath);
|
||||
#ifdef FIXME
|
||||
tree_remove_entry (tree, my_s);
|
||||
#endif
|
||||
vfs_path_free (my_s);
|
||||
}
|
||||
vfs_path_free (vpath);
|
||||
|
@ -1187,20 +1187,19 @@ find_ignore_dir_search (const char *dir)
|
||||
static void
|
||||
find_rotate_dash (const WDialog * h, gboolean show)
|
||||
{
|
||||
static const char rotating_dash[4] = "|/-\\";
|
||||
static size_t pos = 0;
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
static const char rotating_dash[4] = "|/-\\";
|
||||
const Widget *w = WIDGET (h);
|
||||
|
||||
if (!verbose)
|
||||
return;
|
||||
|
||||
tty_setcolor (h->color[DLG_COLOR_NORMAL]);
|
||||
widget_move (h, w->lines - 7, w->cols - 4);
|
||||
tty_print_char (show ? rotating_dash[pos] : ' ');
|
||||
pos = (pos + 1) % sizeof (rotating_dash);
|
||||
mc_refresh ();
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
|
@ -740,8 +740,15 @@ read_file_system_list (int need_fs_type)
|
||||
int val;
|
||||
struct fs_data fsd;
|
||||
|
||||
while (errno = 0, 0 < (val = getmnt (&offset, &fsd, sizeof (fsd), NOSTAT_MANY, (char *) 0)))
|
||||
while (TRUE)
|
||||
{
|
||||
errno = 0;
|
||||
val = getmnt (&offset, &fsd, sizeof (fsd), NOSTAT_MANY, (char *) NULL);
|
||||
if (val < 0)
|
||||
goto free_then_fail;
|
||||
if (val == 0)
|
||||
break;
|
||||
|
||||
me = g_malloc (sizeof (*me));
|
||||
me->me_devname = g_strdup (fsd.fd_req.devname);
|
||||
me->me_mountdir = g_strdup (fsd.fd_req.path);
|
||||
@ -755,8 +762,6 @@ read_file_system_list (int need_fs_type)
|
||||
*mtail = me;
|
||||
mtail = &me->me_next;
|
||||
}
|
||||
if (val < 0)
|
||||
goto free_then_fail;
|
||||
}
|
||||
#endif /* MOUNTED_GETMNT. */
|
||||
|
||||
@ -992,7 +997,7 @@ read_file_system_list (int need_fs_type)
|
||||
char *table = MNTTAB;
|
||||
FILE *fp;
|
||||
int ret;
|
||||
int lockfd = -1;
|
||||
int lockfd;
|
||||
|
||||
#if defined F_RDLCK && defined F_SETLKW
|
||||
/* MNTTAB_LOCK is a macro name of our own invention; it's not present in
|
||||
@ -1003,9 +1008,10 @@ read_file_system_list (int need_fs_type)
|
||||
#define MNTTAB_LOCK "/etc/.mnttab.lock"
|
||||
#endif
|
||||
lockfd = open (MNTTAB_LOCK, O_RDONLY);
|
||||
if (0 <= lockfd)
|
||||
if (lockfd >= 0)
|
||||
{
|
||||
struct flock flock;
|
||||
|
||||
flock.l_type = F_RDLCK;
|
||||
flock.l_whence = SEEK_SET;
|
||||
flock.l_start = 0;
|
||||
@ -1019,6 +1025,7 @@ read_file_system_list (int need_fs_type)
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (errno != ENOENT)
|
||||
return NULL;
|
||||
#endif
|
||||
@ -1048,10 +1055,10 @@ read_file_system_list (int need_fs_type)
|
||||
ret = fclose (fp) == EOF ? errno : 0 < ret ? 0 : -1;
|
||||
}
|
||||
|
||||
if (0 <= lockfd && close (lockfd) != 0)
|
||||
if (lockfd >= 0 && close (lockfd) != 0)
|
||||
ret = errno;
|
||||
|
||||
if (0 <= ret)
|
||||
if (ret >= 0)
|
||||
{
|
||||
errno = ret;
|
||||
goto free_then_fail;
|
||||
|
@ -197,6 +197,7 @@ fish_decode_reply (char *s, gboolean was_garbage)
|
||||
{
|
||||
int code;
|
||||
|
||||
/* cppcheck-suppress invalidscanf */
|
||||
if (sscanf (s, "%d", &code) == 0)
|
||||
{
|
||||
code = 500;
|
||||
@ -809,6 +810,7 @@ fish_dir_load (struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path)
|
||||
case 'D':
|
||||
{
|
||||
struct tm tim;
|
||||
/* cppcheck-suppress invalidscanf */
|
||||
if (sscanf (buffer + 1, "%d %d %d %d %d %d", &tim.tm_year, &tim.tm_mon,
|
||||
&tim.tm_mday, &tim.tm_hour, &tim.tm_min, &tim.tm_sec) != 6)
|
||||
break;
|
||||
@ -818,6 +820,7 @@ fish_dir_load (struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path)
|
||||
case 'E':
|
||||
{
|
||||
int maj, min;
|
||||
/* cppcheck-suppress invalidscanf */
|
||||
if (sscanf (buffer + 1, "%d,%d", &maj, &min) != 2)
|
||||
break;
|
||||
#ifdef HAVE_STRUCT_STAT_ST_RDEV
|
||||
|
@ -386,6 +386,7 @@ ftpfs_get_reply (struct vfs_class *me, int sock, char *string_buf, int string_le
|
||||
code = 421;
|
||||
return 4;
|
||||
}
|
||||
/* cppcheck-suppress invalidscanf */
|
||||
switch (sscanf (answer, "%d", &code))
|
||||
{
|
||||
case 0:
|
||||
@ -405,6 +406,7 @@ ftpfs_get_reply (struct vfs_class *me, int sock, char *string_buf, int string_le
|
||||
code = 421;
|
||||
return 4;
|
||||
}
|
||||
/* cppcheck-suppress invalidscanf */
|
||||
if ((sscanf (answer, "%d", &i) > 0) && (code == i) && (answer[3] == ' '))
|
||||
break;
|
||||
}
|
||||
@ -1093,6 +1095,7 @@ ftpfs_setup_passive_pasv (struct vfs_class *me, struct vfs_s_super *super,
|
||||
return 0;
|
||||
if (!isdigit ((unsigned char) *c))
|
||||
return 0;
|
||||
/* cppcheck-suppress invalidscanf */
|
||||
if (sscanf (c, "%d,%d,%d,%d,%d,%d", &xa, &xb, &xc, &xd, &xe, &xf) != 6)
|
||||
return 0;
|
||||
|
||||
|
@ -253,7 +253,6 @@ sftpfs_fill_config_entity_from_config (FILE * ssh_config_handler,
|
||||
{
|
||||
mc_search_t *pattern_regexp;
|
||||
|
||||
pattern_block_hit = FALSE;
|
||||
pattern_regexp = mc_search_new (host_pattern, -1, DEFAULT_CHARSET);
|
||||
pattern_regexp->search_type = MC_SEARCH_T_GLOB;
|
||||
pattern_regexp->is_case_sensitive = FALSE;
|
||||
|
@ -146,16 +146,12 @@ enum
|
||||
|
||||
struct sparse
|
||||
{
|
||||
/* cppcheck-suppress unusedStructMember */
|
||||
char offset[12];
|
||||
/* cppcheck-suppress unusedStructMember */
|
||||
char numbytes[12];
|
||||
};
|
||||
|
||||
struct sp_array
|
||||
{
|
||||
int offset;
|
||||
int numbytes;
|
||||
};
|
||||
|
||||
union record
|
||||
{
|
||||
char charptr[RECORDSIZE];
|
||||
@ -190,11 +186,15 @@ union record
|
||||
{
|
||||
char atime[12];
|
||||
char ctime[12];
|
||||
/* cppcheck-suppress unusedStructMember */
|
||||
char offset[12];
|
||||
/* cppcheck-suppress unusedStructMember */
|
||||
char longnames[4];
|
||||
/* cppcheck-suppress unusedStructMember */
|
||||
char pad;
|
||||
struct sparse sp[SPARSE_IN_HDR];
|
||||
char isextended;
|
||||
/* cppcheck-suppress unusedStructMember */
|
||||
char realsize[12]; /* true size of the sparse file */
|
||||
} oldgnu;
|
||||
} unused;
|
||||
|
@ -110,6 +110,22 @@ utf8_to_int (char *str, int *char_width, gboolean * result)
|
||||
}
|
||||
#endif /* HAVE_CHARSET */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/** Determine the state of the current byte.
|
||||
*
|
||||
* @param view viewer object
|
||||
* @param from offset
|
||||
* @param curr current node
|
||||
*/
|
||||
|
||||
static mark_t
|
||||
mcview_hex_calculate_boldflag (mcview_t * view, off_t from, struct hexedit_change_node *curr)
|
||||
{
|
||||
return (from == view->hex_cursor) ? MARK_CURSOR
|
||||
: (curr != NULL && from == curr->offset) ? MARK_CHANGED
|
||||
: (view->search_start <= from && from < view->search_end) ? MARK_SELECTED : MARK_NORMAL;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -218,11 +234,7 @@ mcview_display_hex (mcview_t * view)
|
||||
}
|
||||
|
||||
/* Determine the state of the current byte */
|
||||
boldflag =
|
||||
(from == view->hex_cursor) ? MARK_CURSOR
|
||||
: (curr != NULL && from == curr->offset) ? MARK_CHANGED
|
||||
: (view->search_start <= from &&
|
||||
from < view->search_end) ? MARK_SELECTED : MARK_NORMAL;
|
||||
boldflag = mcview_hex_calculate_boldflag (view, from, curr);
|
||||
|
||||
/* Determine the value of the current byte */
|
||||
if (curr != NULL && from == curr->offset)
|
||||
|
@ -310,7 +310,7 @@ mcview_load (mcview_t * view, const char *command, const char *file, int start_l
|
||||
retval = mcview_load_command_output (view, command);
|
||||
else if (file != NULL && file[0] != '\0')
|
||||
{
|
||||
int fd = -1;
|
||||
int fd;
|
||||
char tmp[BUF_MEDIUM];
|
||||
struct stat st;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user