这是集中地处理程序中的一类错误的策略. 尤其是对于legacy 的code, pc-lint的默认输出信息量将会是的巨大的, 我碰过10万行C++代码, 产生200多MB的pc-lint警告信息的情况.
这一用法的关键是处理完这一类错误之后, 马上关掉 -e* 这个开关. 否则你会丧失pc-lint 对所有其它类型的潜在错误发出警告的好处.
-e* 选项是禁止所有警告. 这个选项本身会引起一个警告:
Warning 686: Option '-e*' is suspicious because of 'blanket suppression can hide configuration problems'
而且这个编号 686的警告本身是无法被禁用掉的. 这也说明pc-lint不建议在最终的配置文件中使用-e*
另一个类似的警告是 -wlib(0), pc-lint同样不建议将与库相关的警告级别调至0(意味着关闭所有警告), 它引发的错误信息是
Warning 686: Option '-wlib(0)' is suspicious because of 'blanket suppression can hide configuration problems'
但关于这个, 我个人却倾向于在配置文件中永久性地使用它, 原因是那是关于库代码的. 比如VC++的头文件, SDK的头文件, 第三方软件库的头文件. 这些地方即使引发警告, 你又能干什么呢?
各个击破, 并不就意味着只通过 +e577 之类的选项打开单单一个警告. 有可能是一族相关的警告. 比如printf/scanf 函数族中经常会出现的格式错误, 就有相关的警告如下:
+e557
+e558
+e559
+e560
+e561
+e566
+e567
+e592 // Non-literal format specifier used without arguments -- A
// argument no. Integer inconsistent with format -- The argument to
// a printf (or fprintf or sprintf) was inconsistent with the
// format. Although the size of the quantity was appropriate the
// type was not. You might consider casting the quantity to the
// correct type. You could also suppress this message, as more
// flagrant violations are picked up with warning 559.
+e626
// (arg. no. Integer) indirect object inconsistent with format --
// The type of an argument to scanf (or fscanf or sscanf) was
// inappropriate to the format. However, the argument was a pointer
// and it pointed to a quantity of the expected size.
+e627
// Format char 'Char' not supported by wsprintf -- This means that
// you are using an option of the form: -printf(w... and you are
// using a format character not supported by the Microsoft Windows
// function wsprintf. If you are not really using wsprintf but are
// using the w flag to get far pointers you should turn this message
// off.
+e642
// Argument no. Integer nominally inconsistent with format -- The
// argument to a printf (or fprintf or sprintf) was nominally
// inconsistent with the format. Although the size of the quantity
// was appropriate the type was similar, but not exact. (E.g.,
// passing a long to a %d or an int to a %x) You might consider
// casting the quantity to the correct type. You could also
// suppress this message, as more flagrant violations are picked up
// with warnings 559 and 626.
+e705
// (arg. no. Integer) indirect object inconsistent with format --
// The type of an argument to scanf (or fscanf or sscanf) was
// inappropriate to the format. However, the argument was a pointer
// and it pointed to a quantity of the expected size and similar,
// but not expected type.
+e706
// Too many arguments for format (Integer too many) -- The number
// of arguments to a function in the printf/scanf family was more
// than what is specified in the format. This message is similar to
// Warning 558 which alerts users to situations in which there were
// too few arguments for the format. It receives a lighter
// Informational classification because the additional arguments are
// simply ignored.
+e719
// Non-ANSI format specification -- A non-standard format specifier
// was found in a format-processing function such as printf or
// scanf. Such a specifier could be unique to a particular compiler
// or could be a de facto standard but is not ANSI.
+e816
+e905 // Non-literal format specifier used (with arguments) -- A
阅读(7237) | 评论(0) | 转发(0) |