Skip to contentSkip to conversation

erec: Make error messages in nft consistent

PATCH Superseded Elise Lennion 1 participant 2 messages Nov 16, 2016 netfilter

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 erec: Make error messages in nft consistent

Error messages in nft from parser_bison should state "syntax error" to keep consistency. A new error type was defined to include this message.

---
 include/erec.h     | 5 ++++-
 src/erec.c         | 3 ++-
 src/parser_bison.y | 2 +-
 3 files changed, 7 insertions(+), 3 deletions(-)
include/erec.h +4 -1
index 36e0efa..8fee151 100644
@@ -15,6 +15,7 @@ enum error_record_types {
 	EREC_INFORMATIONAL,
 	EREC_WARNING,
 	EREC_ERROR,
+	EREC_SYNTAX_ERROR,
 };
 
 #define EREC_MSGBUFSIZE		1024
@@ -47,8 +48,10 @@ extern struct error_record *erec_create(enum error_record_types type,
 extern void erec_add_location(struct error_record *erec,
 			      const struct location *loc);
 
-#define error(loc, fmt, args...) \
+#define __error(loc, fmt, args...) \
 	erec_create(EREC_ERROR, (loc), (fmt), ## args)
+#define error(loc, fmt, args...) \
+	erec_create(EREC_SYNTAX_ERROR, (loc), (fmt), ## args)
 #define warning(loc, fmt, args...) \
 	erec_create(EREC_WARNING, (loc), (fmt), ## args)
 
src/erec.c +2 -1
index 3603216..9f01238 100644
@@ -30,7 +30,8 @@ const struct location internal_location = {
 static const char *error_record_names[] = {
 	[EREC_INFORMATIONAL]	= NULL,
 	[EREC_WARNING]		= "Warning",
-	[EREC_ERROR]		= "Error"
+	[EREC_ERROR]		= "Error",
+	[EREC_SYNTAX_ERROR]     = "Error: syntax error"
 };
 
 void erec_add_location(struct error_record *erec, const struct location *loc)
src/parser_bison.y +1 -1
index 91955c1..58385fa 100644
@@ -47,7 +47,7 @@ void parser_init(struct parser_state *state, struct list_head *msgs)
 static void yyerror(struct location *loc, void *scanner,
 		    struct parser_state *state, const char *s)
 {
-	erec_queue(error(loc, "%s", s), state->msgs);
+	erec_queue(__error(loc, "%s", s), state->msgs);
 }
 
 static struct scope *current_scope(const struct parser_state *state)
Signature · 1 line
2.7.4
#1 lore raw
Quoted 64 lines · Elise Lennion

Error messages in nft from parser_bison should state "syntax error" to keep consistency. A new error type was defined to include this message.

---
 include/erec.h     | 5 ++++-
 src/erec.c         | 3 ++-
 src/parser_bison.y | 2 +-
 3 files changed, 7 insertions(+), 3 deletions(-)
include/erec.h +4 -1
index 36e0efa..8fee151 100644
@@ -15,6 +15,7 @@ enum error_record_types {
 	EREC_INFORMATIONAL,
 	EREC_WARNING,
 	EREC_ERROR,
+	EREC_SYNTAX_ERROR,
 };
 
 #define EREC_MSGBUFSIZE		1024
@@ -47,8 +48,10 @@ extern struct error_record *erec_create(enum error_record_types type,
 extern void erec_add_location(struct error_record *erec,
 			      const struct location *loc);
 
-#define error(loc, fmt, args...) \
+#define __error(loc, fmt, args...) \
 	erec_create(EREC_ERROR, (loc), (fmt), ## args)
+#define error(loc, fmt, args...) \
+	erec_create(EREC_SYNTAX_ERROR, (loc), (fmt), ## args)
 #define warning(loc, fmt, args...) \
 	erec_create(EREC_WARNING, (loc), (fmt), ## args)
 
src/erec.c +2 -1
index 3603216..9f01238 100644
@@ -30,7 +30,8 @@ const struct location internal_location = {
 static const char *error_record_names[] = {
 	[EREC_INFORMATIONAL]	= NULL,
 	[EREC_WARNING]		= "Warning",
-	[EREC_ERROR]		= "Error"
+	[EREC_ERROR]		= "Error",
+	[EREC_SYNTAX_ERROR]     = "Error: syntax error"
 };
 
 void erec_add_location(struct error_record *erec, const struct location *loc)
src/parser_bison.y +1 -1
index 91955c1..58385fa 100644
@@ -47,7 +47,7 @@ void parser_init(struct parser_state *state, struct list_head *msgs)
 static void yyerror(struct location *loc, void *scanner,
 		    struct parser_state *state, const char *s)
 {
-	erec_queue(error(loc, "%s", s), state->msgs);
+	erec_queue(__error(loc, "%s", s), state->msgs);
 }
 
 static struct scope *current_scope(const struct parser_state *state)
Signature · 1 line
2.7.4

Please ignore this patch, I'll send a v3 where the changes in different files are separated.

elise