首页 > 系统服务 > 详细

Linux 内核模块编译消灭告警

时间:2014-03-14 17:51:43      阅读:620      评论:0      收藏:0      [点我收藏+]

ISO C90 forbids mixed declarations and code

因为 变量定义之前任何一条非变量定义的语句(注意:语句是会带分号的)都会引起这个警告!将非变量的定义移到变量定义之后 即可。

比如:

int a;

a=a+1;

int b;

改为:

int a;

int b;

a=a+1;

即可。

-------------------------------------------------------------

function declaration isn’t a prototype

#include 
#include 
#include 
#include 
static int hello_init_module(void)
{
    printk("Hello, world - this is the kernel speaking\n");
    return 0;
}
/* Cleanup - undid whatever init_module did */
static void hello_cleanup_module(void)
{
    printk("Short is the life of a kernel module\n");
}
module_init(hello_init_module);
module_exit(hello_cleanup_module);
上面代码是内核中的一个模块, 如果 static int hello_init_module(void)  括号里面没有加void就会出现此警告。

-------------------------------------------------------------

backslash and newline separated by space

backslash and newline separated by space”
反斜杠和换行为空格所分隔”

#define NIPQUAD(addr)\
  ((unsigned char *)&addr)[0],\
  ((unsigned char *)&addr)[1],\
  ((unsigned char *)&addr)[2],\
  ((unsigned char *)&addr)[3]

类似这个,反斜杠后面不能有空格

 

-------------------------------------------------------------

statement with no effect

 int i=0;
        *n1=0;
        *n2=0;
        for(i;i<strlen(cmds);++i)
        {
                if(*(cmds+i) ==‘ ‘)
                {
                        *n1=++i;
                        break;
                }
        }

开头定义了变量,在循环内部就不需要在定义了

 

 

未完待续....

Linux 内核模块编译消灭告警,布布扣,bubuko.com

Linux 内核模块编译消灭告警

原文:http://www.cnblogs.com/wk23/p/3599842.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!