Browse Source

- removed macro SAVE_int2uint()

- bugfix, in execute_plan() use tag_t for loop over tags
development
Andreas Romeyke 10 months ago
parent
commit
ab67340612
  1. 27
      src/parser/config_parser.c

27
src/parser/config_parser.c

@ -12,7 +12,6 @@
#include <string.h>
#include <assert.h>
#include "config_parser.h"
#include "check.h"
#include "check_helper.h"
#include "msg_parser.h"
#include <pcre.h>
@ -301,16 +300,6 @@ char * __ch_malloc(char * msg) {
return msg;
}
unsigned int save_int2int(int i, const char* file, int line ) {
if (i < 0) {
fprintf(stderr, "code error, using integer %i but unsigned value was expected, code=%s, line=%i\n", \
i, file, line);
exit(EXIT_FAILURE);
}
return (unsigned int) i;
}
#define SAVE_int2uint( i) save_int2int((i), __FILE__, __LINE__)
ret_t call_exec_function(ctiff_t * ctif, ret_t * retp, internal_entry_t * exep) {
ret_t ret = *retp;
@ -319,7 +308,7 @@ ret_t call_exec_function(ctiff_t * ctif, ret_t * retp, internal_entry_t * exep)
switch (exe.function) {
case fc_true: { ret.returncode=is_valid; break;}
case fc_false: { ret.returncode=is_error; break; }
case fc_tag_has_some_of_these_values: { unsigned int count = SAVE_int2uint(exe_i_pop(&exe));
case fc_tag_has_some_of_these_values: { unsigned int count = exe_i_pop(&exe);
unsigned int values[count];
expected_value = __ch_malloc(expected_value);
char * strp = expected_value;
@ -330,14 +319,14 @@ ret_t call_exec_function(ctiff_t * ctif, ret_t * retp, internal_entry_t * exep)
all_printed+=printed;
for (unsigned int j=0; j<count; j++) {
/* reduce VALUESTRLEN with n*printed */
printed = snprintf(strp, VALUESTRLEN-all_printed, " [%i]=%u",j, values[j]);
printed = snprintf(strp, (size_t) (VALUESTRLEN - all_printed), " [%i]=%u", j, values[j]);
strp+=printed;
all_printed+=printed;
}
ret = check_tag_has_some_of_these_values(ctif, exe.tag, count, values);
break;
}
case fc_tag_has_valuelist: { unsigned int count = SAVE_int2uint(exe_i_pop(&exe));
case fc_tag_has_valuelist: { unsigned int count = exe_i_pop(&exe);
unsigned int values[count];
expected_value = __ch_malloc(expected_value);
char * strp = expected_value;
@ -355,20 +344,20 @@ ret_t call_exec_function(ctiff_t * ctif, ret_t * retp, internal_entry_t * exep)
ret = check_tag_has_valuelist(ctif, exe.tag, count, values);
break;
}
case fc_tag_has_value_in_range: { unsigned int a = SAVE_int2uint(exe_i_pop(&exe));
unsigned int b = SAVE_int2uint(exe_i_pop(&exe));
case fc_tag_has_value_in_range: { unsigned int a = exe_i_pop(&exe);
unsigned int b = exe_i_pop(&exe);
expected_value = __ch_malloc(expected_value);
snprintf(expected_value, VALUESTRLEN, "%i -- %i", a, b);
ret = check_tag_has_value_in_range(ctif, exe.tag, a, b);
break;
}
case fc_tag_has_value: { unsigned int a = SAVE_int2uint(exe_i_pop(&exe));
case fc_tag_has_value: { unsigned int a = exe_i_pop(&exe);
expected_value = __ch_malloc(expected_value);
snprintf(expected_value, VALUESTRLEN, "%i", a);
ret = check_tag_has_value(ctif, exe.tag, a);
break;
}
case fc_tag_has_value_quiet: { unsigned int a = SAVE_int2uint(exe_i_pop(&exe));
case fc_tag_has_value_quiet: { unsigned int a = exe_i_pop(&exe);
expected_value = __ch_malloc(expected_value);
snprintf(expected_value, VALUESTRLEN, "%i", a);
ret = check_tag_has_value_quiet(ctif, exe.tag, a);
@ -602,7 +591,7 @@ void execute_plan (ctiff_t * ctif) {
#endif
#ifndef NOTAGCHECK
for (int i = MINTAGS; i<MAXTAGS; i++) {
for (tag_t i = MAXTAGS; i>=MINTAGS; i--) {
if (false==parser_state.called_tags[i]) {
ret_t res = check_notag(ctif, i);
if (res.returncode == tag_exist) {

Loading…
Cancel
Save