Sfoglia il codice sorgente

ncd: NCDConfig: remove some redundant error checking

ambrop7 13 anni fa
parent
commit
64d6913dec

+ 2 - 2
generated/NCDConfigParser_parse.c

@@ -811,7 +811,7 @@ static void yy_reduce(
       case 1: /* processes ::= process_or_template NAME CURLY_OPEN statements CURLY_CLOSE */
 #line 101 "NCDConfigParser_parse.y"
 {
-    yygotominor.yy45 = NCDConfig_make_processes(yymsp[-4].minor.yy46, yymsp[-3].minor.yy0.str, yymsp[-1].minor.yy16, 0, NULL);
+    yygotominor.yy45 = NCDConfig_make_processes(yymsp[-4].minor.yy46, yymsp[-3].minor.yy0.str, yymsp[-1].minor.yy16, NULL);
     if (!yygotominor.yy45) {
         parser_out->out_of_memory = 1;
     }
@@ -823,7 +823,7 @@ static void yy_reduce(
       case 2: /* processes ::= process_or_template NAME CURLY_OPEN statements CURLY_CLOSE processes */
 #line 108 "NCDConfigParser_parse.y"
 {
-    yygotominor.yy45 = NCDConfig_make_processes(yymsp[-5].minor.yy46, yymsp[-4].minor.yy0.str, yymsp[-2].minor.yy16, 1, yymsp[0].minor.yy45);
+    yygotominor.yy45 = NCDConfig_make_processes(yymsp[-5].minor.yy46, yymsp[-4].minor.yy0.str, yymsp[-2].minor.yy16, yymsp[0].minor.yy45);
     if (!yygotominor.yy45) {
         parser_out->out_of_memory = 1;
     }

+ 2 - 2
generated/NCDConfigParser_parse.y

@@ -99,14 +99,14 @@ input ::= processes(A). {
 }
 
 processes(R) ::= process_or_template(T) NAME(A) CURLY_OPEN statements(B) CURLY_CLOSE. {
-    R = NCDConfig_make_processes(T, A.str, B, 0, NULL);
+    R = NCDConfig_make_processes(T, A.str, B, NULL);
     if (!R) {
         parser_out->out_of_memory = 1;
     }
 }
 
 processes(R) ::= process_or_template(T) NAME(A) CURLY_OPEN statements(B) CURLY_CLOSE processes(N). {
-    R = NCDConfig_make_processes(T, A.str, B, 1, N);
+    R = NCDConfig_make_processes(T, A.str, B, N);
     if (!R) {
         parser_out->out_of_memory = 1;
     }

+ 1 - 5
ncd/NCDConfig.c

@@ -102,12 +102,8 @@ void NCDConfig_free_strings (struct NCDConfig_strings *v)
     free(v);
 }
 
-struct NCDConfig_processes * NCDConfig_make_processes (int is_template, char *name, struct NCDConfig_statements *statements, int need_next, struct NCDConfig_processes *next)
+struct NCDConfig_processes * NCDConfig_make_processes (int is_template, char *name, struct NCDConfig_statements *statements, struct NCDConfig_processes *next)
 {
-    if (!name || !statements || (need_next && !next)) {
-        goto fail;
-    }
-    
     struct NCDConfig_processes *v = malloc(sizeof(*v));
     if (!v) {
         goto fail;

+ 1 - 1
ncd/NCDConfig.h

@@ -79,7 +79,7 @@ void NCDConfig_free_processes (struct NCDConfig_processes *v);
 void NCDConfig_free_statements (struct NCDConfig_statements *v);
 void NCDConfig_free_list (struct NCDConfig_list *v);
 void NCDConfig_free_strings (struct NCDConfig_strings *v);
-struct NCDConfig_processes * NCDConfig_make_processes (int is_template, char *name, struct NCDConfig_statements *statements, int have_next, struct NCDConfig_processes *next);
+struct NCDConfig_processes * NCDConfig_make_processes (int is_template, char *name, struct NCDConfig_statements *statements, struct NCDConfig_processes *next);
 struct NCDConfig_statements * NCDConfig_make_statements (struct NCDConfig_strings *objname, struct NCDConfig_strings *names, struct NCDConfig_list *args, char *name, struct NCDConfig_statements *next);
 struct NCDConfig_list * NCDConfig_make_list_string (char *str, size_t len, struct NCDConfig_list *next);
 struct NCDConfig_list * NCDConfig_make_list_var (struct NCDConfig_strings *var, struct NCDConfig_list *next);

+ 2 - 2
ncd/NCDConfigParser_parse.y

@@ -99,14 +99,14 @@ input ::= processes(A). {
 }
 
 processes(R) ::= process_or_template(T) NAME(A) CURLY_OPEN statements(B) CURLY_CLOSE. {
-    R = NCDConfig_make_processes(T, A.str, B, 0, NULL);
+    R = NCDConfig_make_processes(T, A.str, B, NULL);
     if (!R) {
         parser_out->out_of_memory = 1;
     }
 }
 
 processes(R) ::= process_or_template(T) NAME(A) CURLY_OPEN statements(B) CURLY_CLOSE processes(N). {
-    R = NCDConfig_make_processes(T, A.str, B, 1, N);
+    R = NCDConfig_make_processes(T, A.str, B, N);
     if (!R) {
         parser_out->out_of_memory = 1;
     }