[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] tools/libxl: disable clang indentation check for the disk parser



commit 190c60f12db469472476041ecd0e6c9a0d4b0f8a
Author:     Roger Pau Monne <roger.pau@xxxxxxxxxx>
AuthorDate: Tue May 5 11:24:54 2020 +0200
Commit:     Wei Liu <wl@xxxxxxx>
CommitDate: Sun May 10 13:02:18 2020 +0100

    tools/libxl: disable clang indentation check for the disk parser
    
    Clang 10 complains with:
    
    13: error: misleading indentation; statement is not part of the previous 
'if'
          [-Werror,-Wmisleading-indentation]
                if ( ! yyg->yy_state_buf )
                ^
    libxlu_disk_l.c:1259:9: note: previous statement is here
            if ( ! yyg->yy_state_buf )
            ^
    
    Due to the missing braces in single line statements and the wrong
    indentation. Fix this by disabling the warning for that specific file.
    I haven't found a way to force flex to add braces around single line
    statements in conditional blocks.
    
    Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
    [ wei: regenerate output files ]
    Acked-by: Wei Liu <wl@xxxxxxx>
---
 tools/libxl/libxlu_disk_l.c | 97 +++++++++++++++++++++++++--------------------
 tools/libxl/libxlu_disk_l.h |  2 +-
 tools/libxl/libxlu_disk_l.l | 11 +++++
 3 files changed, 66 insertions(+), 44 deletions(-)

diff --git a/tools/libxl/libxlu_disk_l.c b/tools/libxl/libxlu_disk_l.c
index b0ac3a865a..05f7ac74a0 100644
--- a/tools/libxl/libxlu_disk_l.c
+++ b/tools/libxl/libxlu_disk_l.c
@@ -1074,6 +1074,17 @@ goto find_rule; \
 
 #define YY_NO_INPUT
 
+/* The code generated by flex is missing braces in single line expressions and
+ * is not properly indented, which triggers the clang misleading-indentation
+ * check that has been made part of -Wall since clang 10. In order to safely
+ * disable it on clang versions that don't have the diagnostic implemented
+ * also disable the unknown option and pragma warning. */
+#ifdef __clang__
+# pragma clang diagnostic ignored "-Wunknown-pragmas"
+# pragma clang diagnostic ignored "-Wunknown-warning-option"
+# pragma clang diagnostic ignored "-Wmisleading-indentation"
+#endif
+
 /* Some versions of flex have a bug (Fedora bugzilla 612465) which causes
  * it to fail to declare these functions, which it defines.  So declare
  * them ourselves.  Hopefully we won't have to simultaneously support
@@ -1188,9 +1199,9 @@ static int vdev_and_devtype(DiskParseContext *dpc, char 
*str) {
 #undef DPC /* needs to be defined differently the actual lexer */
 #define DPC ((DiskParseContext*)yyextra)
 
-#line 1192 "libxlu_disk_l.c"
+#line 1203 "libxlu_disk_l.c"
 
-#line 1194 "libxlu_disk_l.c"
+#line 1205 "libxlu_disk_l.c"
 
 #define INITIAL 0
 #define LEXERR 1
@@ -1466,13 +1477,13 @@ YY_DECL
                }
 
        {
-#line 166 "libxlu_disk_l.l"
+#line 177 "libxlu_disk_l.l"
 
 
-#line 169 "libxlu_disk_l.l"
+#line 180 "libxlu_disk_l.l"
  /*----- the scanner rules which do the parsing -----*/
 
-#line 1476 "libxlu_disk_l.c"
+#line 1487 "libxlu_disk_l.c"
 
        while ( /*CONSTCOND*/1 )                /* loops until end-of-file is 
reached */
                {
@@ -1561,135 +1572,135 @@ do_action:    /* This label is used only to access 
EOF actions. */
 case 1:
 /* rule 1 can match eol */
 YY_RULE_SETUP
-#line 171 "libxlu_disk_l.l"
+#line 182 "libxlu_disk_l.l"
 { /* ignore whitespace before parameters */ }
        YY_BREAK
 /* ordinary parameters setting enums or strings */
 case 2:
 /* rule 2 can match eol */
 YY_RULE_SETUP
-#line 175 "libxlu_disk_l.l"
+#line 186 "libxlu_disk_l.l"
 { STRIP(','); setformat(DPC, FROMEQUALS); }
        YY_BREAK
 case 3:
 YY_RULE_SETUP
-#line 177 "libxlu_disk_l.l"
+#line 188 "libxlu_disk_l.l"
 { DPC->disk->is_cdrom = 1; }
        YY_BREAK
 case 4:
 YY_RULE_SETUP
-#line 178 "libxlu_disk_l.l"
+#line 189 "libxlu_disk_l.l"
 { DPC->disk->is_cdrom = 1; }
        YY_BREAK
 case 5:
 YY_RULE_SETUP
-#line 179 "libxlu_disk_l.l"
+#line 190 "libxlu_disk_l.l"
 { DPC->disk->is_cdrom = 0; }
        YY_BREAK
 case 6:
 /* rule 6 can match eol */
 YY_RULE_SETUP
-#line 180 "libxlu_disk_l.l"
+#line 191 "libxlu_disk_l.l"
 { xlu__disk_err(DPC,yytext,"unknown value for type"); }
        YY_BREAK
 case 7:
 /* rule 7 can match eol */
 YY_RULE_SETUP
-#line 182 "libxlu_disk_l.l"
+#line 193 "libxlu_disk_l.l"
 { STRIP(','); setaccess(DPC, FROMEQUALS); }
        YY_BREAK
 case 8:
 /* rule 8 can match eol */
 YY_RULE_SETUP
-#line 183 "libxlu_disk_l.l"
+#line 194 "libxlu_disk_l.l"
 { STRIP(','); SAVESTRING("backend", backend_domname, FROMEQUALS); }
        YY_BREAK
 case 9:
 /* rule 9 can match eol */
 YY_RULE_SETUP
-#line 184 "libxlu_disk_l.l"
+#line 195 "libxlu_disk_l.l"
 { STRIP(','); setbackendtype(DPC,FROMEQUALS); }
        YY_BREAK
 case 10:
 /* rule 10 can match eol */
 YY_RULE_SETUP
-#line 186 "libxlu_disk_l.l"
+#line 197 "libxlu_disk_l.l"
 { STRIP(','); SAVESTRING("vdev", vdev, FROMEQUALS); }
        YY_BREAK
 case 11:
 /* rule 11 can match eol */
 YY_RULE_SETUP
-#line 187 "libxlu_disk_l.l"
+#line 198 "libxlu_disk_l.l"
 { STRIP(','); SAVESTRING("script", script, FROMEQUALS); }
        YY_BREAK
 case 12:
 YY_RULE_SETUP
-#line 188 "libxlu_disk_l.l"
+#line 199 "libxlu_disk_l.l"
 { DPC->disk->direct_io_safe = 1; }
        YY_BREAK
 case 13:
 YY_RULE_SETUP
-#line 189 "libxlu_disk_l.l"
+#line 200 "libxlu_disk_l.l"
 { libxl_defbool_set(&DPC->disk->discard_enable, true); }
        YY_BREAK
 case 14:
 YY_RULE_SETUP
-#line 190 "libxlu_disk_l.l"
+#line 201 "libxlu_disk_l.l"
 { libxl_defbool_set(&DPC->disk->discard_enable, false); }
        YY_BREAK
 /* Note that the COLO configuration settings should be considered unstable.
   * They may change incompatibly in future versions of Xen. */
 case 15:
 YY_RULE_SETUP
-#line 193 "libxlu_disk_l.l"
+#line 204 "libxlu_disk_l.l"
 { libxl_defbool_set(&DPC->disk->colo_enable, true); }
        YY_BREAK
 case 16:
 YY_RULE_SETUP
-#line 194 "libxlu_disk_l.l"
+#line 205 "libxlu_disk_l.l"
 { libxl_defbool_set(&DPC->disk->colo_enable, false); }
        YY_BREAK
 case 17:
 /* rule 17 can match eol */
 YY_RULE_SETUP
-#line 195 "libxlu_disk_l.l"
+#line 206 "libxlu_disk_l.l"
 { STRIP(','); SAVESTRING("colo-host", colo_host, FROMEQUALS); }
        YY_BREAK
 case 18:
 /* rule 18 can match eol */
 YY_RULE_SETUP
-#line 196 "libxlu_disk_l.l"
+#line 207 "libxlu_disk_l.l"
 { STRIP(','); setcoloport(DPC, FROMEQUALS); }
        YY_BREAK
 case 19:
 /* rule 19 can match eol */
 YY_RULE_SETUP
-#line 197 "libxlu_disk_l.l"
+#line 208 "libxlu_disk_l.l"
 { STRIP(','); SAVESTRING("colo-export", colo_export, FROMEQUALS); }
        YY_BREAK
 case 20:
 /* rule 20 can match eol */
 YY_RULE_SETUP
-#line 198 "libxlu_disk_l.l"
+#line 209 "libxlu_disk_l.l"
 { STRIP(','); SAVESTRING("active-disk", active_disk, FROMEQUALS); }
        YY_BREAK
 case 21:
 /* rule 21 can match eol */
 YY_RULE_SETUP
-#line 199 "libxlu_disk_l.l"
+#line 210 "libxlu_disk_l.l"
 { STRIP(','); SAVESTRING("hidden-disk", hidden_disk, FROMEQUALS); }
        YY_BREAK
 /* the target magic parameter, eats the rest of the string */
 case 22:
 YY_RULE_SETUP
-#line 203 "libxlu_disk_l.l"
+#line 214 "libxlu_disk_l.l"
 { STRIP(','); SAVESTRING("target", pdev_path, FROMEQUALS); }
        YY_BREAK
 /* unknown parameters */
 case 23:
 /* rule 23 can match eol */
 YY_RULE_SETUP
-#line 207 "libxlu_disk_l.l"
+#line 218 "libxlu_disk_l.l"
 { xlu__disk_err(DPC,yytext,"unknown parameter"); }
        YY_BREAK
 /* deprecated prefixes */
@@ -1697,7 +1708,7 @@ YY_RULE_SETUP
    * matched the whole string, so these patterns take precedence */
 case 24:
 YY_RULE_SETUP
-#line 214 "libxlu_disk_l.l"
+#line 225 "libxlu_disk_l.l"
 {
                     STRIP(':');
                     DPC->had_depr_prefix=1; DEPRECATE("use `[format=]...,'");
@@ -1706,7 +1717,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 25:
 YY_RULE_SETUP
-#line 220 "libxlu_disk_l.l"
+#line 231 "libxlu_disk_l.l"
 {
                     char *newscript;
                     STRIP(':');
@@ -1725,12 +1736,12 @@ case 26:
 yyg->yy_c_buf_p = yy_cp = yy_bp + 8;
 YY_DO_BEFORE_ACTION; /* set up yytext again */
 YY_RULE_SETUP
-#line 233 "libxlu_disk_l.l"
+#line 244 "libxlu_disk_l.l"
 { DPC->had_depr_prefix=1; DEPRECATE(0); }
        YY_BREAK
 case 27:
 YY_RULE_SETUP
-#line 234 "libxlu_disk_l.l"
+#line 245 "libxlu_disk_l.l"
 { DPC->had_depr_prefix=1; DEPRECATE(0); }
        YY_BREAK
 case 28:
@@ -1738,7 +1749,7 @@ case 28:
 yyg->yy_c_buf_p = yy_cp = yy_bp + 4;
 YY_DO_BEFORE_ACTION; /* set up yytext again */
 YY_RULE_SETUP
-#line 235 "libxlu_disk_l.l"
+#line 246 "libxlu_disk_l.l"
 { DPC->had_depr_prefix=1; DEPRECATE(0); }
        YY_BREAK
 case 29:
@@ -1746,7 +1757,7 @@ case 29:
 yyg->yy_c_buf_p = yy_cp = yy_bp + 6;
 YY_DO_BEFORE_ACTION; /* set up yytext again */
 YY_RULE_SETUP
-#line 236 "libxlu_disk_l.l"
+#line 247 "libxlu_disk_l.l"
 { DPC->had_depr_prefix=1; DEPRECATE(0); }
        YY_BREAK
 case 30:
@@ -1754,7 +1765,7 @@ case 30:
 yyg->yy_c_buf_p = yy_cp = yy_bp + 5;
 YY_DO_BEFORE_ACTION; /* set up yytext again */
 YY_RULE_SETUP
-#line 237 "libxlu_disk_l.l"
+#line 248 "libxlu_disk_l.l"
 { DPC->had_depr_prefix=1; DEPRECATE(0); }
        YY_BREAK
 case 31:
@@ -1762,13 +1773,13 @@ case 31:
 yyg->yy_c_buf_p = yy_cp = yy_bp + 4;
 YY_DO_BEFORE_ACTION; /* set up yytext again */
 YY_RULE_SETUP
-#line 238 "libxlu_disk_l.l"
+#line 249 "libxlu_disk_l.l"
 { DPC->had_depr_prefix=1; DEPRECATE(0); }
        YY_BREAK
 case 32:
 /* rule 32 can match eol */
 YY_RULE_SETUP
-#line 240 "libxlu_disk_l.l"
+#line 251 "libxlu_disk_l.l"
 {
                  xlu__disk_err(DPC,yytext,"unknown deprecated disk prefix");
                  return 0;
@@ -1778,7 +1789,7 @@ YY_RULE_SETUP
 case 33:
 /* rule 33 can match eol */
 YY_RULE_SETUP
-#line 247 "libxlu_disk_l.l"
+#line 258 "libxlu_disk_l.l"
 {
     STRIP(',');
 
@@ -1807,7 +1818,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 34:
 YY_RULE_SETUP
-#line 273 "libxlu_disk_l.l"
+#line 284 "libxlu_disk_l.l"
 {
     BEGIN(LEXERR);
     yymore();
@@ -1815,17 +1826,17 @@ YY_RULE_SETUP
        YY_BREAK
 case 35:
 YY_RULE_SETUP
-#line 277 "libxlu_disk_l.l"
+#line 288 "libxlu_disk_l.l"
 {
     xlu__disk_err(DPC,yytext,"bad disk syntax"); return 0;
 }
        YY_BREAK
 case 36:
 YY_RULE_SETUP
-#line 280 "libxlu_disk_l.l"
+#line 291 "libxlu_disk_l.l"
 YY_FATAL_ERROR( "flex scanner jammed" );
        YY_BREAK
-#line 1829 "libxlu_disk_l.c"
+#line 1840 "libxlu_disk_l.c"
                        case YY_STATE_EOF(INITIAL):
                        case YY_STATE_EOF(LEXERR):
                                yyterminate();
@@ -2930,4 +2941,4 @@ void yyfree (void * ptr , yyscan_t yyscanner)
 
 #define YYTABLES_NAME "yytables"
 
-#line 280 "libxlu_disk_l.l"
+#line 291 "libxlu_disk_l.l"
diff --git a/tools/libxl/libxlu_disk_l.h b/tools/libxl/libxlu_disk_l.h
index 9275a3ab55..54f4662d7a 100644
--- a/tools/libxl/libxlu_disk_l.h
+++ b/tools/libxl/libxlu_disk_l.h
@@ -694,7 +694,7 @@ extern int yylex (yyscan_t yyscanner);
 #undef yyTABLES_NAME
 #endif
 
-#line 280 "libxlu_disk_l.l"
+#line 291 "libxlu_disk_l.l"
 
 #line 700 "libxlu_disk_l.h"
 #undef xlu__disk_yyIN_HEADER
diff --git a/tools/libxl/libxlu_disk_l.l b/tools/libxl/libxlu_disk_l.l
index 97039a2800..7a46f4a30c 100644
--- a/tools/libxl/libxlu_disk_l.l
+++ b/tools/libxl/libxlu_disk_l.l
@@ -36,6 +36,17 @@
 
 #define YY_NO_INPUT
 
+/* The code generated by flex is missing braces in single line expressions and
+ * is not properly indented, which triggers the clang misleading-indentation
+ * check that has been made part of -Wall since clang 10. In order to safely
+ * disable it on clang versions that don't have the diagnostic implemented
+ * also disable the unknown option and pragma warning. */
+#ifdef __clang__
+# pragma clang diagnostic ignored "-Wunknown-pragmas"
+# pragma clang diagnostic ignored "-Wunknown-warning-option"
+# pragma clang diagnostic ignored "-Wmisleading-indentation"
+#endif
+
 /* Some versions of flex have a bug (Fedora bugzilla 612465) which causes
  * it to fail to declare these functions, which it defines.  So declare
  * them ourselves.  Hopefully we won't have to simultaneously support
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.