mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 04:22:34 +03:00
Reduce cppcheck warnings (style) in lib subdirectory.
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
0d489acd58
commit
0ed4a91d7d
@ -75,6 +75,7 @@ mc_search__hex_translate_to_regex (const GString * astr)
|
||||
{
|
||||
int val, ptr;
|
||||
|
||||
/* cppcheck-suppress invalidscanf */
|
||||
if (sscanf (tmp_str + loop, "%x%n", &val, &ptr))
|
||||
{
|
||||
if (val < -128 || val > 255)
|
||||
|
@ -99,10 +99,13 @@ parse_256_color_name (const char *color_name)
|
||||
{
|
||||
int i;
|
||||
char dummy;
|
||||
|
||||
/* cppcheck-suppress invalidscanf */
|
||||
if (sscanf (color_name, "color%d%c", &i, &dummy) == 1 && i >= 0 && i < 256)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
/* cppcheck-suppress invalidscanf */
|
||||
if (sscanf (color_name, "gray%d%c", &i, &dummy) == 1 && i >= 0 && i < 24)
|
||||
{
|
||||
return 232 + i;
|
||||
@ -155,10 +158,10 @@ tty_color_get_name_by_index (int idx)
|
||||
int
|
||||
tty_color_get_index_by_name (const char *color_name)
|
||||
{
|
||||
|
||||
if (color_name != NULL)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; color_table[i].name != NULL; i++)
|
||||
if (strcmp (color_name, color_table[i].name) == 0)
|
||||
return color_table[i].value;
|
||||
|
@ -1578,9 +1578,6 @@ lookup_key_by_code (const int keycode)
|
||||
/* modifier */
|
||||
unsigned int mod = keycode & KEY_M_MASK;
|
||||
|
||||
int use_meta = -1;
|
||||
int use_ctrl = -1;
|
||||
int use_shift = -1;
|
||||
int key_idx = -1;
|
||||
|
||||
GString *s;
|
||||
@ -1594,8 +1591,7 @@ lookup_key_by_code (const int keycode)
|
||||
{
|
||||
if (lookup_keycode (KEY_M_ALT, &idx))
|
||||
{
|
||||
use_meta = idx;
|
||||
g_string_append (s, key_conv_tab_sorted[use_meta]->name);
|
||||
g_string_append (s, key_conv_tab_sorted[idx]->name);
|
||||
g_string_append_c (s, '-');
|
||||
}
|
||||
}
|
||||
@ -1607,8 +1603,7 @@ lookup_key_by_code (const int keycode)
|
||||
|
||||
if (lookup_keycode (KEY_M_CTRL, &idx))
|
||||
{
|
||||
use_ctrl = idx;
|
||||
g_string_append (s, key_conv_tab_sorted[use_ctrl]->name);
|
||||
g_string_append (s, key_conv_tab_sorted[idx]->name);
|
||||
g_string_append_c (s, '-');
|
||||
}
|
||||
}
|
||||
@ -1616,12 +1611,11 @@ lookup_key_by_code (const int keycode)
|
||||
{
|
||||
if (lookup_keycode (KEY_M_ALT, &idx))
|
||||
{
|
||||
use_shift = idx;
|
||||
if (k < 127)
|
||||
g_string_append_c (s, (gchar) g_ascii_toupper ((gchar) k));
|
||||
else
|
||||
{
|
||||
g_string_append (s, key_conv_tab_sorted[use_shift]->name);
|
||||
g_string_append (s, key_conv_tab_sorted[idx]->name);
|
||||
g_string_append_c (s, '-');
|
||||
g_string_append (s, key_conv_tab_sorted[key_idx]->name);
|
||||
}
|
||||
|
@ -185,8 +185,12 @@ mc_XOpenDisplay (const char *displayname)
|
||||
{
|
||||
Display *retval;
|
||||
|
||||
/* cppcheck-suppress redundantAssignment */
|
||||
longjmp_allowed = TRUE;
|
||||
|
||||
retval = func_XOpenDisplay (displayname);
|
||||
|
||||
/* cppcheck-suppress redundantAssignment */
|
||||
longjmp_allowed = FALSE;
|
||||
return retval;
|
||||
}
|
||||
@ -205,9 +209,14 @@ mc_XCloseDisplay (Display * display)
|
||||
{
|
||||
int retval;
|
||||
|
||||
/* cppcheck-suppress redundantAssignment */
|
||||
longjmp_allowed = TRUE;
|
||||
|
||||
retval = func_XCloseDisplay (display);
|
||||
|
||||
/* cppcheck-suppress redundantAssignment */
|
||||
longjmp_allowed = FALSE;
|
||||
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
@ -227,11 +236,16 @@ mc_XQueryPointer (Display * display, Window win, Window * root_return,
|
||||
{
|
||||
if (setjmp (x11_exception) == 0)
|
||||
{
|
||||
/* cppcheck-suppress redundantAssignment */
|
||||
longjmp_allowed = TRUE;
|
||||
|
||||
retval = func_XQueryPointer (display, win, root_return,
|
||||
child_return, root_x_return, root_y_return,
|
||||
win_x_return, win_y_return, mask_return);
|
||||
|
||||
/* cppcheck-suppress redundantAssignment */
|
||||
longjmp_allowed = FALSE;
|
||||
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
|
@ -207,7 +207,10 @@ mc_util_write_backup_content (const char *from_file_name, const char *to_file_na
|
||||
ret1 = FALSE;
|
||||
{
|
||||
int ret2;
|
||||
|
||||
/* cppcheck-suppress redundantAssignment */
|
||||
ret2 = fflush (backup_fd);
|
||||
/* cppcheck-suppress redundantAssignment */
|
||||
ret2 = fclose (backup_fd);
|
||||
(void) ret2;
|
||||
}
|
||||
|
@ -245,7 +245,6 @@ vfs_s_find_entry_linear (struct vfs_class *me, struct vfs_s_inode *root,
|
||||
{
|
||||
struct vfs_s_entry *ent = NULL;
|
||||
char *const path = g_strdup (a_path);
|
||||
struct vfs_s_entry *retval = NULL;
|
||||
GList *iter;
|
||||
|
||||
if (root->super->root != root)
|
||||
@ -262,11 +261,11 @@ vfs_s_find_entry_linear (struct vfs_class *me, struct vfs_s_inode *root,
|
||||
dirname = g_path_get_dirname (path);
|
||||
name = g_path_get_basename (path);
|
||||
ino = vfs_s_find_inode (me, root->super, dirname, follow, flags | FL_DIR);
|
||||
retval = vfs_s_find_entry_tree (me, ino, name, follow, flags);
|
||||
ent = vfs_s_find_entry_tree (me, ino, name, follow, flags);
|
||||
g_free (dirname);
|
||||
g_free (name);
|
||||
g_free (path);
|
||||
return retval;
|
||||
return ent;
|
||||
}
|
||||
|
||||
iter = g_list_find_custom (root->subdir, path, (GCompareFunc) vfs_s_entry_compare);
|
||||
|
@ -80,7 +80,7 @@ static vfs_path_t *
|
||||
mc_def_getlocalcopy (const vfs_path_t * filename_vpath)
|
||||
{
|
||||
vfs_path_t *tmp_vpath = NULL;
|
||||
int fdin = -1, fdout = -1;
|
||||
int fdin, fdout = -1;
|
||||
ssize_t i;
|
||||
char buffer[BUF_1K * 8];
|
||||
struct stat mystat;
|
||||
|
@ -213,6 +213,7 @@ is_year (char *str, struct tm *tim)
|
||||
if (strlen (str) != 4)
|
||||
return 0;
|
||||
|
||||
/* cppcheck-suppress invalidscanf */
|
||||
if (sscanf (str, "%ld", &year) != 1)
|
||||
return 0;
|
||||
|
||||
@ -570,6 +571,7 @@ vfs_parse_filedate (int idx, time_t * t)
|
||||
{
|
||||
p[2] = p[5] = '-';
|
||||
|
||||
/* cppcheck-suppress invalidscanf */
|
||||
if (sscanf (p, "%2d-%2d-%d", &d[0], &d[1], &d[2]) == 3)
|
||||
{
|
||||
/* Months are zero based */
|
||||
@ -755,14 +757,17 @@ vfs_parse_ls_lga (const char *p, struct stat * s, char **filename, char **linkna
|
||||
/* Corner case: there is no whitespace(s) between maj & min */
|
||||
if (!is_num (idx2) && idx2 == 2)
|
||||
{
|
||||
/* cppcheck-suppress invalidscanf */
|
||||
if (!is_num (++idx2) || sscanf (columns[idx2], " %d,%d", &maj, &min) != 2)
|
||||
goto error;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* cppcheck-suppress invalidscanf */
|
||||
if (!is_num (idx2) || sscanf (columns[idx2], " %d,", &maj) != 1)
|
||||
goto error;
|
||||
|
||||
/* cppcheck-suppress invalidscanf */
|
||||
if (!is_num (++idx2) || sscanf (columns[idx2], " %d", &min) != 1)
|
||||
goto error;
|
||||
}
|
||||
|
@ -292,6 +292,7 @@ vfs_path_url_split (vfs_path_element_t * path_element, const char *path)
|
||||
if (colon != NULL)
|
||||
{
|
||||
*colon = '\0';
|
||||
/* cppcheck-suppress invalidscanf */
|
||||
if (sscanf (colon + 1, "%d", &path_element->port) == 1)
|
||||
{
|
||||
if (path_element->port <= 0 || path_element->port >= 65536)
|
||||
|
@ -319,6 +319,7 @@ vfs_url_split (const char *path, int default_port, vfs_url_flags_t flags)
|
||||
if (colon != NULL)
|
||||
{
|
||||
*colon = '\0';
|
||||
/* cppcheck-suppress invalidscanf */
|
||||
if (sscanf (colon + 1, "%d", &path_element->port) == 1)
|
||||
{
|
||||
if (path_element->port <= 0 || path_element->port >= 65536)
|
||||
|
@ -520,6 +520,7 @@ dlg_key_event (WDialog * h, int d_key)
|
||||
if (handled == MSG_NOT_HANDLED)
|
||||
handled = dlg_handle_key (h, d_key);
|
||||
|
||||
(void) handled;
|
||||
send_message (h, NULL, MSG_POST_KEY, d_key, NULL);
|
||||
}
|
||||
|
||||
|
@ -946,6 +946,7 @@ try_complete_all_possible (try_complete_automation_state_t * state, char *text,
|
||||
char *s;
|
||||
|
||||
s = strchr (cdpath, ':');
|
||||
/* cppcheck-suppress nullPointer */
|
||||
if (s == NULL)
|
||||
s = strchr (cdpath, '\0');
|
||||
c = *s;
|
||||
|
@ -508,7 +508,6 @@ configure_box (void)
|
||||
#endif
|
||||
|
||||
if (quick_dialog (&qdlg) == B_ENTER)
|
||||
/* cppcheck-suppress uninitvar */
|
||||
old_esc_mode_timeout = atoi (time_out_new);
|
||||
|
||||
g_free (time_out_new);
|
||||
|
Loading…
Reference in New Issue
Block a user