]> xenbits.xensource.com Git - people/vhanquez/xen.git/commitdiff
libxl: correctly initialise yylineno
authorIan Jackson <Ian.Jackson@eu.citrix.com>
Thu, 3 Mar 2011 17:11:31 +0000 (17:11 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Thu, 3 Mar 2011 17:11:31 +0000 (17:11 +0000)
Sometimes xl would read an uninitialised variable when printing error
messages, resulting in things like this:
  /etc/xen/thing.cfg:1030057088: config parsing error near `"ws08r2-x64-2': lexical error

This is because yylineno is a variable inside the scanner created by
yylex_init, but it is not initialised by yylex_init.
(Debian bug #616099.)

On the way I discovered a lot of complication to do with the calling
convention between bison and flex in reentrant parsers/scanners which
use locations (Debian bug #616100) but as the above change makes the
current code in xen-unstable work I don't propose to do anything else
about that now in our tree.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Tested-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxl/libxlu_cfg.c

index 663fdf9a02623cd9e0ef0d338a5585e4e5a99833..f947c219b4fd9f551b7c5b208af9fcf73c6139b6 100644 (file)
@@ -43,6 +43,9 @@ static void ctx_dispose(CfgParseContext *ctx) {
 static void parse(CfgParseContext *ctx) {
     /* On return, ctx.err will be updated with the error status. */
     int r;
+
+    xlu__cfg_yyset_lineno(1, ctx->scanner);
+
     r= xlu__cfg_yyparse(ctx);
     if (r) assert(ctx->err);