Uploaded image for project: 'Rules Repository'
  1. Rules Repository
  2. RSPEC-5293

Format strings should comply with ISO standards

    XMLWordPrintable

    Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Default Severity:
      Minor
    • Impact:
      Low
    • Likelihood:
      Low
    • Default Quality Profiles:
      Sonar way, MISRA C++ 2008 recommended
    • Covered Languages:
      C, C++, Objective-C
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      15min
    • Analysis Level:
      Semantic Analysis

      Description

      The possibilities of ISO C printf format strings are limited, this is why many extensions have been added by several implementations. Even though they are widespread and similar in many implementations, they are not standard, which means that using them may create portability issues.

      This rule reports an issue when format strings do not comply with ISO C standards.

      Noncompliant Code Example

      void test() {
        printf("%1$d", 1); // Noncompliant; positional arguments are not supported by ISO C
        printf("%qd", (long long)1); // Noncompliant; length specifier "q" is not supported by ISO C
      }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              amelie.renard Amélie Renard
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated: