From: Tomohiro Kusumi Date: Mon, 23 Jan 2017 15:13:05 +0000 (+0900) Subject: Use ARRAY_SIZE() X-Git-Tag: fio-2.18~45 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=b920b29b99829221550e6620b7b699abdef1a712;hp=248c94366c4e5806d7356b50e39438b4ac32f8b8 Use ARRAY_SIZE() They can assume ARRAY_SIZE() is defined and usable as far as fio's internal code is concerned (i.e. FIO_INTERNAL defined). Signed-off-by: Tomohiro Kusumi Signed-off-by: Jens Axboe --- diff --git a/gclient.c b/gclient.c index 5ce33d0c..928a1b76 100644 --- a/gclient.c +++ b/gclient.c @@ -48,7 +48,7 @@ static GtkActionEntry results_menu_items[] = { { "PrintFile", GTK_STOCK_PRINT, "Print", "P", NULL, G_CALLBACK(results_print) }, { "CloseFile", GTK_STOCK_CLOSE, "Close", "W", NULL, G_CALLBACK(results_close) }, }; -static gint results_nmenu_items = sizeof(results_menu_items) / sizeof(results_menu_items[0]); +static gint results_nmenu_items = ARRAY_SIZE(results_menu_items); static const gchar *results_ui_string = " \ \ diff --git a/gfio.c b/gfio.c index 9ccf78c4..9c917cb6 100644 --- a/gfio.c +++ b/gfio.c @@ -1271,7 +1271,7 @@ static GtkActionEntry menu_items[] = { { "Quit", GTK_STOCK_QUIT, NULL, "Q", NULL, G_CALLBACK(quit_clicked) }, { "About", GTK_STOCK_ABOUT, NULL, NULL, NULL, G_CALLBACK(about_dialog) }, }; -static gint nmenu_items = sizeof(menu_items) / sizeof(menu_items[0]); +static gint nmenu_items = ARRAY_SIZE(menu_items); static const gchar *ui_string = " \ \ diff --git a/lib/num2str.c b/lib/num2str.c index 940d4a5e..ed3545d9 100644 --- a/lib/num2str.c +++ b/lib/num2str.c @@ -4,8 +4,6 @@ #include "../fio.h" -#define ARRAY_LENGTH(arr) sizeof(arr) / sizeof((arr)[0]) - /** * num2str() - Cheesy number->string conversion, complete with carry rounding error. * @num: quantity (e.g., number of blocks, bytes or bits) @@ -75,7 +73,7 @@ char *num2str(uint64_t num, int maxlen, int base, int pow2, int units) if (modulo == -1U) { done: - if (post_index >= ARRAY_LENGTH(sistr)) + if (post_index >= ARRAY_SIZE(sistr)) post_index = 0; sprintf(buf, "%llu%s%s", (unsigned long long) num,