Auto format Linux kernel coding style
2015-12-04 14:47
816 查看
一、代码风格自动检查
scripts/checkpatch.pl -f directory / *.cGerrit可以对kernel git增加此自动检查功能,保证代码提交质量。
二、代码风格自动整理
1、使用开源软件astyle自动整理
http://sourceforge.net/projects/astyle/files/astyle/下载最新linux版本astyle ,编译:
cd astyle/build/gcc
make release
#!/bin/sh
#./astyle --style=linux --indent=force-tab=8 --align-pointer=name --max-code-length=90 --break-after-logical -p -H -U ./*.c ./*.h
./astyle --style=linux --indent=force-tab=8 --align-pointer=name -p -H -U ./*.c ./*.h
2、使用kernel脚本indent自动整理
参考:http://blog.csdn.net/lixianlin/article/details/7820753
3、注释风格C99自动转换C89
// comment 修改成风格/* comment */sed -i '/\/\//s/$/\*\//g' epl8802.c
sed -i 's/\/\//\/\*/g' epl8802.c.
四、Auto format Linux kernel coding style
#!/bin/sh#./astyle --style=linux --indent=force-tab=8 --align-pointer=name --max-code-length=90 --break-after-logical
-p -H -U ./*.c ./*.h
./astyle --style=linux --indent=force-tab=8 --align-pointer=name -p -H -U ./*.c ./*.h
files=$(find . -name "*.c")
for f in ${files}
do
mv ${f} ${f}.org
#./cconvert ${f}.org > ${f}
sed -i '/\/\//s/$/\*\//g' ${f}.org
sed -i 's/\/\//\/\*/g' ${f}.org
done
相关文章推荐
- Linux之死锁的代码体验
- centos5下sendmail发送邮件时主题中文乱码的解决办法
- Linux服务器监控命令
- epoll + 线程池 回应服务器(Linux) ---可以支持上万个连接
- Linux crontab定时服务
- Ubuntu下修改环境变量的三种方法
- Linux下source命令
- 制作可用grub引导Linux系统的磁盘映像文件 二
- 使用epoll 在 linux 上开发高性能应用服务器
- Centos7 Friewalld 防火墙配置
- Redhat linux DNS配置指南(SCANIP配置手册)
- linux 下多线程epoll编程 -socket
- Linux解析DNS
- Linux dpkg 命令
- linux can收发程序
- Centos配置国内yum源
- Centos配置国内yum源
- linux ps 命令
- linux 显示文件或文件夹
- Linux 基本命令