Uploaded image for project: 'CFEngine Community'
  1. CFEngine Community
  2. CFE-3417

Fix cast-function-type warnings

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Done
    • Priority: Lowest
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.18.0
    • Component/s: None
    • Labels:

      Description

      Remove exception from here and fix warnings:

      https://github.com/cfengine/core/blob/fe5cbc8693e1c2aadbb3eebbbf9832809eeae914/tests/static-check/run_checks.sh#L11

      With a recent gcc compiler, this is the command to compile core, with warning exceptions:

      make CFLAGS="-Wall -Wextra -Werror -Wno-sign-compare -Wno-implicit-fallthrough -Wno-cast-function-type -Wno-type-limits"
      

      Remove -Wno-cast-function-type and compile again and you should get some warnings:

      $ make CFLAGS="-Wall -Wextra -Werror -Wno-sign-compare -Wno-implicit-fallthrough -Wno-type-limits"
      [...]
        CC       generic_agent.lo
      generic_agent.c: In function ‘GenericAgentShowContextsFormatted’:
      generic_agent.c:2210:18: error: cast between incompatible function types from ‘int (*)(const char *, const char *)’ to
      int (*)(const void *, const void *, void *)’ [-Werror=cast-function-type]
       2210 |     SeqSort(seq, (SeqItemComparator)strcmp, NULL);
            |                  ^
      generic_agent.c: In function ‘GenericAgentShowVariablesFormatted’:
      generic_agent.c:2290:18: error: cast between incompatible function types from ‘int (*)(const char *, const char *)’ to
      int (*)(const void *, const void *, void *)’ [-Werror=cast-function-type]
       2290 |     SeqSort(seq, (SeqItemComparator)strcmp, NULL);
            |                  ^
      cc1: all warnings being treated as errors
      make[3]: *** [Makefile:1008: generic_agent.lo] Error 1
      make[2]: *** [Makefile:783: all] Error 2
      make[1]: *** [Makefile:711: all-recursive] Error 1
      make: *** [Makefile:600: all] Error 2
      $ gcc --version
      gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
      Copyright (C) 2019 Free Software Foundation, Inc.
      This is free software; see the source for copying conditions.  There is NO
      warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
      
      $
      

      When you change a flag / make command, remember to run make clean to ensure you recompile all the binaries.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Alias Georgios Kotzampopoulos
                Reporter:
                olehermanse Ole Herman Schumacher Elgesem
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Summary Panel