util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] partx: remove __NCOLUMNS
@ 2011-10-26 13:57 Davidlohr Bueso
  2011-11-02 15:19 ` Karel Zak
  0 siblings, 1 reply; 2+ messages in thread
From: Davidlohr Bueso @ 2011-10-26 13:57 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux

From: Davidlohr Bueso <dave@gnu.org>

We use ARRAY_SIZE() instead to define the amount of available columns.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
---
 partx/partx.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/partx/partx.c b/partx/partx.c
index bf18a4e..b12eebc 100644
--- a/partx/partx.c
+++ b/partx/partx.c
@@ -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] < NCOLS);
 	return columns[num];
 }
 
@@ -154,7 +156,7 @@ static int column_name_to_id(const char *name, size_t namesz)
 
 	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))
@@ -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"));
-- 
1.7.7




^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-11-02 15:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-26 13:57 [PATCH 1/2] partx: remove __NCOLUMNS Davidlohr Bueso
2011-11-02 15:19 ` Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).