1
1

Use G_N_ELEMENTS macro to calculate of array size.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Этот коммит содержится в:
Andrew Borodin 2013-04-12 14:36:56 +04:00 коммит произвёл Slava Zanko
родитель 9f80eda26e
Коммит 31bacf56c9
6 изменённых файлов: 7 добавлений и 10 удалений

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

@ -306,7 +306,7 @@ mc_search_types_list_get (size_t * num)
{ {
/* don't count last NULL item */ /* don't count last NULL item */
if (num != NULL) if (num != NULL)
*num = sizeof (mc_search__list_types) / sizeof (mc_search__list_types[0]) - 1; *num = G_N_ELEMENTS (mc_search__list_types) - 1;
return mc_search__list_types; return mc_search__list_types;
} }

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

@ -271,7 +271,7 @@ edit_find_filter (const vfs_path_t * filename_vpath)
filename = vfs_path_to_str (filename_vpath); filename = vfs_path_to_str (filename_vpath);
l = strlen (filename); l = strlen (filename);
for (i = 0; i < sizeof (all_filters) / sizeof (all_filters[0]); i++) for (i = 0; i < G_N_ELEMENTS (all_filters); i++)
{ {
e = strlen (all_filters[i].extension); e = strlen (all_filters[i].extension);
if (l > e) if (l > e)

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

@ -1379,11 +1379,11 @@ panel_operate_generate_prompt (const WPanel * panel, FileOperation operation,
{ {
size_t i; size_t i;
for (i = sizeof (op_names1) / sizeof (op_names1[0]); i--;) for (i = G_N_ELEMENTS (op_names1); i-- != 0;)
op_names1[i] = Q_ (op_names1[i]); op_names1[i] = Q_ (op_names1[i]);
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
for (i = sizeof (prompt_parts) / sizeof (prompt_parts[0]); i--;) for (i = G_N_ELEMENTS (prompt_parts); i-- != 0;)
prompt_parts[i] = _(prompt_parts[i]); prompt_parts[i] = _(prompt_parts[i]);
one_format = _(one_format); one_format = _(one_format);
@ -2680,7 +2680,7 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
static gboolean i18n_flag = FALSE; static gboolean i18n_flag = FALSE;
if (!i18n_flag) if (!i18n_flag)
{ {
for (i = sizeof (op_names) / sizeof (op_names[0]); i--;) for (i = G_N_ELEMENTS (op_names); i-- != 0;)
op_names[i] = Q_ (op_names[i]); op_names[i] = Q_ (op_names[i]);
i18n_flag = TRUE; i18n_flag = TRUE;
} }

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

@ -313,8 +313,6 @@ extern int saving_setup;
/*** file scope macro definitions ****************************************************************/ /*** file scope macro definitions ****************************************************************/
#define ELEMENTS(arr) ( sizeof(arr) / sizeof((arr)[0]) )
#define NORMAL 0 #define NORMAL 0
#define SELECTED 1 #define SELECTED 1
#define MARKED 2 #define MARKED 2

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

@ -230,7 +230,7 @@ mcview_init (mcview_t * view)
view->search_end = 0; view->search_end = 0;
view->marker = 0; view->marker = 0;
for (i = 0; i < sizeof (view->marks) / sizeof (view->marks[0]); i++) for (i = 0; i < G_N_ELEMENTS (view->marks); i++)
view->marks[i] = 0; view->marks[i] = 0;
view->update_steps = 0; view->update_steps = 0;

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

@ -9,8 +9,7 @@
/*** typedefs(not structures) and defined constants **********************************************/ /*** typedefs(not structures) and defined constants **********************************************/
#define mctest_add_parameterized_test(tc_core, test_func, test_data_source) {\ #define mctest_add_parameterized_test(tc_core, test_func, test_data_source) {\
tcase_add_loop_test (tc_core, test_func, 0, \ tcase_add_loop_test (tc_core, test_func, 0, G_N_ELEMENTS (test_data_source)); \
sizeof (test_data_source) / sizeof (test_data_source[0])); \
} }
#define mctest_assert_str_eq(actual_result, etalon_result) { \ #define mctest_assert_str_eq(actual_result, etalon_result) { \