Patchwork [02/10] mtd_debug: replace #defines with enum

login
register
mail settings
Submitter Brian Norris
Date Aug. 19, 2011, 5:07 p.m.
Message ID <1313773676-12879-3-git-send-email-computersforpeace@gmail.com>
Download mbox | patch
Permalink /patch/110698/
State New
Headers show

Comments

Brian Norris - Aug. 19, 2011, 5:07 p.m.
enum provides a cleaner mechanism that creating single-purpose `#define`s.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
 mtd_debug.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

Patch

diff --git a/mtd_debug.c b/mtd_debug.c
index a348a4c..b98de50 100644
--- a/mtd_debug.c
+++ b/mtd_debug.c
@@ -342,16 +342,18 @@  void showusage(void)
 	exit(EXIT_FAILURE);
 }
 
-#define OPT_INFO	1
-#define OPT_READ	2
-#define OPT_WRITE	3
-#define OPT_ERASE	4
-
 int main(int argc, char *argv[])
 {
-	int err = 0, fd, option = OPT_INFO;
+	int err = 0, fd;
 	int open_flag;
 
+	enum {
+		OPT_INFO,
+		OPT_READ,
+		OPT_WRITE,
+		OPT_ERASE
+	} option = OPT_INFO;
+
 	/* parse command-line options */
 	if (argc == 3 && !strcmp(argv[1], "info"))
 		option = OPT_INFO;