Files
svc.ems/include/Makefile.splint
2024-03-13 09:30:40 +08:00

288 lines
10 KiB
Makefile

##----------------------------------------------------------##
## ##
## Universal Makefile Splint Function ##
## ##
## Created : Wei Liu 07/05/20 ##
## Revision: [Last]Wei Liu 07/07/07 ##
## ##
##----------------------------------------------------------##
##--------------------------------------
##
## Make splinting program flags
##
##--------------------------------------
##是否有提示信息
SFLAG_HINTS := #-hints
##是否用库信息代替头文件
SFLAG_INCLUDE := +single-include
#+never-include
##包含什么库
SFLAG_LIB := +posixlib
##+nolib +nof -warnposix
##+unixlib
##+posixlib
#+nolib +nof -warnposix
##+nof
##+unixlib
##+which_lib
##
SFLAG_DUMP :=
##dump ./include/public.h ./include/pub_base.h ./include/includes.h
SFLAG_LOAD :=
##+load /usr/share/splint/lib/unixstrict.lcd
##load ./include/public.h ./include/pub_base.h ./include/includes.h
SFLAG_DIR :=
##-I/work/r9/plat/public/src/include/splint
##-I/work/r9/plat/public/src/include/splint
##-I /usr/local/work/r9/plat/public/src/include/
##检查模式
SFLAG_TYPE := -strict
##略过的头文件
SFLAG_SYS_HEADERS := +skip_sys_headers
SFLAG_ISO_HEADERS :=
#+skip_iso_headers
SFLAG_POSIX_HEADERS :=
##+skip_posix_headers
##每个头文件只检查一次
SFLAG_SINGLE_INCLUDE := +singleinclude
##系统文件目录
SFLAG_SYS_DIR :=
##+sys-dirs /work/r9/plat/public/src/include/splint
##函数参数有原型
SFLAG_PROTO_PARAMNAME := -protoparamname
##变量名是否为保留名
SFLAG_UNDERSCORE := -isoreserved -isoreservedinternal
## 在"/*"和"*/"中再次使用"/*"和"*/"
SFLAG_NESTCOMMENT := -nestcomment
##允许未说明导出变量、函数和类型
SFLAG_EXPORT_VAR := -exportvar
SFLAG_EXPORT_FCN := -exportfcn
SFLAG_EXPORT_TYPE := -exporttype
SFLAG_EXPORT_CONST := -exportconst
##允许其他类型定义为BOOL型
SFLAG_LIKELY_BOOL := -likelybool
##两种类型相等
SFLAG_CHAR_INT := +charint
SFLAG_BOOL_INT := +boolint
##Report memory transfer errors for initializations to read-only string literals
SFLAG_READONLY_TRANS := -readonlytrans
##A string literal is assigned to a char array that smaller than the string literal needs
SFLAG_STRING_SMALLER := -stringliteralsmaller
##A variable declared outside a macro body starts with the macro-var-prefix
SFLAG_MACRO_PREFIX := -macrovarprefixexclude
##Initializer does not define all elements of a declared array
SFLAG_INITAL_ELEMENT := -initallelements
##类型匹配
SFLAG_PARAM_TYPE := -type
##Report modification errors in functions declared without a modifies clause
SFLAG_MODIFY := -modnomods
##Use of a checked global in a function with no globals list
SFLAG_GLOBAL := -glob-noglobs
##Use of internal state in function with no globals list
SFLAG_INTERNAL_GLOBS := -internal-globs-noglobs
##Implicit checked qualifier on global variables and qualifier file static scope variables with no checking annotation
SFLAG_CHECK_GLOBAL := -imp-checkedstrict-globs -imp-checkedstrict_statics
##Undocumented modification of a checked global variable in a function with no modifies clause
SFLAG_CHECK_GLOBAL_MODIFY := -mod-globs-nomods
##Storage declared with observer may be modified through a call to an unconstrained function
SFLAG_OBSERVER_MODIFY := -mod-observer-uncon
##忽略返回值
SFLAG_IGNORE_RETVAL := -retval
##while,if and for statement is not a block
SFLAG_WHILE_BLOCK := -whileblock
SFLAG_IF_BLOCK := -ifblock
SFLAG_FOR_BLOCK := -forblock
##There is no finals else following an else if construct
SFLAG_ELSEIF_COMPLETE := -elseifcomplete
##允许指针进行数学运算
SFLAG_POINT_ARITH := -ptrarith -nullptrarith
##An unconstrained function is called in a function body where modifications are checked.
SFLAG_UNCONSTRAIN_MODIFY := -mod-uncon-nomods
##NO effect of unconstrained functions
SFLAG_EFFECT_UNCONSTRAIN := -no-effect-uncon
##Type-mismatch in parameter corresponding to format code in a printflike or scanflike function
SFLAG_FORMAT-TYPE := -format-type
##An actual parameter that is passed as a unique formal parameter is aliased by another parameter or global variable
SFLAG_ALIASING := -alias-unique -ret-alias#-may-alias-unique
##Transfer Errors flag
SFLAG_STORAGE_TRANSFER := -onlytrans -temptrans -unqualified-trans -immediatetrans
##Report errors for break statements inside a nested while, for or switch
SFLAG_DEEP_BREAK := -deep-break #-switch-switch-break -loop-loop-break
##Storage has inconsistent states of alternate paths through a branch
SFLAG_INCONSISTENT_BRANCH := -branch-state
##There is a non-empty case in a switch not followed by a break.
##Likely infinite loop is detected
##Likely infinite loop is detected. Loop test or body calls an unconstrained function that may produce an undetected modification
SFLAG_PROBLEMATIC_CTR := -case-break -infloops -infloopsuncon
##An expression may be undefined because a sub-expression contains a call to an unconstrained function (no modifies clause)
##that may modify something that may be modified or used by another sub-expression
SFLAG_UNDEFINED_EVALORDER := -eval-order-uncon
##Only storage transferred to an unqualified global or static reference.
##This may lead to a memory leak, since the new reference is not necessarily released
SFLAG_INITIALIZERS := -only-unq-global-trans
##Primitive operation does not type check strictly
SFLAG_PRIMITIVE_OPERA := -strict-ops -bitwise-signed
##Unused Declarations (未使用的声明)
SFLAG_DECLARARIONS := -field-use -fcnuse -param-use -typeuse -varuse -enummemuse
##Function, variable, iterator or constant declared but never defined (未初始化)
SFLAG_COMPLETE_PRG := -decl-undef
##A declaration is exported but not used outside this module or not appear in a header file
SFLAG_EXPORTS := -export-local -export-header
##把warning输出到文件splint_warn中
SFLAG_WARN_FILE := #+warning-stream splint_warn
##把致命错误输出到文件splint_error中
SFLAG_ERROR_FILE := #+error-stream splint_error
##文件覆盖
SFLAG_STREAM_OVERWRITE := -streamoverwrite
##An abstract type defined in M.h (or specified in M.lcl) is accessible in M.c
SFLAG_ACCESS := -access-module
##Function definition is in old style syntax. Standard prototype syntax is preferred.
SFLAG_ISO_CONFORMANCE := #-old-style
##Use of function that may lead to buffer overflow
SFLAG_BUFFER := -bufferoverflowhigh
##A function is declared without a parameter list prototype
SFLAG_FUNC_NOPARAM := -noparams
##Operand of sizeof operator is a type
SFLAG_SIZEOF_TYPE := -sizeoftype
##Storage derivable from a parameter, return value or global variable is not completely defined
SFLAG_COMP_DEF := -compdef
##Behavior of an expression is unspecified or implementation-dependent
##because sub-expressions contain interfering side effects that may be evaluated in any order
SFLAG_EVAL_ORDER := -eval-order
##try to recover code
SFLAG_TRY_TO_RECOVER := #+trytorecover
##返回一个NULL指针
SFLAG_NULL_RET := -nullret
##A possibly null pointer is reachable from a parameter or global variable that is not declared using a /*@null@*/ annotation
SFLAG_NULL_STATE := -nullstate
##The value of a location that may not be initialized on some execution path is used
SFLAG_USE_BEFORE_DEF := -usedef
##编译时不知道参数类型 Format parameter is not known at compile-time 例如:sprintf(mgcpAsciTempBuf, msg)
SFLAG_FORMAT_CONST := -format-const
##Argument to exit has implementation defined behavior. The only valid arguments to exit are EXIT_SUCCESS, EXIT_FAILURE and 0.
##An error is reported if Splint can determine statically that the argument to exit is not one of these
SFLAG_EXIT_ARG := -exitarg
##An extern declaration is used inside a function body
SFLAG_EXTERN := -nested-extern
SFLAG_OLD_STTLE := -oldstyle
SFLAG_SHIFT_NEG := -shiftnegative
SFLAG_PREPROC := -preproc
##all splint flags
SPLINT_FLAGS := $(SFLAG_LIB) $(SFLAG_TYPE) $(SFLAG_SYS_HEADERS) $(SFLAG_ISO_HEADERS)\
$(SFLAG_POSIX_HEADERS) $(SFLAG_SINGLEINCLUDE) $(SFLAG_WARN)\
$(SFLAG_UNDERSCORE) $(SFLAG_NESTCOMMENT) $(SFLAG_EVAL_ORDER)\
$(SFLAG_PROTO_PARAMNAME) $(SFLAG_EXPORT_VAR) $(SFLAG_EXPORT_FCN)\
$(SFLAG_EXPORT_TYPE) $(SFLAG_LIKELY_BOOL) $(SFLAG_CHAR_INT)\
$(SFLAG_READONLY_TRANS) $(SFLAG_STRING_SMALLER) $(SFLAG_MACRO_PREFIX)\
$(SFLAG_INITAL_ELEMENT) $(SFLAG_PARAM_TYPE) $(SFLAG_GLOBAL)\
$(SFLAG_CHECK_GLOBAL) $(SFLAG_CHECK_GLOBAL_MODIFY) $(SFLAG_IGNORE_RETVAL)\
$(SFLAG_INTERNAL_GLOBS) $(SFLAG_MODIFY) $(SFLAG_BOOL_INT)\
$(SFLAG_WHILE_BLOCK) $(SFLAG_HINTS) $(SFLAG_IF_BLOCK) $(SFLAG_FOR_BLOCK)\
$(SFLAG_POINT_ARITH) $(SFLAG_ELSEIF_COMPLETE) $(SFLAG_UNCONSTRAIN_MODIFY)\
$(SFLAG_EFFECT_UNCONSTRAIN) $(SFLAG_OBSERVER_MODIFY)\
$(SFLAG_FORMAT-TYPE) $(SFLAG_ALIASING) $(SFLAG_STORAGE_TRANSFER)\
$(SFLAG_DEEP_BREAK) $(SFLAG_INCONSISTENT_BRANCH) $(SFLAG_PROBLEMATIC_CTR)\
$(SFLAG_UNDEFINED_EVALORDER) $(SFLAG_INITIALIZERS) $(SFLAG_PRIMITIVE_OPERA)\
$(SFLAG_DECLARARIONS) $(SFLAG_COMPLETE_PRG) $(SFLAG_EXPORTS) $(SFLAG_INCLUDE)\
$(SFLAG_STREAM_OVERWRITE) $(SFLAG_WARN_FILE) $(SFLAG_ERROR_FILE)\
$(SFLAG_ACCESS) $(SFLAG_ISO_CONFORMANCE) $(SFLAG_BUFFER) $(SFLAG_SIZEOF_TYPE)\
$(SFLAG_COMP_DEF) $(SFLAG_FUNC_NOPARAM) $(SFLAG_TRY_TO_RECOVER)\
$(SFLAG_EXPORT_CONST) $(SFLAG_DUMP) $(SFLAG_LOAD) $(SFLAG_NULL_RET)\
$(SFLAG_NULL_STATE) $(SFLAG_USE_BEFORE_DEF) $(SFLAG_FORMAT_CONST)\
$(SFLAG_EXIT_ARG) $(SFLAG_EXTERN) $(SFLAG_OLD_STTLE) $(SFLAG_DIR)\
$(SFLAG_SHIFT_NEG) $(SFLAG_PREPROC)
##--------------------------------------
##
## MAKE_INDENT template
##
##------------------------------------
define SPLINT_FILE
@echo -e "Splinting: $(notdir $(1)) \t\t\t please wait ..."
@nohup splint $(SPLINT_FLAGS) $(1) | sed '$d' | sed '1,2d' |\
sed '/Splint /d' | sed '/Finished /d' |\
sed '/Cannot continue/d'
endef
##@echo $(SPLINT_FLAGS)
define MAKE_SPLINT
@echo
$(foreach file,$(1),$(call SPLINT_FILE, $(file)))
@echo
@echo =======================================End======================================
endef