Hauptinhalt

Defekte hinsichtlich der guten Codierungspraxis

Defekte, deren Meldung es Ihnen ermöglicht, gute Codierungspraktiken einzuhalten, wie z. B. die Detektion von hart codierten Speicherpuffergrößen oder unbenutzten Funktionsparametern

Die Meldung dieser Defekte ermöglicht es Ihnen, gute Codierungspraktiken einzuhalten. Die Defekte weisen manchmal auf schwerwiegendere logische Fehler in Ihrem Code hin, auch wenn die ihnen zugrunde liegenden Fehler vielleicht keinen Absturz verursachen. Bei solchen Defekten ist Ihr Code außerdem anfällig für Angriffe und schwer zu pflegen. Zu diesen Defekten gehören:

  • Fest kodierte Konstanten wie Puffergröße und Schleifenbegrenzung

  • Probleme, die die Lesbarkeit des Codes behindern

  • Mögliche Codierungsfehler

  • Fehlende const

Polyspace-Ergebnisse

alle erweitern

Ambiguous declaration syntaxDeclaration syntax can be interpreted as object declaration or part of function declaration
Incorrectly indented statementStatement indentation incorrectly makes it appear as part of a block
Invalid scientific notation formatthe use of an invalid format makes the code less readable (Seit R2022b)
Line with more than one statementMultiple statements on a line
Duplicated codeA section of code is duplicated in other places (Seit R2023a)
Partially duplicated codeA section of code is duplicated in other places with very minor changes (Seit R2023a)
Hard-coded buffer sizeSize of memory buffer is a numerical value instead of symbolic constant
Hard-coded loop boundaryLoop boundary is a numerical value instead of symbolic constant
Hard-coded object size used to manipulate memoryMemory manipulation with hard-coded size instead of sizeof
Method not constA method that can be made const is not marked const (Seit R2022a)
Public static field not constA static and public field of a struct or class is not marked as a const (Seit R2022a)
Unmodified variable not const-qualifiedVariable not const-qualified but variable value not modified during lifetime
Macro terminated with a semicolonMacro definition ends with a semicolon
Macro with multiple statementsMacro consists of multiple semicolon-terminated statements, enclosed in braces or not
Missing break of switch casecase block of switch statement does not end in a break, [[fallthrough]] or explanatory comment
Possibly inappropriate data type for switch expressionswitch expression has a data type other than char, short, int or enum
Semicolon on same line as if, for or while statementSemicolon on same line results in empty body of if, for or while statement
Delete of void pointerdelete operates on a void* pointer pointing to an object
Missing overload of allocation or deallocation functionOnly one function in an allocation-deallocation function pair is overloaded
Missing reset of a freed pointerPointer free not followed by a reset statement to clear leftover data
C++ reference to const-qualified type with subsequent modificationReference to const-qualified type is subsequently modified
C++ reference type qualified with const or volatileReference type declared with a redundant const or volatile qualifier
Declaration of catch for generic exceptionA catch block handles a generic exception that might have many different subtypes (Seit R2022a)
Declaration of throw for generic exceptionA function throws a generic exception, which might have many subtypes (Seit R2022a)
Reference to un-named temporaryLocal reference is declared by using unnamed temporary variable that a function returns by value (Seit R2023a)
Incorrect syntax of flexible array member sizeFlexible array member defined with size zero or one
Use of a forbidden functionUse of function that appears in a blocklist of forbidden functions
Use of a forbidden keywordUse of keyword that appears in a blocklist of forbidden keywords (Seit R2022a)
Use of a forbidden macroUse of macro that appears in a blocklist of forbidden macros (Seit R2022b)
Use of setjmp/longjmpsetjmp and longjmp cause deviation from normal control flow
Bitwise and arithmetic operation on the same dataStatement with mixed bitwise and arithmetic operations
File does not compileFile has a compilation error (Seit R2021a)
Unused parameterFunction prototype has parameters not read or written in function body
Unused variableVariable defined or declared but not read (Seit R2024a)
Useless expressions in sizeof operandsizeof operand contains expression that is not evaluated
Useless includeAn include directive is present but not used (Seit R2022b)
Useless captureLambda captures objects but does not use the objects (Seit R2024b)

Themen

  • Bug Finder Defect Groups

    The Bug Finder defect checkers are classified into groups such as data flow, concurrency, numerical, and so on.