-
warning:
举例:
/************************************************/
/* /* save
snmp entry data /* add by
Tina Lee 2003/7/11
/*******************
******************************/
说明:意思是说
/*
*/
中间又包含了
/*
修改:改成这样就好了
/*****
******************************************* * *
save snmp entry
data * add by Tina Lee
2003/7/11
*****************************
********************/
warning: no previous prototype for
'get_char_for_sta'
举例:无
说明:函数没有声明,只有定义
修改
:在相应的
.h
文件中添加该函
数的声
明。
warning: unused parameter
'mcb'
举例:
int
ifnMenuQuit(MCB_T *mcb) { return QUIT; }
说明:因为函数参数
中的
mcb,
在该函数中没有被使用,所以产生
warning
修改:对没使用的参数使
用
para=para; int ifnMenuQuit(MCB_T *mcb) { mcb=mcb;
<----------
添加该
行
return QUIT; }
warning:
comparison between signed and unsigned
举例:
INT4
s4UnitID
=
0;
INT4
s4ChipID
=
0;
uint32
u0
=
0;
PMAP_BUNIT_ITE
(s4UnitID,
u0,
s4ChipID)
说明:类型不一致。
修改:使用相同
的类型(视具
体情况而定)。
warning: unused variable `iRet'
举例:
func() { int
iRet=error_none; ............... ...............
return error_none; }
说明:函数中定
义局部变量
iRet,
但没有使用。
修改:
(1)
删除该变量
(2)
在合适的地方使用该变量
如结尾改为:
return
iRet;
warning:
suggest
parentheses
around
assignment
used
as
truth
value
举例:
func(char
*format)
{
char
c;
while(c=*format++)
{
.............
}
}
说明:
该
warning
的意思是建议程序员对
while
中的条件语句加上括号,
因为
编
译器
不知道到底是
=
,还是
==
修改:
while((c=*format++))
明确告诉编译器,
这里确实是赋值语句,然后判断
c
是否为真。
warning:
declaration
of
'remove'
shadows
a
global
declaration
举例:
int
bcm_port_learn_modify(int
unit,
bcm_port_t
port,
uint32
add,
uint32
remove)
{
int rv;
PORT_PARAM_CHECK(unit,
port);
PORT_LOCK(unit);
rv = _bcm_port_learn_modify(unit, port,
add, sdkremove);
PORT_UNLOCK(unit);
return
rv;
}
说明:因为库函数
stdio.h
中使用了全局
变
量
remove,
所以和该函数声明
中的
remove
冲突。
修改:
把该函数的变量名改掉。
如把
remove
改为
sdkremove
附
:
linux
的
patch
中也是采用
的修改变量名
的方法。
linux
patch
warning: redundant
redeclaration of 'ifnDispTitle'
举例:在
m_main.c
中第
50
< br>行
int ifnDispTitle(MCB_T *mcb);
在
menuext.h
中第
954
行
extern int
ifnDispTitle(MCB_T *mcb);
说明:产生这种
warning
多数情况是因为
m_main.c<
/p>
没有对于的
.h
文件,
< br>因此该函数在
.c
文件中声明,
所
以
在别的地方用该函数的时候,使用
extern funcn
ame()
来声明,就会产生这
种
wa
rning.
解决方法:还没想到
warning: missing braces around
initializer
举例:
typedef
strunc
tS{
int
a;
int
b;
int
c
;
}S;
S
s[3]={
1,2,3,
4,5,6,
7,8,9 };
说明:这个
war
ning
是说同一个结构体中的数据初始化的时候应该放
在一个
括号里面。在
menu
结构体初始化
中,有大量的此类
warning,
加
上括号
即可解决。
修改:加上括号即可。
S s[3]={ {1,2,3},
{4,5,6}, {7,8,9} };
warning:
function declaration isn't a prototype
举例:在
mac_if.h
中
UI32_T u32fnFDB_GetDiscards
()
;
说明:当声明的函
数中没有参数时,括号中不用为空,填入
void
修改:
UI32_T
u32fnFDB_GetDiscards
(void)
;
-
-
-
-
-
-
-
-
-
上一篇:行政公文常用词汇
下一篇:马斯洛理论把需求分成生理需求