Skip to contentSkip to conversation

enums: remove trailing ',' after last item in enum

PATCH In review Ronnie Sahlberg 3 participants 4 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 enums: remove trailing ',' after last item in enum

---
 builtin/clean.c | 2 +-
 builtin/tag.c   | 2 +-
 pretty.c        | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
builtin/clean.c +1 -1
index 9a91515..27701d2 100644
@@ -48,7 +48,7 @@ enum color_clean {
 	CLEAN_COLOR_PROMPT = 2,
 	CLEAN_COLOR_HEADER = 3,
 	CLEAN_COLOR_HELP = 4,
-	CLEAN_COLOR_ERROR = 5,
+	CLEAN_COLOR_ERROR = 5
 };
 
 #define MENU_OPTS_SINGLETON		01
builtin/tag.c +1 -1
index c6e8a71..ef76556 100644
@@ -83,7 +83,7 @@ static int in_commit_list(const struct commit_list *want, struct commit *c)
 enum contains_result {
 	CONTAINS_UNKNOWN = -1,
 	CONTAINS_NO = 0,
-	CONTAINS_YES = 1,
+	CONTAINS_YES = 1
 };
 
 /*
pretty.c +1 -1
index 4f51287..924bc61 100644
@@ -274,7 +274,7 @@ static void add_rfc822_quoted(struct strbuf *out, const char *s, int len)
 
 enum rfc2047_type {
 	RFC2047_SUBJECT,
-	RFC2047_ADDRESS,
+	RFC2047_ADDRESS
 };
 
 static int is_rfc2047_special(char ch, enum rfc2047_type type)
Signature · 1 line
2.0.1.442.g7fe6834.dirty
#1 lore raw
Quoted 6 lines · Ronnie Sahlberg
---
 builtin/clean.c | 2 +-
 builtin/tag.c   | 2 +-
 pretty.c        | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

Is there some gcc option or other tool that can automatically detect this kind of problem so the regress/fix cycle doesn't have to repeat too many times?

Looks like v1.7.2-rc0~32^2~16 (2010-03-14) and v1.7.4.2~34 (2011-03-16) tried to fix this in the past.

Using the test from v1.7.4.2~34 also finds enums with trailing comma in

grep.h
log-tree.c

Thanks,
Jonathan

#2 lore raw

GCC can check/error for this with

--pedantic -Werror

Quoted 24 lines · Jonathan Nieder
Quoted 6 lines · Ronnie Sahlberg
---
 builtin/clean.c | 2 +-
 builtin/tag.c   | 2 +-
 pretty.c        | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

Is there some gcc option or other tool that can automatically detect this kind of problem so the regress/fix cycle doesn't have to repeat too many times?

Looks like v1.7.2-rc0~32^2~16 (2010-03-14) and v1.7.4.2~34 (2011-03-16) tried to fix this in the past.

Using the test from v1.7.4.2~34 also finds enums with trailing comma in

grep.h
log-tree.c

Thanks,
Jonathan

#3 lore raw
In reply to Ronnie Sahlberg
Quoted 2 lines · Ronnie Sahlberg

---

Looks good; thanks.

Quoted 44 lines
 builtin/clean.c | 2 +-
 builtin/tag.c   | 2 +-
 pretty.c        | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
builtin/clean.c +1 -1
index 9a91515..27701d2 100644
@@ -48,7 +48,7 @@ enum color_clean {
 	CLEAN_COLOR_PROMPT = 2,
 	CLEAN_COLOR_HEADER = 3,
 	CLEAN_COLOR_HELP = 4,
-	CLEAN_COLOR_ERROR = 5,
+	CLEAN_COLOR_ERROR = 5
 };
 
 #define MENU_OPTS_SINGLETON		01
builtin/tag.c +1 -1
index c6e8a71..ef76556 100644
@@ -83,7 +83,7 @@ static int in_commit_list(const struct commit_list *want, struct commit *c)
 enum contains_result {
 	CONTAINS_UNKNOWN = -1,
 	CONTAINS_NO = 0,
-	CONTAINS_YES = 1,
+	CONTAINS_YES = 1
 };
 
 /*
pretty.c +1 -1
index 4f51287..924bc61 100644
@@ -274,7 +274,7 @@ static void add_rfc822_quoted(struct strbuf *out, const char *s, int len)
 
 enum rfc2047_type {
 	RFC2047_SUBJECT,
-	RFC2047_ADDRESS,
+	RFC2047_ADDRESS
 };
 
 static int is_rfc2047_special(char ch, enum rfc2047_type type)