diff options
-rw-r--r-- | wiretap/candump_parser.lemon | 3 | ||||
-rw-r--r-- | wiretap/candump_scanner.l | 25 |
2 files changed, 28 insertions, 0 deletions
diff --git a/wiretap/candump_parser.lemon b/wiretap/candump_parser.lemon index 25cb98a78e..2af58a6ea5 100644 --- a/wiretap/candump_parser.lemon +++ b/wiretap/candump_parser.lemon @@ -276,6 +276,9 @@ run_candump_parser(FILE_T fh, int *err, gchar **err_info) if (file_seek(fh, 0, SEEK_SET, err) == -1) return NULL; + *err = 0; + *err_info = NULL; + memset(&state, 0, sizeof(state)); state.fh = fh; diff --git a/wiretap/candump_scanner.l b/wiretap/candump_scanner.l index 59b2188e29..98b98ee791 100644 --- a/wiretap/candump_scanner.l +++ b/wiretap/candump_scanner.l @@ -24,6 +24,19 @@ %option noyy_scan_bytes %option noyy_scan_string +/* + * We have to override the memory allocators so that we don't get + * "unused argument" warnings from the yyscanner argument (which + * we don't use, as we have a global memory allocator). + * + * We provide, as macros, our own versions of the routines generated by Flex, + * which just call malloc()/realloc()/free() (as the Flex versions do), + * discarding the extra argument. + */ +%option noyyalloc +%option noyyrealloc +%option noyyfree + %{ #include <ws_diag_control.h> @@ -52,6 +65,18 @@ static int candump_yyinput(void *buf, unsigned int max_size, #define YY_INPUT(buf, result, max_size) \ do { (result) = candump_yyinput((buf), (max_size), yyextra); } while (0) +/* + * Sleazy hack to suppress compiler warnings in yy_fatal_error(). + */ +#define YY_EXIT_FAILURE ((void)yyscanner, 2) + +/* + * Macros for the allocators, to discard the extra argument. + */ +#define candump_alloc(size, yyscanner) (void *)malloc(size) +#define candump_realloc(ptr, size, yyscanner) (void *)realloc((char *)(ptr), (size)) +#define candump_free(ptr, yyscanner) free((char *)(ptr)) + DIAG_OFF_FLEX %} |