Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Version number:
1.2

C checkers

Guideline

callfmt

DCL11-C. Understand the type issues associated with variadic functions

castexpr

EXP05-C. Do not cast away a const qualification

castexpr

EXP36-C. Do not convert pointers into more strictly aligned pointer types

CC2.API08

API08-C. Avoid parameter names in a function prototype

CC2.ARR02

ARR02-C. Explicitly specify array bounds, even if implicitly defined by an initializer

CC2.EXP37 DCL00

EXP37DCL00-C. Call functions with the correct number and type of argumentsConst-qualify immutable objects

CC2.INT12 DCL01

INT12DCL01-C. Do not make assumptions about the type of a plain int bit-field when used in an expressionreuse variable names in subscopes

CC2.PRE00 DCL02

PRE00DCL02-C. Prefer inline or static functions to function-like macrosUse visually distinct identifiers

CC2.STR36 DCL03

STR11DCL03-C. Do not specify the bound of a character array initialized with a string literal

charcast

STR34-C. Cast characters to unsigned char before converting to larger integer sizes

charsgnd

STR04-C. Use plain char for characters in the basic character set

cmntdout_tokenuse

MSC04-C. Use comments consistently and in a readable fashion

cnstpnte

DCL00-C. Const-qualify immutable objects

Use a static assertion to test the value of a constant expression

CC2.DCL04

DCL04-C. Do not declare more than one variable per declaration

CC2.DCL06

DCL06-C. Use meaningful symbolic constants to represent literal values

CC2.DCL07

DCL07-C. Include the appropriate type information in function declarators

CC2.DCL11

DCL11-C. Understand the type issues associated with variadic functions

CC2.DCL13 cnstpnte

DCL13-C. Declare function parameters that are pointers to values not changed by the function as const

CC2.DCL15

DCL15-C. Declare file-scope objects or functions that do not need external linkage as static

CC2.DCL16

DCL16

conststr

STR05-C. Use pointers to const when referring to string literals"L," not "l," to indicate a long value

CC2.DCL19

DCL19-C. Minimize the scope of variables and functions

CC2.DCL31

DCL31-C. Declare identifiers before using them

CC2.DCL36

DCL36

cplxcall

VOID FLP31-C. Do not call functions expecting real values with complex valuesdeclare an identifier with conflicting linkage classifications

CC2.DCL37

DCL37

declgrup_srceline

DCL04-C. Do not declare more than one variable per declarationor define a reserved identifier

CC2.ERR01

ERR01-C. Use ferror() rather than errno to check for FILE stream errors

CC2.EXP00

EXP00-C. Use parentheses for precedence of operation

CC2.EXP05

EXP05-C. Do not cast away a const qualification

CC2.EXP06

EXP44

declhidn

DCL01-C. Do not reuse variable names in subscopes

decltype

DCL07-C. Include the appropriate type information in function declarators

decltype

DCL31-C. Declare identifiers before using them

dtrigraf

PRE07-C. Avoid using repeated question marks

emptloop

void MSC40-C. Do not use an empty infinite loop

enuminit

INT09-C. Ensure enumeration constants map to unique values

rely on side effects in operands to sizeof, _Alignof, or _Generic

CC2.EXP09

EXP09-C. Use sizeof to determine the size of a type or variable

CC2.EXP12

EXP12-C. Do not ignore values returned by functions

CC2.EXP13

EXP13-C. Treat relational and equality operators as if they were nonassociative

CC2.EXP14

EXP14-C. Beware of integer promotion when performing bitwise operations on integer types smaller than int

CC2.EXP18

EXP45-C. Do not perform assignments in selection statements

CC2.EXP21

EXP21-C. Place constants on the left of equality comparisons

CC2.EXP30 evalordr

EXP30-C. Do not depend on order of evaluation for side effects

CC2.EXP31

VOID EXP31

exprctxt

EXP45-C. Do not perform assignments in selection statementsside effects in assertions

CC2.EXP31

PRE31-C. Avoid side effects in arguments to unsafe macros

CC2.EXP36

EXP36

exprctxt

MSC05-C. Do not manipulate time_t typed values directly

exprprns

EXP00-C. Use parentheses for precedence of operation

exprprns

EXP13-C. Treat relational and equality operators as if they were nonassociative

filscope

DCL15-C. Declare file-scope objects or functions that do not need external linkage as static

filscope

DCL19-C. Minimize the scope of variables and functions

floateql

FLP06-C. Understand that floating-point arithmetic in C is inexact

convert pointers into more strictly aligned pointer types

CC2.EXP37

EXP37-C. Call functions with the correct number and type of arguments

CC2.FIO04

VOID FIO04-C. Detect and handle input and output errors

CC2.FIO07

void FIO07-C. Prefer fseek() to rewind()

CC2.FIO12

void FIO12-C. Prefer setvbuf() to setbuf()

CC2.FIO34

FIO34-C. Distinguish between characters read from a file and EOF or WEOF

CC2.FIO34

FIO34-C. Distinguish between characters read from a file and EOF or WEOF

CC2.FLP00

FLP00-C. Understand the limitations of floating-point numbers

CC2.FLP06

FLP06-C. Convert integers to floating point for floating-point operations

CC2.FLP30 forcntrl

FLP30-C. Do not use floating-point variables as loop counters

funcalls

EXP09-C. Use sizeof to determine the size of a type or variable

CC2.FLP31

VOID FLP31-C. Do not call functions expecting real values with complex values

CC2.INT02

INT02-C. Understand integer conversion rules

CC2.INT07

INT07-C. Use only explicitly signed or unsigned char type for numeric values

CC2.INT09

INT09-C. Ensure enumeration constants map to unique values

CC2.INT12

INT12-C. Do not make assumptions about the type of a plain int bit-field when used in an expression

CC2.INT13

INT13-C. Use bitwise operators only on unsigned operands

CC2.INT34

INT34-C. Do not shift a negative number of bits or more bits than exist in the operand

CC2.MEM02 funcalls

MEM02-C. Immediately cast the result of a memory allocation function call into a pointer to the allocated type

funcalls CC2.MEM08

void MEM08-C. Use realloc() only to resize dynamically allocated arrays

funparid CC2.MSC04

API08MSC04-C. Avoid parameter names Use comments consistently and in a function prototypereadable fashion

CC2.MSC05

MSC05

hedrname

PRE04-C. Do not reuse a standard header file namemanipulate time_t typed values directly

CC2.MSC12

MSC12

hedrname

PRE08-C. Guarantee that header file names are unique

idb_charplan

INT07-C. Use only explicitly signed or unsigned char type for numeric values

idb_charplan

STR37-C. Arguments to character-handling functions must be representable as an unsigned char

idntsiml

DCL02-C. Use visually distinct identifiers

ignrrtrn

FIO04-C. Detect and handle input and output errors

ignrrtrn

void FIO34-C. Use int to capture the return value of character IO functions that might be used to check for end of file

ignrtrn

EXP12-C. Do not ignore values returned by functions

inclgard

PRE06-C. Enclose header files in an inclusion guard

intllnkg

DCL36-C. Do not declare an identifier with conflicting linkage classifications

ltrlsynt

DCL16-C. Use "L," not "l," to indicate a long value

Detect and remove code that has no effect

CC2.MSC17

MSC17-C. Finish every set of statements associated with a case label with a break statement

CC2.MSC20

MSC20-C. Do not use a switch statement to transfer control into a complex block

CC2.MSC30

MSC30-C. Do not use the rand() function for generating pseudorandom numbers

CC2.MSC34

MSC24-C. Do not use deprecated or obsolescent functions

CC2.MSC40

MSC06-C. Beware of compiler optimizations

CC2.MSC40

MSC40-C. Do not violate constraints

CC2.PRE00

PRE00-C. Prefer inline or static functions to function-like macros

CC2.PRE01 macrbody

PRE01-C. Use parentheses within macros around parameter names

macrbody CC2.PRE02

PRE02-C. Macro replacement lists should be parenthesized

macrbody

PRE12-C. Do not define unsafe macros

CC2.PRE03

PRE03

macrcall

DCL03-C. Use a static assertion to test the value of a constant expressionPrefer typedefs to defines for encoding types

CC2.PRE04

PRE04

macrcall

VOID EXP31-C. Do not perform side effects in assertions

macrcall

PRE31-C. Do not perform side effects in arguments to unsafe macros

macrcall

PRE32-C. Do not use preprocessor directives inside macro arguments

macrexpd

PRE03-C. Prefer typedefs to defines for encoding types

noeffect

MSC12-C. Detect and remove code that has no effect

nomagicc

DCL06-C. Use meaningful symbolic constants to represent literal values

optrargs

EXP21-C. Place constants on the left of equality comparisons

optrargs

INT13-C. Use bitwise operators only on unsigned operands

resvidnt_resvmacr

DCL37-C. Do not declare or define a reserved identifier

shiftrhs

INT34-C. Do not shift a negative number of bits or more bits than exist in the operand

stlibuse

ERR01-C. Use ferror() rather than errno to check for FILE stream errors

stlibuse

FIO07-C. Prefer fseek() to rewind()

stlibuse

FIO12-C. Prefer setvbuf() to setbuf()

stlibuse

MSC30-C. Do not use the rand() function for generating pseudorandom numbers

stlibuse

MSC24-C. Do not use deprecated or obsolescent functions

reuse a standard header file name

CC2.PRE06

PRE06-C. Enclose header files in an inclusion guard

CC2.PRE07

PRE07-C. Avoid using repeated question marks

CC2.PRE08

PRE08-C. Guarantee that header file names are unique

CC2.PRE12

PRE12-C. Do not define unsafe macros

CC2.PRE31

PRE31-C. Avoid side effects in arguments to unsafe macros

CC2.PRE32

PRE32-C. Do not use preprocessor directives in invocations of function-like macros

CC2.STR04

STR04-C. Use plain char for characters in the basic character set

CC2.STR05

STR05-C. Use pointers to const when referring to string literals

CC2.STR10

stltccat

STR10-C. Do not concatenate different type of string literals

swchsynt CC2.STR34

MSC17STR34-C. Finish every set of statements associated with a case label with a break statementCast characters to unsigned char before converting to larger integer sizes

CC2.STR36

STR11

swchsynt

MSC20-C. Do not use a switch statement to transfer control into a complex block

unexfct

EXP44-C. Do not use side effects in operands to sizeof, _Alignof, or _Generic

utypbtws

EXP14-C. Beware of integer promotion when performing bitwise operations on integer types smaller than int

specify the bound of a character array initialized with a string literal

CC2.STR37

STR37-C. Arguments to character-handling functions must be representable as an unsigned char

utypbtws

INT02-C. Understand integer conversion rules