From 52dc69b2dc349a43f108a9926b0794ee6b6ec4c3 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Mon, 25 Nov 2019 15:32:19 -0500 Subject: [PATCH] Fix -Wmissing-declarations warnings in filter-parser.y MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Make gc_string_append and yyerror static, as they are only used in this file. Remove yywrap, apparently, it's not used. This probably has to do with the fact that our lexer uses the noyywrap option. setstring is used by filter-lexer.c (generated from filter-lexer.l), which has its own local setstring declaration. This is not very good, because the prototype of setstring could change in the implementation, and the users of the function would still compile, but then it would probably crash inexplicably at runtime. Instead, put the declaration in filter-parser.h, using a "%code provides" directive. That seems to be the intent of "%code provides" [1]: Purpose: This is the best place to write additional definitions and declarations that should be provided to other modules. [1] https://www.gnu.org/software/bison/manual/html_node/_0025code-Summary.html Change-Id: I04ce69ae9808b72e96bf9e602772f0e5758dfc10 Signed-off-by: Simon Marchi Signed-off-by: Jérémie Galarneau --- src/lib/lttng-ctl/filter/filter-lexer.l | 3 --- src/lib/lttng-ctl/filter/filter-parser.y | 18 ++++++++++-------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/lib/lttng-ctl/filter/filter-lexer.l b/src/lib/lttng-ctl/filter/filter-lexer.l index 4ef4519be..cdb099af7 100644 --- a/src/lib/lttng-ctl/filter/filter-lexer.l +++ b/src/lib/lttng-ctl/filter/filter-lexer.l @@ -14,9 +14,6 @@ #include "filter-ast.h" #include "filter-parser.h" -extern -void setstring(struct filter_parser_ctx *parser_ctx, YYSTYPE *lvalp, const char *src); - static void yyunput (int c, register char * yy_bp , yyscan_t yyscanner) __attribute__((unused)); static int input (yyscan_t yyscanner) __attribute__((unused)); diff --git a/src/lib/lttng-ctl/filter/filter-parser.y b/src/lib/lttng-ctl/filter/filter-parser.y index d1ea3a1a9..ba2d3007b 100644 --- a/src/lib/lttng-ctl/filter/filter-parser.y +++ b/src/lib/lttng-ctl/filter/filter-parser.y @@ -93,7 +93,7 @@ end: * gsrc will be garbage collected immediately, and gstr might be. * Should only be used to append characters to a string literal or constant. */ -LTTNG_HIDDEN +static struct gc_string *gc_string_append(struct filter_parser_ctx *parser_ctx, struct gc_string *gstr, struct gc_string *gsrc) @@ -185,17 +185,11 @@ static struct filter_node *make_op_node(struct filter_parser_ctx *scanner, return node; } -LTTNG_HIDDEN +static void yyerror(struct filter_parser_ctx *parser_ctx, yyscan_t scanner, const char *str) { fprintf(stderr, "error %s\n", str); } - -LTTNG_HIDDEN -int yywrap(void) -{ - return 1; -} #define parse_error(parser_ctx, str) \ do { \ @@ -296,6 +290,14 @@ void filter_parser_ctx_free(struct filter_parser_ctx *parser_ctx) %} +%code provides +{ +#include "common/macros.h" + +LTTNG_HIDDEN +void setstring(struct filter_parser_ctx *parser_ctx, YYSTYPE *lvalp, const char *src); +} + %define api.pure /* %locations */ %parse-param {struct filter_parser_ctx *parser_ctx} -- 2.34.1