]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
partx: remove __NCOLUMNS
authorDavidlohr Bueso <dave@gnu.org>
Wed, 26 Oct 2011 13:57:38 +0000 (15:57 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 2 Nov 2011 15:17:19 +0000 (16:17 +0100)
We use ARRAY_SIZE() instead to define the amount of available columns.

[kzak@redhat.com: - fix compiler warnings [-Wsign-compare]]

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
partx/partx.c

index bf18a4ebe491c30329b038df70c4c156624d1cc4..47cc65a25a2729f3b5385c60473781b2021bb67e 100644 (file)
@@ -49,7 +49,6 @@ enum {
        COL_TYPE,
        COL_FLAGS,
        COL_SCHEME,
-       __NCOLUMNS
 };
 
 enum {
@@ -72,7 +71,7 @@ struct colinfo {
 };
 
 /* columns descriptions */
-struct colinfo infos[__NCOLUMNS] = {
+struct colinfo infos[] = {
        [COL_PARTNO]   = { "NR",    0.25, TT_FL_RIGHT, N_("partition number") },
        [COL_START]    = { "START",   0.30, TT_FL_RIGHT, N_("start of the partition in sectors") },
        [COL_END]      = { "END",     0.30, TT_FL_RIGHT, N_("end of the partition in sectors") },
@@ -84,8 +83,11 @@ struct colinfo infos[__NCOLUMNS] = {
        [COL_FLAGS]    = { "FLAGS",   0.1, TT_FL_TRUNC, N_("partition flags")},
        [COL_TYPE]     = { "TYPE",    1, TT_FL_RIGHT, N_("partition type hex or uuid")},
 };
+
+#define NCOLS ARRAY_SIZE(infos)
+
 /* array with IDs of enabled columns */
-static int columns[__NCOLUMNS], ncolumns;
+static int columns[NCOLS], ncolumns;
 
 static int verbose;
 static int partx_flags;
@@ -137,9 +139,9 @@ static void assoc_loopdev(const char *fname)
 
 static inline int get_column_id(int num)
 {
-       assert(ARRAY_SIZE(columns) == __NCOLUMNS);
+       assert(ARRAY_SIZE(columns) == NCOLS);
        assert(num < ncolumns);
-       assert(columns[num] < __NCOLUMNS);
+       assert(columns[num] < (int) NCOLS);
        return columns[num];
 }
 
@@ -150,11 +152,11 @@ static inline struct colinfo *get_column_info(int num)
 
 static int column_name_to_id(const char *name, size_t namesz)
 {
-       int i;
+       size_t i;
 
        assert(name);
 
-       for (i = 0; i < __NCOLUMNS; i++) {
+       for (i = 0; i < NCOLS; i++) {
                const char *cn = infos[i].name;
 
                if (!strncasecmp(name, cn, namesz) && !*(cn + namesz))
@@ -600,7 +602,7 @@ static blkid_partlist get_partlist(blkid_probe pr,
 
 static void __attribute__((__noreturn__)) usage(FILE *out)
 {
-       int i;
+       size_t i;
 
        fputs(_("\nUsage:\n"), out);
        fprintf(out,
@@ -624,7 +626,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out)
 
        fputs(_("\nAvailable columns (for --show, --raw or --pairs):\n"), out);
 
-       for (i = 0; i < __NCOLUMNS; i++)
+       for (i = 0; i < NCOLS; i++)
                fprintf(out, " %10s  %s\n", infos[i].name, _(infos[i].help));
 
        fprintf(out, _("\nFor more information see partx(8).\n"));