public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: Sami Kerola <kerolasa@iki.fi>
To: util-linux@vger.kernel.org
Cc: kerolasa@iki.fi
Subject: [PATCH 11/12] setterm: convert various constant number definitions to enums
Date: Sun, 11 May 2014 20:26:48 +0100	[thread overview]
Message-ID: <1399836409-7769-11-git-send-email-kerolasa@iki.fi> (raw)
In-Reply-To: <1399836409-7769-1-git-send-email-kerolasa@iki.fi>

The enum strings are visible when using debugger.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 term-utils/setterm.c | 46 ++++++++++++++++++++++++++--------------------
 1 file changed, 26 insertions(+), 20 deletions(-)

diff --git a/term-utils/setterm.c b/term-utils/setterm.c
index ef820b3..2de555e 100644
--- a/term-utils/setterm.c
+++ b/term-utils/setterm.c
@@ -141,28 +141,34 @@ extern int klogctl(int type, char *buf, int len);
 #define EXIT_DUMPFILE	-1
 
 /* Colors. */
-#define BLACK   0
-#define RED     1
-#define GREEN   2
-#define YELLOW  3
-#define BLUE    4
-#define MAGENTA 5
-#define CYAN    6
-#define WHITE   7
-#define GREY	8
-#define DEFAULT 9
+enum {
+	BLACK = 0,
+	RED,
+	GREEN,
+	YELLOW,
+	BLUE,
+	MAGENTA,
+	CYAN,
+	WHITE,
+	GREY,
+	DEFAULT
+};
 
 /* Blank commands */
-#define BLANKSCREEN	-1
-#define UNBLANKSCREEN	-2
-#define BLANKEDSCREEN	-3
+enum {
+	BLANKSCREEN	= -1,
+	UNBLANKSCREEN	= -2,
+	BLANKEDSCREEN	= -3
+};
 
 /* <linux/tiocl.h> fallback */
 #ifndef TIOCL_BLANKSCREEN
-# define TIOCL_UNBLANKSCREEN	4       /* unblank screen */
-# define TIOCL_SETVESABLANK	10      /* set vesa blanking mode */
-# define TIOCL_BLANKSCREEN	14	/* keep screen blank even if a key is pressed */
-# define TIOCL_BLANKEDSCREEN	15	/* return which vt was blanked */
+enum {
+	TIOCL_UNBLANKSCREEN	=  4,	/* unblank screen */
+	TIOCL_SETVESABLANK	= 10,	/* set vesa blanking mode */
+	TIOCL_BLANKSCREEN	= 14,	/* keep screen blank even if a key is pressed */
+	TIOCL_BLANKEDSCREEN	= 15	/* return which vt was blanked */
+};
 #endif
 
 /* Static variables. */
@@ -298,7 +304,7 @@ par_color(int argc, char **argv, int *option, int *opt_color, int *bad_arg) {
 		else
 			*bad_arg = TRUE;
 
-		if(*opt_color < 0 || *opt_color > 9 || *opt_color == 8)
+		if(*opt_color < BLACK || DEFAULT < *opt_color || *opt_color == GREY)
 			*bad_arg = TRUE;
 	}
 }
@@ -319,7 +325,7 @@ par_color2(int argc, char **argv, int *option, int *opt_color, int *bad_arg) {
 	*opt_color = 0;
 	if (argc == 2) {
 		if (strcmp(argv[0], "bright") == 0)
-			*opt_color = 8;
+			*opt_color = GREY;
 		else {
 			*bad_arg = TRUE;
 			return;
@@ -354,7 +360,7 @@ par_color2(int argc, char **argv, int *option, int *opt_color, int *bad_arg) {
 			*opt_color = atoi(argv[argc-1]);
 		else
 			*bad_arg = TRUE;
-		if(*opt_color < 0 || *opt_color > 15)
+		if(*opt_color < BLACK || DEFAULT < *opt_color )
 			*bad_arg = TRUE;
 	}
 }
-- 
1.9.2


  parent reply	other threads:[~2014-05-11 19:27 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-11 19:26 [PATCH 01/12] tests: check /proc availability, and go-around if it is incomplete Sami Kerola
2014-05-11 19:26 ` [PATCH 02/12] cytune: remove from util-linux Sami Kerola
2014-05-12 12:11   ` Karel Zak
2014-05-11 19:26 ` [PATCH 03/12] blkid: remove unused variable Sami Kerola
2014-05-11 19:26 ` [PATCH 04/12] logger: fail when io vector number exceeds maximum Sami Kerola
2014-05-11 19:26 ` [PATCH 05/12] logger: check numeric priority and facility input values Sami Kerola
2014-05-11 19:26 ` [PATCH 06/12] build-sys: remove unnecessary void casts Sami Kerola
2014-05-11 19:26 ` [PATCH 07/12] term-utils: avoid error message string length couting errors Sami Kerola
2014-05-12 12:05   ` Karel Zak
2014-05-11 19:26 ` [PATCH 08/12] wall: replace magic number by named value Sami Kerola
2014-05-11 19:26 ` [PATCH 09/12] setterm: remove unused code Sami Kerola
2014-05-11 19:26 ` [PATCH 10/12] setterm: use string constant rather than #define Sami Kerola
2014-05-12 12:07   ` Karel Zak
2014-05-11 19:26 ` Sami Kerola [this message]
2014-05-11 19:26 ` [PATCH 12/12] setterm: convert remaining magic values to symbolic references Sami Kerola
2014-05-12 12:10   ` Karel Zak
2014-05-12 14:53     ` Sami Kerola
2014-05-12  7:05 ` [PATCH 01/12] tests: check /proc availability, and go-around if it is incomplete Bernhard Voelker
2014-05-12  9:13   ` Sami Kerola
2014-05-12 11:06   ` Karel Zak
2014-05-12 12:01 ` Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1399836409-7769-11-git-send-email-kerolasa@iki.fi \
    --to=kerolasa@iki.fi \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox