Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-15294

Minor bugs in pcre.m4

XMLWordPrintable

    • Sprint 47, Dec 2018
    • 0.125

      There are bugs in file m4/pcre.m4 when pcre_compile() is called.
      The bugs slip through C compiler (gcc) as warnings

      conftest.c: In function 'main':
      conftest.c:185:1: warning: old-style function definition [-Wold-style-definition]
      conftest.c:190:49: warning: passing argument 3 of 'pcre_compile' from incompatible pointer type [-Wincompatible-pointer-types]
        pcre *regexp = pcre_compile("test", PCRE_UTF8, error, error_offset, 0);
                                                       ^~~~~
      In file included from conftest.c:182:
      /usr/include/pcre.h:540:21: note: expected 'const char **' but argument is of type 'const char *'
       PCRE_EXP_DECL pcre *pcre_compile(const char *, int, const char **, int *,
                           ^~~~~~~~~~~~
      conftest.c:190:56: warning: passing argument 4 of 'pcre_compile' makes pointer from integer without a cast [-Wint-conversion]
        pcre *regexp = pcre_compile("test", PCRE_UTF8, error, error_offset, 0);
                                                              ^~~~~~~~~~~~
      In file included from conftest.c:182:
      /usr/include/pcre.h:540:21: note: expected 'int *' but argument is of type 'int'
       PCRE_EXP_DECL pcre *pcre_compile(const char *, int, const char **, int *,
                           ^~~~~~~~~~~~
      

      but are stopped by C++ compiler (g++):

      conftest.c: In function 'int main()':
      conftest.c:192:49: error: cannot convert 'const char*' to 'const char**'
        pcre *regexp = pcre_compile("test", PCRE_UTF8, error, error_offset, 0);
                                                       ^~~~~
      In file included from conftest.c:184:
      /usr/include/pcre.h:540:53: note:   initializing argument 3 of 'pcre* pcre_compile(const char*, int, const char**, int*, const unsigned char*)'
       PCRE_EXP_DECL pcre *pcre_compile(const char *, int, const char **, int *,
                                                           ^~~~~~~~~~~~~
      

      It can be fixed with patch

      Index: m4/pcre.m4
      ===================================================================
      --- m4/pcre.m4	(revision 87676)
      +++ m4/pcre.m4	(working copy)
      @@ -20,7 +20,7 @@
       [
       	const char* error = NULL;
       	int error_offset = -1;
      -	pcre *regexp = pcre_compile("test", PCRE_UTF8, error, error_offset, 0);
      +	pcre *regexp = pcre_compile("test", PCRE_UTF8, &error, &error_offset, NULL);
       	pcre_free(regexp);
       ],
       found_libpcre="yes")
      

            asitals Andrejs Sitals (Inactive)
            andris Andris Mednis
            Team A
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: