Replaced names to match selected naming convention.
Now, running LCLint in checks mode detects no anomalies.
Running with +strict reports 115 anomalies.
Five of them concern type definitions:
eref.h:9,36: Type exported, but not specified: erefStatus A type is exported, but not specified. Use -exporttype to suppress message. eref.h:14,3: Type exported, but not specified: erefTable < checking empset.c > erc.h:7,67: Type exported, but not specified: ercElem erc.h:8,18: Type exported, but not specified: ercList erc.h:9,55: Type exported, but not specified: ercInfoThe two types in eref.h can be moved to eref.c. There is no need for these types to be exported.
The three types in erc.h are used in macros defined in erf.h Hence, they cannot be moved to erc.c. They shouldn't be part of the interface though, so are not documented in the specification. We add -exporttype comments around the type declarations.
Another 5 messages concern functions. The functions bool_initMod, bool_unparse, bool_not, bool_equal, and check are not specified. We add a specification file bool.lcl containing specifications of the boolean function, and check.lcl containing a specification of check.
The other 7 (of the original 9, two are no longer reported since the declarations of ST_USED and ST_AVAIL were moved with the erefStatus type definition) messages concern constants.
All of these are "pre-processor" constants, that are used to prevent multiple inclusion of header files. Instead of adding them to the specifications, we use the -exportconstant flag to suppress the messages.
employee.lcl:49: Modifies list for employee_initMod uses global internal state, not included in globals list. A global variable is used in the modifies clause, but it not listed in the globals list. The variable will be added to the globals list. Use -warnmissingglobs to suppress message. employee.lcl:49: Specification of employee_initModNormally, a variable (or special state) that appears in a modifies clause but no in the globals list is added to the globals list silently. In strict mode, a message is reported. We add internalState to the globals lists for employee_initMod. The other six messages are fixed similarly.
dbase.c: (in function db_keyGet) dbase.c:68,26: Undocumented use of file static db A checked global variable is used in the function, but not listed in its globals clause. By default, only globals specified in .lcl files are checked. To check all globals, use +allglobals. To check globals selectively use /*@checked@*/ in the global declaration. Use -globs to suppress message.This message was not reported earlier, since db_keyGet is declared with no globals list. Without +globnoglobs and +impcheckedstrictstatics (both are set on in strict mode) this message would not be produced.
We add /*@globals db@*/ to the declaration of db_keyGet. This propagates to produce two new messages:
dbase.c: (in function db_hire) dbase.c:119,23: Called procedure db_keyGet may access file static db A checked global variable is used in the function, but not listed in its globals clause. By default, only globals specified in .lcl files are checked. To check all globals, use +allglobals. To check globals selectively use /*@checked@*/ in the global declaration. Use -globs to suppress message. dbase.c: (in function db_setSalary) dbase.c:228,8: Called procedure db_keyGet may access file static dbWe add globals lists to db_hire and db_setSalary. After this, no undocumented globals use messages are reported.
These changes propagate, leading us to add internalState to the globals and modifies lists of several other functions: empset_union, empset_intersect, db_addEmpls, and db_query.
We add modifies clauses to the unconstrained (file static) functions empset_get, int_toSize, and db_ercKeyGet. The shorthand /*@*/ is used to indicate the function uses no global state and modifies nothing.
We add db to the source-code modifies clauses for db_uncheckedHire, db_fire and db_promote.
Six sizeoftype messages are reported. For example,
eref.c: (in function eref_alloc) eref.c:32,48: Parameter to sizeof is type employee: sizeof(employee) Parameter to sizeof operator is a type. (Safer to use expression, int *x = sizeof (*x); instead of sizeof (int).) Use -sizeoftype to suppress message.We fix these by using expression arguments to the sizeof operator, as suggested by the error message.
bool.h: (in macro bool_initMod) bool.h:24,1: Macro definition for bool_initMod is empty A macro definition has no body. Use -macroempty to suppress message.Empty macro bodies can cause syntax problems, so we replace the definition with, do { ; } while (FALSE).
We add the -exportlocal flag to suppress these messages.