c语言 代码检查工具6,Ubuntu系统下C语言代码检查工具-- Splint
看一下下面的代码(当然包括错误,以检验splint的功能):
#include
int main(int argc,char* argv[]){
int a=100; /*没有使用的变量*/
int b[8];
printf("Hello c\n");
b[9]=100; /*明显数组越界 */
/* 用到了两个为声明的变量c和d/
c=100;
d=10;
return 0;
}
现在可以用splint来检查一下,为了检验是否可以检测到数组越界,使用+bounds选项。
splint hi.c +bounds
输出结果:
hi.c: (in function main)
hi.c:9:2: Unrecognized identifier: c
Identifier used in code has not been declared. (Use -unrecog to inhibit
warning)
hi.c:10:2: Unrecognized identifier: d
hi.c:4:6: Variable a declared but not used
A variable is declared but never used. Use /*@unused@*/ in front of
declaration to suppress message. (Use -varuse to inhibit warning)
hi.c:7:2: Likely out-of-bounds store:
b[9]
Unable to resolve constraint:
requires 7 >= 9
needed to satisfy precondition:
requires maxSet(b @ hi.c:7:2) >= 9
A memory write may write to an address beyond the allocated buffer. (Use
-likely-boundswrite to inhibit warning)
hi.c:3:14: Parameter argc not used
A function parameter is not used in the body of the function. If the argument
is needed for type compatibility or future plans, use /*@unused@*/ in the
argument declaration. (Use -paramuse to inhibit warning)
hi.c:3:25: Parameter argv not used
Finished checking --- 6 code warnings
现在详细看一下结果:
检查结果1:
hi.c:9:2: Unrecognized identifier: c
Identifier used in code has not been declared. (Use -unrecog to inhibit
warning)
hi.c:10:2: Unrecognized identifier: d
hi.c:4:6: Variable a declared but not used
A variable is declared but never used. Use /*@unused@*/ in front of
declaration to suppress message. (Use -varuse to inhibit warning)
这些应该是splint检测到变量c和d没有声明。
检查结果2:
hi.c:7:2: Likely out-of-bounds store:
b[9]
Unable to resolve constraint:
requires 7 >= 9
needed to satisfy precondition:
requires maxSet(b @ hi.c:7:2) >= 9
A memory write may write to an address beyond the allocated buffer. (Use
-likely-boundswrite to inhibit warning)
这些是检查存在数组越界,因为吧b[8]的最大数组序号应该是7,而不是9,所以出现requires 7 >= 9;
检查结果3:
hi.c:3:14: Parameter argc not used
A function parameter is not used in the body of the function. If the argument
is needed for type compatibility or future plans, use /*@unused@*/ in the
argument declaration. (Use -paramuse to inhibit warning)
hi.c:3:25: Parameter argv not used
这些表明argc和argv变量声明了,但是没有使用。这个不是什么问题。
如果小心使用splint,应该对于c语言的程序编写有非常大的辅助作用!
c语言 代码检查工具6,Ubuntu系统下C语言代码检查工具-- Splint相关推荐
- ubuntu下c语言编程工具,Ubuntu系统下C语言代码检查工具(Splint)
看一下下面的代码(当然包括错误,以检验splint的功能): #include int main(int argc,char* argv[]){ int a=100; /*没有使用的变量*/ int ...
- ubuntu系统下c语言helloworld入门以及编写简单程序
文章目录 一.c语言helloworld入门 二.分别在ubuntu和windows系统下编写简单程序 (一)ubuntu系统下的简单主/子程序 (二)在windows系统下编写简单主/子程序 (三) ...
- ubuntu系统下c语言入门以及编写简单程序
目录 一,hello world入门 二,在windows系统中编写简单程序 三,在ubuntu系统下用makefile方式编写程序 一,hello world入门 在linux操作系统中打开终端 1 ...
- 基于虚拟机Ubuntu系统下C语言简单编写程序
目录描述 前言 一.修改系统参数 1.查看Ubuntu版本 2.原文件备份 3.下载清华源 二.编写"hello world"C语言程序 1.安装vim 2.建立hello.c 3 ...
- ubuntu系统下C语言编写简单程序
文章目录 一.学习了解ubuntu系统下vim编辑器的基本运用. 1.如何进入vim编辑器 2.vim编辑器命令模式基本命令 3.vim编辑器编辑模式 4.vim编辑器末行模式命令 二.ubuntu系 ...
- Ubuntu系统下C语言编译以及Makefile编译C语言程序
目录 1.c语言hello world 1.打开终端 2.新建文件夹:mkdir 文件名 3.打开文件夹 cd 文件名 4.vim指令打开hello.c的c语言文件:vi hello.c 5.输入以下 ...
- git管理工具 linux,linux系统下使用流行的版本管理工具 Git
前几天被版本管理困扰了好久,主要是因为 没法回到之前的版本,新版本又出了问题真的很尴尬. 终于决定使用目前网上很火的版本管理工具-------Git 历史啥的就不说了,说些有用的. 我用的是oschi ...
- Ubuntu系统下C语言的简单使用及gcc和Makefile编译C程序
Ubuntu18.04系统用C语言的编程. 一.网络设置 1. 下载 Ubuntu 18.04 2.下载 VMware Workstation 3.安装虚拟机 二.更换apt源 1.查看ubuntu的 ...
- linux系统下qt中文输入法,Ubuntu系统下Qt使用中文输入法(示例代码)
近几个月一直在搞QML框架下的UI控件,没有更新博客.今天记录下Ubuntu系统下Qt开发工具使用中文输入法的流程. (题外话,Linux系统下的开发,离线是没法搞的(夸张手法),不联网简直就是事倍功 ...
最新文章
- scaling之旅_机器学习算法之旅
- iOS Hacker Xcode玩转arm64汇编基础
- koa --- [MVC实现之一]自定义路由读取规则
- 2018 年,React 将独占web前端框架鳌头?
- PHP单选框实现的方法,jQuery简单实现遍历单选框的方法
- 力扣326.3的幂 C/C++
- 为iPhone 12上市做准备,台积电月底前投产A14 Bionic芯片
- 文本框焦点事件显示隐藏文本框内容
- 数据挖掘知识图谱(大数据分析师)
- 浙江省计算机二级办公软件高级应用技术真题,浙江省计算机二级办公软件高级应用技术考试题库.doc...
- 利用FinalData恢复shift+delete误删的文件
- QQ影音播放器 for Mac
- win10底部任务栏无响应解决办法
- ubuntu20.04不是所有者所以不能更改权限
- 炼数成金(dataguru)IT技能修炼
- 环境和社会风险分类c类_企业经营风险的定义、种类以及基本分类
- ‘https://start.spring.io‘ 的初始化失败请检查 URL、网络和代理设置。
- 云服务器操作系统 版本选择,云服务器操作系统 版本选择
- js 获取字典的key_JS-字典
- 【网页设计】HTML+CSS保护野生动物北极熊介绍网页设计专题
热门文章
- 【无标题】动态规划leetcode浅析(一)泰波那契序列
- 一杯严选+JOYx正酒链盟”心直酒快“登陆台北@HiFi++ 美学文化海外节点
- 电子采购管理软件开发功能有哪些?
- java简介(Java简介英文)
- oracle 创建电子钱包,计算机软件水平考试电子商务设计师模拟题五
- 接口-服务端接口客户端接口
- Python 开发环境搭建及预备知识
- 抓取部分京东手机信息案例(Java案例)
- 教育大数据挖掘--菜鸟入门
- 计算机操作系统存储管理实验报告,《操作系统》存储管理实验报告