Fix -Wmissing-declarations warnings in filter-parser.y
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 25 Nov 2019 20:32:19 +0000 (15:32 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 10 Mar 2020 02:02:26 +0000 (22:02 -0400)
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 <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/lib/lttng-ctl/filter/filter-lexer.l
src/lib/lttng-ctl/filter/filter-parser.y

index 4ef4519bea03f6f91db8e958a1e54d0df10e3bbe..cdb099af7552477129aa16adef47ff51f66cdea8 100644 (file)
@@ -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));
index d1ea3a1a9d533e0f14c6e4534e5bc36e65b16be3..ba2d3007b932754ea080d3f88ed4ff030aeda8d6 100644 (file)
@@ -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}
This page took 0.025988 seconds and 4 git commands to generate.