util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] lsblk: remove __NCOLUMNS
@ 2011-10-26 13:58 Davidlohr Bueso
  2011-11-02 15:20 ` Karel Zak
  0 siblings, 1 reply; 2+ messages in thread
From: Davidlohr Bueso @ 2011-10-26 13:58 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>
---
 misc-utils/lsblk.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c
index 74a1850..24e0d05 100644
--- a/misc-utils/lsblk.c
+++ b/misc-utils/lsblk.c
@@ -88,8 +88,6 @@ enum {
 	COL_DGRAN,
 	COL_DMAX,
 	COL_DZERO,
-
-	__NCOLUMNS
 };
 
 /* column names */
@@ -101,7 +99,7 @@ struct colinfo {
 };
 
 /* columns descriptions */
-static struct colinfo infos[__NCOLUMNS] = {
+static struct colinfo infos[] = {
 	[COL_NAME]   = { "NAME",    0.25, TT_FL_TREE, N_("device name") },
 	[COL_KNAME]  = { "KNAME",   0.3, 0, N_("internal kernel device name") },
 	[COL_MAJMIN] = { "MAJ:MIN", 6, 0, N_("major:minor device number") },
@@ -140,7 +138,9 @@ struct lsblk {
 };
 
 struct lsblk *lsblk;	/* global handler */
-int columns[__NCOLUMNS];/* enabled columns */
+
+#define NCOLS ARRAY_SIZE(infos)
+int columns[NCOLS];/* enabled columns */
 int ncolumns;		/* number of enabled columns */
 
 int excludes[256];
@@ -190,9 +190,9 @@ static int is_maj_excluded(int maj)
 /* array with IDs of enabled columns */
 static 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];
 }
 
@@ -205,7 +205,7 @@ static int column_name_to_id(const char *name, size_t namesz)
 {
 	int i;
 
-	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))
@@ -933,7 +933,7 @@ static void __attribute__((__noreturn__)) help(FILE *out)
 
 	fprintf(out, _("\nAvailable columns:\n"));
 
-	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 lsblk(8).\n"));
-- 
1.7.7




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

* Re: [PATCH 2/2] lsblk: remove __NCOLUMNS
  2011-10-26 13:58 [PATCH 2/2] lsblk: remove __NCOLUMNS Davidlohr Bueso
@ 2011-11-02 15:20 ` Karel Zak
  0 siblings, 0 replies; 2+ messages in thread
From: Karel Zak @ 2011-11-02 15:20 UTC (permalink / raw)
  To: Davidlohr Bueso; +Cc: util-linux

On Wed, Oct 26, 2011 at 03:58:18PM +0200, Davidlohr Bueso wrote:
>  misc-utils/lsblk.c |   16 ++++++++--------
>  1 files changed, 8 insertions(+), 8 deletions(-)

 Applied, thanks.

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

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

end of thread, other threads:[~2011-11-02 15:20 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:58 [PATCH 2/2] lsblk: remove __NCOLUMNS Davidlohr Bueso
2011-11-02 15:20 ` 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).