Use ARRAY_SIZE()
authorTomohiro Kusumi <tkusumi@tuxera.com>
Mon, 23 Jan 2017 15:13:05 +0000 (00:13 +0900)
committerJens Axboe <axboe@fb.com>
Mon, 23 Jan 2017 15:26:12 +0000 (08:26 -0700)
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 <tkusumi@tuxera.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
gclient.c
gfio.c
lib/num2str.c

index 5ce33d0c56244cb55d5ea0716085b3b9a583951e..928a1b7641da2976c64c9709aaa7314030410a4f 100644 (file)
--- a/gclient.c
+++ b/gclient.c
@@ -48,7 +48,7 @@ static GtkActionEntry results_menu_items[] = {
        { "PrintFile", GTK_STOCK_PRINT, "Print", "<Control>P", NULL, G_CALLBACK(results_print) },
        { "CloseFile", GTK_STOCK_CLOSE, "Close", "<Control>W", NULL, G_CALLBACK(results_close) },
 };
        { "PrintFile", GTK_STOCK_PRINT, "Print", "<Control>P", NULL, G_CALLBACK(results_print) },
        { "CloseFile", GTK_STOCK_CLOSE, "Close", "<Control>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 = " \
        <ui> \
 
 static const gchar *results_ui_string = " \
        <ui> \
diff --git a/gfio.c b/gfio.c
index 9ccf78c423b22df655f874682918c0a2819a2f61..9c917cb6a955f167738fa5ab8dbbb32bf82a3703 100644 (file)
--- a/gfio.c
+++ b/gfio.c
@@ -1271,7 +1271,7 @@ static GtkActionEntry menu_items[] = {
        { "Quit", GTK_STOCK_QUIT, NULL,   "<Control>Q", NULL, G_CALLBACK(quit_clicked) },
        { "About", GTK_STOCK_ABOUT, NULL,  NULL, NULL, G_CALLBACK(about_dialog) },
 };
        { "Quit", GTK_STOCK_QUIT, NULL,   "<Control>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 = " \
        <ui> \
 
 static const gchar *ui_string = " \
        <ui> \
index 940d4a5e289133a03c89569dc3cca01a5e604b4c..ed3545d95634553640d3ccaf537e0e436d432ac2 100644 (file)
@@ -4,8 +4,6 @@
 
 #include "../fio.h"
 
 
 #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)
 /**
  * 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 (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,
                        post_index = 0;
 
                sprintf(buf, "%llu%s%s", (unsigned long long) num,