Uploaded image for project: 'SonarCFamily'
  1. SonarCFamily
  2. CPP-3427

S5008: fix false-positives with void* in callback signatures

    XMLWordPrintable

    Details

    • Type: False-Positive
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 6.0
    • Fix Version/s: 6.30
    • Component/s: C, C++, Rules
    • Labels:
      None

      Description

      The rule must not flag functions that have to correspond to a pre-selected signature: if they are passed as a callback with the fixed type (callback of a type that is a template parameter is fine). More often than not, this happens across a library interface, so the developer has to define a function with a specific signature whether it complies with our rule or not.

      typedef void (*TaskFunction_t)( void * );
      
      void myTask(void *p) {
          (void)*p;
      }
      
      void bar(TaskFunction_t task);
      
      void foo() {
          bar(&myTask);
      }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              frederic.tingaud Frédéric Tingaud
              Reporter:
              arseniy.zaostrovnykh Arseniy Zaostrovnykh
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: