From a1e32bcff0a04dbff61f28c8e725cf2bf120bf85 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 10 May 2010 13:17:25 -0700 Subject: [PATCH] Add some compiler warnings and corresponding fixes. Most of the current problems were (mostly) harmless things like missing declarations, but there was at least one real error, (reversed argument order for yyerrror). --- Makefile | 2 ++ glcpp-lex.l | 1 + glcpp-parse.y | 6 ++++-- glcpp.c | 2 ++ glcpp.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 glcpp.h diff --git a/Makefile b/Makefile index d8357dda0f0..d0ca78de74c 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +override CFLAGS += -Wall -Wextra -Wwrite-strings -Wswitch-enum -Wno-unused + glcpp: glcpp.o glcpp-lex.o glcpp-parse.o %.c %.h: %.y diff --git a/glcpp-lex.l b/glcpp-lex.l index 276f50ddfe3..747e24056f4 100644 --- a/glcpp-lex.l +++ b/glcpp-lex.l @@ -25,6 +25,7 @@ #include #include +#include "glcpp.h" #include "glcpp-parse.h" %} diff --git a/glcpp-parse.y b/glcpp-parse.y index 9acd549b24c..a2d10942538 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -25,10 +25,12 @@ #include #include +#include "glcpp.h" + #define YYSTYPE int void -yyerror (const char *error, void *scanner); +yyerror (void *scanner, const char *error); %} @@ -54,7 +56,7 @@ token: TOKEN %% void -yyerror (const char *error, void *scanner) +yyerror (void *scanner, const char *error) { fprintf (stderr, "Parse error: %s\n", error); } diff --git a/glcpp.c b/glcpp.c index 90a0e89cfa6..eefac74be9a 100644 --- a/glcpp.c +++ b/glcpp.c @@ -21,6 +21,8 @@ * DEALINGS IN THE SOFTWARE. */ +#include "glcpp.h" + int main (void) { diff --git a/glcpp.h b/glcpp.h new file mode 100644 index 00000000000..485387b8a5d --- /dev/null +++ b/glcpp.h @@ -0,0 +1,45 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef GLCPP_H +#define GLCPP_H + +/* Generated by glcpp-lex.l to glcpp-lex.c */ + +#define yyscan_t void* + +int +yylex_init (yyscan_t *scanner); + +int +yylex (yyscan_t scanner); + +int +yylex_destroy (yyscan_t scanner); + +/* Generated by glcpp-parse.y to glcpp-parse.c */ + +int +yyparse (void *scanner); + +#endif -- 2.30.2