checkpatch海思SDK代码遇见的常见错误《二》
Posted coding码场
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了checkpatch海思SDK代码遇见的常见错误《二》相关的知识,希望对你有一定的参考价值。
17) ERROR:OPEN_BRACE: open brace '' following enum go on the same line
左大括号要跟enum同一行。
18)WARNING:LONG_LINE: line over 120 characters
这个最简单了,就是超出了最大长度120个字符,但是有时候需要注意,TAB键输入比较多的情况下,即使最后一个字符的COL没有到120,也会报,因为TAB占的多,有些是8个字符宽度。
19)WARNING:USE_FUNC: __func__ should be used instead of gcc specific __FUNCTION__
这个就基本上不要翻译了,直接替换一下就是了。
20)WARNING:MACRO_WITH_FLOW_CONTROL: Macros with flow control statements should be avoided
就是宏里面不要有流控,可以写成内联函数,就可以。
这就是合规的了。
Things to avoid when using macros:
1) macros that affect control flow:
#define FOO(x) /
do /
if (blah(x) < 0) /
return -EBUGGERED; /
while(0)
is a _very_ bad idea. It looks like a function call but exits the "calling"
function; don't break the internal parsers of those who will read the code.
2) macros that depend on having a local variable with a magic name:
#define FOO(val) bar(index, val)
might look like a good thing, but it's confusing as hell when one reads the
code and it's prone to breakage from seemingly innocent changes.
以上是关于checkpatch海思SDK代码遇见的常见错误《二》的主要内容,如果未能解决你的问题,请参考以下文章