From 5f7494c30c5435f3e21060a2a91d73b8c2e5f45d Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Tue, 2 Jul 2019 11:51:03 +0200 Subject: [PATCH] [sonar] Move include before any code. --- examples/deprecated/msg/dht-kademlia/answer.c | 1 + examples/deprecated/msg/dht-kademlia/answer.h | 2 - src/xbt/automaton/automatonparse_promela.c | 4 +- src/xbt/automaton/parserPromela.tab.cacc | 177 ++++++++++-------- src/xbt/automaton/parserPromela.tab.hacc | 12 +- src/xbt/automaton/parserPromela.yacc | 3 + 6 files changed, 110 insertions(+), 89 deletions(-) diff --git a/examples/deprecated/msg/dht-kademlia/answer.c b/examples/deprecated/msg/dht-kademlia/answer.c index 1aa3b9a892..d420bb9975 100644 --- a/examples/deprecated/msg/dht-kademlia/answer.c +++ b/examples/deprecated/msg/dht-kademlia/answer.c @@ -5,6 +5,7 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "answer.h" +#include "node.h" XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(msg_kademlia_node); diff --git a/examples/deprecated/msg/dht-kademlia/answer.h b/examples/deprecated/msg/dht-kademlia/answer.h index 93b748a2bc..bba5625b3d 100644 --- a/examples/deprecated/msg/dht-kademlia/answer.h +++ b/examples/deprecated/msg/dht-kademlia/answer.h @@ -18,8 +18,6 @@ typedef struct s_node_answer { typedef s_answer_t *answer_t; -#include "node.h" - answer_t answer_init(unsigned int destination_id); void answer_free(answer_t answer); void answer_print(answer_t answer); diff --git a/src/xbt/automaton/automatonparse_promela.c b/src/xbt/automaton/automatonparse_promela.c index 104630c791..bf93af4335 100644 --- a/src/xbt/automaton/automatonparse_promela.c +++ b/src/xbt/automaton/automatonparse_promela.c @@ -15,6 +15,8 @@ #include #include +#include "parserPromela.tab.cacc" + XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(xbt_automaton); static xbt_automaton_t parsed_automaton; @@ -60,8 +62,6 @@ static void new_transition(char* id, xbt_automaton_exp_label_t label) } -#include "parserPromela.tab.cacc" - void xbt_automaton_load(xbt_automaton_t a, const char *file) { parsed_automaton = a; diff --git a/src/xbt/automaton/parserPromela.tab.cacc b/src/xbt/automaton/parserPromela.tab.cacc index 480e0c2f2a..5585076aef 100644 --- a/src/xbt/automaton/parserPromela.tab.cacc +++ b/src/xbt/automaton/parserPromela.tab.cacc @@ -1,8 +1,9 @@ -/* A Bison parser, made by GNU Bison 3.2.2. */ +/* A Bison parser, made by GNU Bison 3.4.1. */ /* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation, + Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -47,7 +48,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "3.2.2" +#define YYBISON_VERSION "3.4.1" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -73,7 +74,7 @@ #define yychar xbt_automaton_parser_char /* First part of user prologue. */ -#line 7 "parserPromela.yacc" /* yacc.c:338 */ +#line 7 "parserPromela.yacc" #include "simgrid/config.h" #if !HAVE_UNISTD_H @@ -85,8 +86,12 @@ void yyerror(const char *s); +static void new_state(char* id, int src); +static void new_transition(char* id, xbt_automaton_exp_label_t label); + + +#line 94 "parserPromela.tab.cacc" -#line 90 "parserPromela.tab.cacc" /* yacc.c:338 */ # ifndef YY_NULLPTR # if defined __cplusplus # if 201103L <= __cplusplus @@ -107,8 +112,8 @@ void yyerror(const char *s); # define YYERROR_VERBOSE 0 #endif -/* In a future release of Bison, this section will be replaced - by #include "parserPromela.tab.hacc". */ +/* Use api.header.include to #include this header + instead of duplicating it here. */ #ifndef YY_XBT_AUTOMATON_PARSER_PARSERPROMELA_TAB_HACC_INCLUDED # define YY_XBT_AUTOMATON_PARSER_PARSERPROMELA_TAB_HACC_INCLUDED /* Debug traces. */ @@ -149,19 +154,18 @@ extern int xbt_automaton_parser_debug; /* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED - union YYSTYPE { -#line 20 "parserPromela.yacc" /* yacc.c:353 */ +#line 23 "parserPromela.yacc" double real; int integer; char* string; xbt_automaton_exp_label_t label; -#line 163 "parserPromela.tab.cacc" /* yacc.c:353 */ -}; +#line 167 "parserPromela.tab.cacc" +}; typedef union YYSTYPE YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_DECLARED 1 @@ -276,6 +280,8 @@ typedef short yytype_int16; #endif +#define YY_ASSERT(E) ((void) (0 && (E))) + #if ! defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ @@ -418,16 +424,16 @@ union yyalloc /* YYNSTATES -- Number of states. */ #define YYNSTATES 32 -/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned - by yylex, with out-of-bounds checking. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 277 +/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, with out-of-bounds checking. */ #define YYTRANSLATE(YYX) \ ((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM - as returned by yylex, without out-of-bounds checking. */ + as returned by yylex. */ static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -464,8 +470,8 @@ static const yytype_uint8 yytranslate[] = /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint8 yyrline[] = { - 0, 57, 57, 60, 61, 61, 64, 65, 68, 69, - 70, 71, 72, 73 + 0, 60, 60, 63, 64, 64, 67, 68, 71, 72, + 73, 74, 75, 76 }; #endif @@ -590,22 +596,22 @@ static const yytype_uint8 yyr2[] = #define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - YYPOPSTACK (yylen); \ - yystate = *yyssp; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror (YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (0) +#define YYBACKUP(Token, Value) \ + do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ + while (0) /* Error token number */ #define YYTERROR 1 @@ -720,7 +726,7 @@ yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yystos[yyssp[yyi + 1 - yynrhs]], - &(yyvsp[(yyi + 1) - (yynrhs)]) + &yyvsp[(yyi + 1) - (yynrhs)] ); YYFPRINTF (stderr, "\n"); } @@ -824,7 +830,10 @@ yytnamerr (char *yyres, const char *yystr) case '\\': if (*++yyp != '\\') goto do_not_strip_quotes; - /* Fall through. */ + else + goto append; + + append: default: if (yyres) yyres[yyn] = *yyp; @@ -920,10 +929,10 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yyarg[yycount++] = yytname[yyx]; { YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); - if (! (yysize <= yysize1 - && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) + yysize = yysize1; + else return 2; - yysize = yysize1; } } } @@ -947,9 +956,10 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, { YYSIZE_T yysize1 = yysize + yystrlen (yyformat); - if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) + yysize = yysize1; + else return 2; - yysize = yysize1; } if (*yymsg_alloc < yysize) @@ -1075,23 +1085,33 @@ yyparse (void) yychar = YYEMPTY; /* Cause a token to be read. */ goto yysetstate; + /*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | +| yynewstate -- push a new state, which is found in yystate. | `------------------------------------------------------------*/ - yynewstate: +yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; - yysetstate: + +/*--------------------------------------------------------------------. +| yynewstate -- set current state (the top of the stack) to yystate. | +`--------------------------------------------------------------------*/ +yysetstate: + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + YY_ASSERT (0 <= yystate && yystate < YYNSTATES); *yyssp = (yytype_int16) yystate; if (yyss + yystacksize - 1 <= yyssp) +#if !defined yyoverflow && !defined YYSTACK_RELOCATE + goto yyexhaustedlab; +#else { /* Get the current used size of the three stacks, in elements. */ YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1); -#ifdef yyoverflow +# if defined yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into @@ -1110,10 +1130,7 @@ yyparse (void) yyss = yyss1; yyvs = yyvs1; } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -# else +# else /* defined YYSTACK_RELOCATE */ /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; @@ -1129,12 +1146,11 @@ yyparse (void) goto yyexhaustedlab; YYSTACK_RELOCATE (yyss_alloc, yyss); YYSTACK_RELOCATE (yyvs_alloc, yyvs); -# undef YYSTACK_RELOCATE +# undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif -#endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; @@ -1145,19 +1161,18 @@ yyparse (void) if (yyss + yystacksize - 1 <= yyssp) YYABORT; } - - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); +#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */ if (yystate == YYFINAL) YYACCEPT; goto yybackup; + /*-----------. | yybackup. | `-----------*/ yybackup: - /* Do appropriate processing given the current state. Read a lookahead token if we need one and don't already have one. */ @@ -1215,7 +1230,6 @@ yybackup: YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; YY_IGNORE_MAYBE_UNINITIALIZED_END - goto yynewstate; @@ -1230,7 +1244,7 @@ yydefault: /*-----------------------------. -| yyreduce -- Do a reduction. | +| yyreduce -- do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ @@ -1250,56 +1264,57 @@ yyreduce: YY_REDUCE_PRINT (yyn); switch (yyn) { - case 4: -#line 61 "parserPromela.yacc" /* yacc.c:1645 */ + case 4: +#line 64 "parserPromela.yacc" { new_state((yyvsp[-1].string), 1);} -#line 1257 "parserPromela.tab.cacc" /* yacc.c:1645 */ +#line 1271 "parserPromela.tab.cacc" break; case 7: -#line 65 "parserPromela.yacc" /* yacc.c:1645 */ +#line 68 "parserPromela.yacc" { new_transition((yyvsp[-1].string), (yyvsp[-4].label));} -#line 1263 "parserPromela.tab.cacc" /* yacc.c:1645 */ +#line 1277 "parserPromela.tab.cacc" break; case 8: -#line 68 "parserPromela.yacc" /* yacc.c:1645 */ +#line 71 "parserPromela.yacc" { (yyval.label) = (yyvsp[-1].label); } -#line 1269 "parserPromela.tab.cacc" /* yacc.c:1645 */ +#line 1283 "parserPromela.tab.cacc" break; case 9: -#line 69 "parserPromela.yacc" /* yacc.c:1645 */ +#line 72 "parserPromela.yacc" { (yyval.label) = xbt_automaton_exp_label_new_or((yyvsp[-2].label), (yyvsp[0].label)); } -#line 1275 "parserPromela.tab.cacc" /* yacc.c:1645 */ +#line 1289 "parserPromela.tab.cacc" break; case 10: -#line 70 "parserPromela.yacc" /* yacc.c:1645 */ +#line 73 "parserPromela.yacc" { (yyval.label) = xbt_automaton_exp_label_new_and((yyvsp[-2].label), (yyvsp[0].label)); } -#line 1281 "parserPromela.tab.cacc" /* yacc.c:1645 */ +#line 1295 "parserPromela.tab.cacc" break; case 11: -#line 71 "parserPromela.yacc" /* yacc.c:1645 */ +#line 74 "parserPromela.yacc" { (yyval.label) = xbt_automaton_exp_label_new_not((yyvsp[0].label)); } -#line 1287 "parserPromela.tab.cacc" /* yacc.c:1645 */ +#line 1301 "parserPromela.tab.cacc" break; case 12: -#line 72 "parserPromela.yacc" /* yacc.c:1645 */ +#line 75 "parserPromela.yacc" { (yyval.label) = xbt_automaton_exp_label_new_one(); } -#line 1293 "parserPromela.tab.cacc" /* yacc.c:1645 */ +#line 1307 "parserPromela.tab.cacc" break; case 13: -#line 73 "parserPromela.yacc" /* yacc.c:1645 */ +#line 76 "parserPromela.yacc" { (yyval.label) = xbt_automaton_exp_label_new_predicat((yyvsp[0].string)); } -#line 1299 "parserPromela.tab.cacc" /* yacc.c:1645 */ +#line 1313 "parserPromela.tab.cacc" break; -#line 1303 "parserPromela.tab.cacc" /* yacc.c:1645 */ +#line 1317 "parserPromela.tab.cacc" + default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -1413,12 +1428,10 @@ yyerrlab: | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: - - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (/*CONSTCOND*/ 0) - goto yyerrorlab; + /* Pacify compilers when the user code never invokes YYERROR and the + label yyerrorlab therefore never appears in user code. */ + if (0) + YYERROR; /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ @@ -1480,6 +1493,7 @@ yyacceptlab: yyresult = 0; goto yyreturn; + /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ @@ -1487,6 +1501,7 @@ yyabortlab: yyresult = 1; goto yyreturn; + #if !defined yyoverflow || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | @@ -1497,6 +1512,10 @@ yyexhaustedlab: /* Fall through. */ #endif + +/*-----------------------------------------------------. +| yyreturn -- parsing is finished, return the result. | +`-----------------------------------------------------*/ yyreturn: if (yychar != YYEMPTY) { @@ -1526,7 +1545,7 @@ yyreturn: #endif return yyresult; } -#line 76 "parserPromela.yacc" /* yacc.c:1903 */ +#line 79 "parserPromela.yacc" diff --git a/src/xbt/automaton/parserPromela.tab.hacc b/src/xbt/automaton/parserPromela.tab.hacc index d159c908dc..18c33f782a 100644 --- a/src/xbt/automaton/parserPromela.tab.hacc +++ b/src/xbt/automaton/parserPromela.tab.hacc @@ -1,8 +1,9 @@ -/* A Bison parser, made by GNU Bison 3.2.2. */ +/* A Bison parser, made by GNU Bison 3.4.1. */ /* Bison interface for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation, + Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -73,19 +74,18 @@ extern int xbt_automaton_parser_debug; /* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED - union YYSTYPE { -#line 20 "parserPromela.yacc" /* yacc.c:1906 */ +#line 23 "parserPromela.yacc" double real; int integer; char* string; xbt_automaton_exp_label_t label; -#line 87 "parserPromela.tab.hacc" /* yacc.c:1906 */ -}; +#line 87 "parserPromela.tab.hacc" +}; typedef union YYSTYPE YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_DECLARED 1 diff --git a/src/xbt/automaton/parserPromela.yacc b/src/xbt/automaton/parserPromela.yacc index 699b732d51..e41de7ee17 100644 --- a/src/xbt/automaton/parserPromela.yacc +++ b/src/xbt/automaton/parserPromela.yacc @@ -15,6 +15,9 @@ void yyerror(const char *s); +static void new_state(char* id, int src); +static void new_transition(char* id, xbt_automaton_exp_label_t label); + %} %union{ -- 2.20.1