ctf: define yystrlen to strlen
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 28 Oct 2019 18:07:05 +0000 (14:07 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 30 Oct 2019 19:14:53 +0000 (15:14 -0400)
commitb86399bbee3e37b36ef60df8743da17ecea8c5dc
tree7776cac358a779a18e3dde28ff64f8034de06bae
parentedd728ec4fe03e0d9ee36e84fa94cf8ac488e8ea
ctf: define yystrlen to strlen

Building with -Wnull-dereference on cygwin gives:

      LEX      lexer.c
      CC       libctf_parser_la-lexer.lo
      CC       libctf_parser_la-parser.lo
    parser.c: In function ‘yysyntax_error’:
    parser.c:2566:24: error: potential null pointer dereference [-Werror=null-dereference]
       for (yylen = 0; yystr[yylen]; yylen++)
                       ~~~~~^~~~~~~

For some reason, the conditional used by bison to define yystrlen makes
it so that cygwin uses the bison-provided version instead of strlen:

    # ifndef yystrlen
    #  if defined __GLIBC__ && defined _STRING_H
    #   define yystrlen strlen
    #  else
    /* Return the length of YYSTR.  */
    static YYSIZE_T
    yystrlen (const char *yystr)
    {
      YYSIZE_T yylen;
      for (yylen = 0; yystr[yylen]; yylen++)
        continue;
      return yylen;
    }
    #  endif
    # endif

Actually, probably because cygwin's string.h uses _STRING_H_ instead of
_STRING_H as its include guard.

As far as I know, strlen on cygwin (and on all the platforms we target)
is reliable.  So we can bypass this by defining yystrlen to strlen
directly.

Change-Id: I08a5d99a164e4e4f2cf44236be0ece94e16e7c57
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2276
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
src/plugins/ctf/common/metadata/parser.y
This page took 0.024286 seconds and 4 git commands to generate.