操作系统kylin

下载sendip-2.5.tar.gz

解压在/home/sendip-2.5/目录下

执行make命令

出现错误:

cc1: warnings being treated as errors

ipv4.c: In function 'do_opt':

ipv4.c:212: warning: pointer targets inpassing argument 1 of 'sprintf' differ in signedness

ipv4.c:213: warning: pointer targets inpassing argument 1 of 'compact_string' differ in signedness

ipv4.c:240: warning: pointer targets inpassing argument 5 of 'addoption' differ in signedness

ipv4.c:355: warning: pointer targets inpassing argument 5 of 'addoption' differ in signedness

ipv4.c:380: warning: pointer targets inpassing argument 5 of 'addoption' differ in signedness

ipv4.c:402: warning: pointer targets inpassing argument 5 of 'addoption' differ in signedness

make: *** [ipv4.so] Error 1

提示上述warning被作为错误

我们打开ipv4.c文件,找到各行,如212行:sprintf(data,"0x%s",arg);

发 现参数data在前面(207行)声明为u_int8_t *类型,而sprintf的参数一般为(char *)而得到data的变量arg也是char *类型的,于是我们在212行将参数data显示转换为char *类型:sprintf((char *)data,"0x%s",arg);

再次make发现212行warning消失,于是其213几行和同样处理。

在 240、355、380、402行方法'addoption'的data的参数是char *类型,但我们发现386行的addoption方法第5个参数为u_int8_t *类型,于是我们将上面几行的data显示转换为u_int8_t *类型,如240行:addoption(0,0,7,len+2,(u_int8_t *)data,pack);

再次make发现ipv4.c中的warning已经消失,但是出现tcp.c文件中的若干warning:

cc1: warnings being treated as errors

tcp.c: In function 'do_opt':

tcp.c:207: warning: pointer targets inpassing argument 1 of 'sprintf' differ in signedness

tcp.c:208: warning: pointer targets inpassing argument 1 of 'compact_string' differ in signedness

tcp.c:239: warning: pointer targets inassignment differ in signedness

tcp.c:241: warning: pointer targets inpassing argument 1 of 'strchr' differ in signedness

tcp.c:241: warning: pointer targets inassignment differ in signedness

tcp.c:249: warning: pointer targets inassignment differ in signedness

tcp.c:252: warning: pointer targets inassignment differ in signedness

tcp.c:262: warning: pointer targets inassignment differ in signedness

tcp.c:264: warning: pointer targets inassignment differ in signedness

tcp.c:266: warning: pointer targets in assignmentdiffer in signedness

tcp.c:270: warning: pointer targets inassignment differ in signedness

make: *** [tcp.so] Error 1


(CentOS6.5 下报错:)

cc1: warnings being treated as errors

ipv4.c: 在函数‘do_opt’中:

ipv4.c:212: 错误:传递‘sprintf’的参数 1 给指针时,目标与指针符号不一致

/usr/include/stdio.h:363: 附注:需要类型‘char * __restrict__’,但实参的类型为‘u_int8_t *’

ipv4.c:213: 错误:传递‘compact_string’的参数 1 给指针时,目标与指针符号不一致

sendip_module.h:41: 附注:需要类型‘char *’,但实参的类型为‘u_int8_t *’

ipv4.c:240: 错误:传递‘addoption’的参数 5 给指针时,目标与指针符号不一致

ipv4.c:81: 附注:需要类型‘u_int8_t *’,但实参的类型为‘char *’

ipv4.c:355: 错误:传递‘addoption’的参数 5 给指针时,目标与指针符号不一致

ipv4.c:81: 附注:需要类型‘u_int8_t *’,但实参的类型为‘char *’

ipv4.c:380: 错误:传递‘addoption’的参数 5 给指针时,目标与指针符号不一致

ipv4.c:81: 附注:需要类型‘u_int8_t *’,但实参的类型为‘char *’

ipv4.c:402: 错误:传递‘addoption’的参数 5 给指针时,目标与指针符号不一致

ipv4.c:81: 附注:需要类型‘u_int8_t *’,但实参的类型为‘char *’

make: *** [ipv4.so] 错误 1

gcc -o ipv4.so -fPIC -fsigned-char -pipe -Wall -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Wnested-externs -Winline -Werror -g -Wcast-align -DSENDIP_LIBS=\"/usr/local/lib/sendip\" -shared ipv4.c csum.o compact.o

cc1: warnings being treated as errors

ipv4.c: 在函数‘do_opt’中:

ipv4.c:212: 错误:传递‘sprintf’的参数 1 给指针时,目标与指针符号不一致

/usr/include/stdio.h:363: 附注:需要类型‘char * __restrict__’,但实参的类型为‘u_int8_t *’

ipv4.c:213: 错误:传递‘compact_string’的参数 1 给指针时,目标与指针符号不一致

sendip_module.h:41: 附注:需要类型‘char *’,但实参的类型为‘u_int8_t *’

ipv4.c:240: 错误:传递‘addoption’的参数 5 给指针时,目标与指针符号不一致

ipv4.c:81: 附注:需要类型‘u_int8_t *’,但实参的类型为‘char *’

ipv4.c:355: 错误:传递‘addoption’的参数 5 给指针时,目标与指针符号不一致

ipv4.c:81: 附注:需要类型‘u_int8_t *’,但实参的类型为‘char *’

ipv4.c:380: 错误:传递‘addoption’的参数 5 给指针时,目标与指针符号不一致

ipv4.c:81: 附注:需要类型‘u_int8_t *’,但实参的类型为‘char *’

ipv4.c:402: 错误:传递‘addoption’的参数 5 给指针时,目标与指针符号不一致

ipv4.c:81: 附注:需要类型‘u_int8_t *’,但实参的类型为‘char *’

make: *** [ipv4.so] 错误 1


我们以类似的方法找到各行,进行格式修改:

207行:sprintf((char*)data,"0x%s",arg);

208行:len =compact_string((char *)data);

239行:next=(unsigned char*)arg;

241行:next=(unsigned char*)strchr((char *)next,',');

249行:next=(unsigned char*)arg;

252行:next=(unsigned char*)strchr(arg, ':');

262行:arg=(char *)next;

264行:next=(unsigned char*)strchr(arg, ',');

266行:next=(unsigned char*)arg-1; /* Finito - next points to \0 */

270行:arg=(char *)next;

重新make通过

make install通过

安装完成