Use bit-field members of file_entry_t as integers explicitly.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2023-04-16 12:06:20 +03:00
parent 7f30f8c692
commit 044c035900
13 changed files with 28 additions and 30 deletions

View File

@ -100,7 +100,7 @@ mc_fhl_is_hlink (const file_entry_t * fe)
inline static gboolean
mc_fhl_is_link_to_dir (const file_entry_t * fe)
{
return mc_fhl_is_link (fe) && fe->f.link_to_dir;
return mc_fhl_is_link (fe) && fe->f.link_to_dir != 0;
}
/* --------------------------------------------------------------------------------------------- */
@ -108,7 +108,7 @@ mc_fhl_is_link_to_dir (const file_entry_t * fe)
inline static gboolean
mc_fhl_is_stale_link (const file_entry_t * fe)
{
return mc_fhl_is_link (fe) ? fe->f.stale_link : !mc_fhl_is_file (fe);
return mc_fhl_is_link (fe) ? (fe->f.stale_link != 0) : !mc_fhl_is_file (fe);
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -835,7 +835,7 @@ advanced_chown_done (gboolean need_update)
static const GString *
next_file (const WPanel * panel)
{
while (!panel->dir.list[current_file].f.marked)
while (panel->dir.list[current_file].f.marked == 0)
current_file++;
return panel->dir.list[current_file].fname;

View File

@ -1097,7 +1097,7 @@ chattr_done (gboolean need_update)
static const GString *
next_file (const WPanel * panel)
{
while (!panel->dir.list[current_file].f.marked)
while (panel->dir.list[current_file].f.marked == 0)
current_file++;
return panel->dir.list[current_file].fname;

View File

@ -415,7 +415,7 @@ chmod_done (gboolean need_update)
static const GString *
next_file (const WPanel * panel)
{
while (!panel->dir.list[current_file].f.marked)
while (panel->dir.list[current_file].f.marked == 0)
current_file++;
return panel->dir.list[current_file].fname;

View File

@ -287,7 +287,7 @@ chown_done (gboolean need_update)
static const GString *
next_file (const WPanel * panel)
{
while (!panel->dir.list[current_file].f.marked)
while (panel->dir.list[current_file].f.marked == 0)
current_file++;
return panel->dir.list[current_file].fname;

View File

@ -1316,7 +1316,7 @@ dirsizes_cmd (WPanel * panel)
for (i = 0; i < panel->dir.len; i++)
if (S_ISDIR (panel->dir.list[i].st.st_mode)
&& ((panel->dirs_marked != 0 && panel->dir.list[i].f.marked)
&& ((panel->dirs_marked != 0 && panel->dir.list[i].f.marked != 0)
|| panel->dirs_marked == 0) && !DIR_IS_DOTDOT (panel->dir.list[i].fname->str))
{
vfs_path_t *p;

View File

@ -744,7 +744,7 @@ dir_list_reload (dir_list * list, const vfs_path_t * vpath, GCompareFunc sort,
dfentry->f.stale_link = fentry->f.stale_link;
dfentry->name_sort_key = NULL;
dfentry->extension_sort_key = NULL;
if (fentry->f.marked)
if (fentry->f.marked != 0)
{
g_hash_table_insert (marked_files, dfentry->fname->str, dfentry);
marked_cnt++;
@ -805,8 +805,8 @@ dir_list_reload (dir_list * list, const vfs_path_t * vpath, GCompareFunc sort,
* we copied one.
*/
fentry->f.marked = (marked_cnt > 0
&& g_hash_table_lookup (marked_files, dp->d_name) != NULL);
if (fentry->f.marked)
&& g_hash_table_lookup (marked_files, dp->d_name) != NULL) ? 1 : 0;
if (fentry->f.marked != 0)
marked_cnt--;
}
}

View File

@ -109,7 +109,7 @@ void file_filter_clear (file_filter_t * filter);
static inline gboolean
link_isdir (const file_entry_t * file)
{
return (gboolean) file->f.link_to_dir;
return (file->f.link_to_dir != 0);
}
#endif /* MC__DIR_H */

View File

@ -1793,7 +1793,7 @@ panel_get_file (const WPanel * panel)
int i;
for (i = 0; i < panel->dir.len; i++)
if (panel->dir.list[i].f.marked)
if (panel->dir.list[i].f.marked != 0)
return panel->dir.list[i].fname->str;
}
@ -3462,7 +3462,7 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
{
const char *source2;
if (!panel->dir.list[i].f.marked)
if (panel->dir.list[i].f.marked == 0)
continue; /* Skip the unmarked ones */
source2 = panel->dir.list[i].fname->str;

View File

@ -805,10 +805,8 @@ put_tagged (WPanel * panel)
int i;
for (i = 0; i < panel->dir.len; i++)
{
if (panel->dir.list[i].f.marked)
if (panel->dir.list[i].f.marked != 0)
command_insert (cmdline, panel->dir.list[i].fname->str, TRUE);
}
}
else
command_insert (cmdline, panel_current_entry (panel)->fname->str, TRUE);

View File

@ -589,7 +589,7 @@ string_file_type (file_entry_t * fe, int len)
{
if (link_isdir (fe))
buffer[0] = '~';
else if (fe->f.stale_link)
else if (fe->f.stale_link != 0)
buffer[0] = '!';
else
buffer[0] = '@';
@ -760,7 +760,7 @@ string_marked (file_entry_t * fe, int len)
{
(void) len;
return fe->f.marked ? "*" : " ";
return fe->f.marked != 0 ? "*" : " ";
}
/* --------------------------------------------------------------------------------------------- */
@ -2102,7 +2102,7 @@ static inline void
unselect_item (WPanel * panel)
{
repaint_file (panel, panel->current,
panel_current_entry (panel)->f.marked ? FATTR_MARKED : FATTR_NORMAL);
panel_current_entry (panel)->f.marked != 0 ? FATTR_MARKED : FATTR_NORMAL);
}
/* --------------------------------------------------------------------------------------------- */
@ -2124,7 +2124,7 @@ panel_select_ext_cmd (WPanel * panel)
if (filename == NULL)
return;
do_select = !fe->f.marked;
do_select = (fe->f.marked == 0);
cur_file_ext = strutils_regex_escape (extension (filename->str));
if (cur_file_ext[0] != '\0')
@ -3866,7 +3866,7 @@ static void
mouse_toggle_mark (WPanel * panel)
{
do_mark_file (panel, MARK_DONT_MOVE);
mouse_marking = panel_current_entry (panel)->f.marked;
mouse_marking = (panel_current_entry (panel)->f.marked != 0);
mouse_mark_panel = current_panel;
}
@ -3881,9 +3881,9 @@ mouse_set_mark (WPanel * panel)
fe = panel_current_entry (panel);
if (mouse_marking && !fe->f.marked)
if (mouse_marking && fe->f.marked == 0)
do_mark_file (panel, MARK_DONT_MOVE);
else if (!mouse_marking && fe->f.marked)
else if (!mouse_marking && fe->f.marked != 0)
do_mark_file (panel, MARK_DONT_MOVE);
}
}
@ -4783,7 +4783,7 @@ recalculate_panel_summary (WPanel * panel)
panel->total = 0;
for (i = 0; i < panel->dir.len; i++)
if (panel->dir.list[i].f.marked)
if (panel->dir.list[i].f.marked != 0)
{
/* do_file_mark will return immediately if newmark == oldmark.
So we have to first unmark it to get panel's summary information
@ -4807,13 +4807,13 @@ do_file_mark (WPanel * panel, int idx, int mark)
return;
file_mark (panel, idx, mark);
if (panel->dir.list[idx].f.marked)
if (panel->dir.list[idx].f.marked != 0)
{
panel->marked++;
if (S_ISDIR (panel->dir.list[idx].st.st_mode))
{
if (panel->dir.list[idx].f.dir_size_computed)
if (panel->dir.list[idx].f.dir_size_computed != 0)
panel->total += (uintmax_t) panel->dir.list[idx].st.st_size;
panel->dirs_marked++;
}
@ -4826,7 +4826,7 @@ do_file_mark (WPanel * panel, int idx, int mark)
{
if (S_ISDIR (panel->dir.list[idx].st.st_mode))
{
if (panel->dir.list[idx].f.dir_size_computed)
if (panel->dir.list[idx].f.dir_size_computed != 0)
panel->total -= (uintmax_t) panel->dir.list[idx].st.st_size;
panel->dirs_marked--;
}

View File

@ -926,7 +926,7 @@ expand_format (const Widget * edit_widget, char c, gboolean do_quote)
block = g_string_sized_new (16);
for (i = 0; i < panel->dir.len; i++)
if (panel->dir.list[i].f.marked)
if (panel->dir.list[i].f.marked != 0)
{
char *tmp;

View File

@ -80,9 +80,9 @@ START_TEST (sanitize_variables)
current_panel->dir.len = 3;
current_panel->dir.list[0].fname = g_string_new ("selected file.txt");
current_panel->dir.list[1].fname = g_string_new ("tagged file1.txt");
current_panel->dir.list[1].f.marked = TRUE;
current_panel->dir.list[1].f.marked = 1;
current_panel->dir.list[2].fname = g_string_new ("tagged file2.txt");
current_panel->dir.list[2].f.marked = TRUE;
current_panel->dir.list[2].f.marked = 1;
/* when */
filename_vpath = vfs_path_from_str ("/tmp/blabla.txt");