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