SonarSource Rules
  • Products

    In-IDE

    Code Quality and Security in your IDE with SonarQube Ide

    IDE extension that lets you fix coding issues before they exist!

    Discover SonarQube for IDE

    SaaS

    Code Quality and Security in the cloud with SonarQube Cloud

    Setup is effortless and analysis is automatic for most languages

    Discover SonarQube Cloud

    Self-Hosted

    Code Quality and Security Self-Hosted with SonarQube Server

    Fast, accurate analysis; enterprise scalability

    Discover SonarQube Server
  • SecretsSecrets
  • ABAPABAP
  • AnsibleAnsible
  • ApexApex
  • AzureResourceManagerAzureResourceManager
  • CC
  • C#C#
  • C++C++
  • CloudFormationCloudFormation
  • COBOLCOBOL
  • CSSCSS
  • DartDart
  • DockerDocker
  • FlexFlex
  • GitHub ActionsGitHub Actions
  • GoGo
  • HTMLHTML
  • JavaJava
  • JavaScriptJavaScript
  • JSONJSON
  • JCLJCL
  • KotlinKotlin
  • KubernetesKubernetes
  • Objective CObjective C
  • PHPPHP
  • PL/IPL/I
  • PL/SQLPL/SQL
  • PythonPython
  • RPGRPG
  • RubyRuby
  • RustRust
  • ScalaScala
  • ShellShell
  • SwiftSwift
  • TerraformTerraform
  • TextText
  • TypeScriptTypeScript
  • T-SQLT-SQL
  • VB.NETVB.NET
  • VB6VB6
  • XMLXML
  • YAMLYAML
C

C static code analysis

Unique rules to find Bugs, Vulnerabilities, Security Hotspots, and Code Smells in your C code

  • All rules 420
  • Vulnerability14
  • Bug111
  • Security Hotspot19
  • Code Smell276

  • Quick Fix 27
Filtered: 64 rules found
pitfall
    Impact
      Clean code attribute
        1. "goto" should jump to labels declared later in the same function

           Code Smell
        2. Dynamic heap memory allocation should not be used

           Bug
        3. "setjmp" and "longjmp" should not be used

           Code Smell
        4. Macros should not be #define'd or #undef'd within a block

           Code Smell
        5. Object declarations should contain no more than 2 levels of pointer indirection

           Code Smell
        6. Functions without parameters should be declared with parameter type "void"

           Code Smell
        7. Recursion should not be used

           Code Smell
        8. Functions should not be defined with a variable number of arguments

           Code Smell
        9. Constants of unsigned type should have a "U" suffix

           Code Smell
        10. If a function has internal linkage then all re-declarations shall include the static storage class specifer

           Code Smell
        11. Literal suffix "L" for long integers shall be upper case

           Code Smell
        12. Macro arguments should not contain preprocessing directives

           Bug
        13. All the elements of an aggregate should be provided with an initial value

           Code Smell
        14. Macros should not be used as replacements for "typedef" and "using"

           Code Smell
        15. Keywords shall not be used as macros identifiers

           Code Smell
        16. Logical operators should not be confused with bitwise operators

           Code Smell
        17. Include directives should not rely on non-portable search strategy

           Code Smell
        18. "#include" paths should be portable

           Code Smell
        19. Array indices should be placed between brackets

           Code Smell
        20. Bit fields should not be used

           Code Smell
        21. Conditionally executed code should be reachable

           Bug
        22. Control characters should not be used in literals

           Code Smell
        23. Octal and hexadecimal escape sequences should be terminated

           Code Smell
        24. Preprocessor directives should not be indented

           Code Smell
        25. "goto" statements should not be used to jump into blocks

           Code Smell
        26. Related "if/else if" statements should not have the same condition

           Bug
        27. "static" should not be used for the size of an array parameter

           Code Smell
        28. "switch" statements should not be nested

           Code Smell
        29. The sign of an unsigned variable should not be tested

           Code Smell
        30. Octal values should not be used

           Code Smell
        31. "for" loop stop conditions should be invariant

           Code Smell
        32. Control structures should use curly braces

           Code Smell
        33. Variables should not be shadowed

           Code Smell
        34. Control should not be transferred into a complex logic block using a "goto" or a "switch" statement

           Code Smell
        35. An "integer-literal" of type "long long" shall not use a single "L" or "l" in any suffix

           Code Smell
        36. "Integral promotion" and the "usual arithmetic conversions" shall not change the signedness or the "type category" of an operand

           Code Smell
        37. The library function "system" from "<cstdlib>" shall not be used

           Vulnerability
        38. All variables should be initialized

           Code Smell
        39. Octal escape sequences, hexadecimal escape sequences and universal character names shall be terminated

           Code Smell
        40. Dynamic memory shall be managed automatically

           Code Smell
        41. The facilities provided by the standard "header file" "<csignal>" shall not be used

           Code Smell
        42. The macro "offsetof" shall not be used

           Code Smell
        43. The standard "header file" "<csetjmp>" shall not be used

           Code Smell
        44. Precautions shall be taken in order to prevent the contents of a "header file" being included more than once

           Code Smell
        45. Program-terminating functions should not be used

           Code Smell
        46. A named bit-field with "signed integer type" shall not have a length of one bit

           Bug
        47. A bit-field shall have an appropriate type

           Code Smell
        48. Bit-fields should not be declared

           Code Smell
        49. The features of "<cstdarg>" shall not be used

           Code Smell
        50. Functions shall not call themselves, either directly or indirectly

           Code Smell
        51. A function must not return a reference or a pointer to a local variable with automatic storage duration

           Bug
        52. The "goto" statement shall jump to a label declared later in the function body

           Code Smell
        53. A "goto" statement shall reference a label in a surrounding block

           Code Smell
        54. The body of an "iteration-statement" or a "selection-statement" shall be a "compound-statement"

           Code Smell
        55. The comma operator should not be used

           Code Smell
        56. The "declaration" of an object should contain no more than two levels of pointer indirection

           Code Smell
        57. The names of the "standard signed integer types" and "standard unsigned integer types" should not be used

           Code Smell
        58. A "header file" shall not contain definitions of functions or objects that are non-inline and have external linkage

           Code Smell
        59. Tokens that look like a preprocessing directive shall not occur within a macro argument

           Bug
        60. Function-like macros shall not be defined

           Code Smell
        61. The lowercase form of "L" shall not be used as the first character in a literal suffix

           Code Smell
        62. Unsigned "integer literals" shall be appropriately suffixed

           Code Smell
        63. Octal constants shall not be used

           Code Smell
        64. A variable declared in an "inner scope" shall not hide a variable declared in an "outer scope"

           Code Smell

        The facilities provided by the standard "header file" "<csignal>" shall not be used

        intentionality - clear
        maintainability
        Code Smell
        • pitfall
        • misra-c++2023
        • misra-required

        Why is this an issue?

        More Info

        This rule is part of MISRA C++:2023.

        Usage of this content is governed by Sonar’s terms and conditions. Redistribution is prohibited.

        Rule 21.10.3 - The facilities provided by the standard header file [1] <csignal> shall not be used

        [C11] / 7.14.1.1; Undefined 3, 5, 7; Implementation 3, 6; Indeterminate 5
        [Koenig] 74

        Category: Required

        Analysis: Decidable,Single Translation Unit

        Amplification

        None of the facilities that are specified as being provided by <csignal> shall be used.

        Note: this rule also applies to the facilities provided by <signal.h>.

        Rationale

        The inappropriate use of signal handling can lead to undefined and implementation-defined behaviour.

        Note: the C++ Standard states that signal handling behaviour is specified in the related version of ISO 9899 .

        Exception

        Calls to signal with a value of SIG_IGN as the second (func) parameter may be used to disable one or more signals. For example:

        signal( SIGTERM, SIG_IGN );
        

        Glossary

        [1] Header file

        A header file is considered to be any file that is included during preprocessing (for example via the #include directive), regardless of its name or suffix.

        Copyright The MISRA Consortium Limited © 2023

          Available In:
        • SonarQube IdeCatch issues on the fly,
          in your IDE
        • SonarQube CloudDetect issues in your GitHub, Azure DevOps Services, Bitbucket Cloud, GitLab repositories
        • SonarQube ServerAnalyze code in your
          on-premise CI

        © 2025 SonarSource Sàrl. All rights reserved.

        Privacy Policy | Cookie Policy | Terms of Use