TEE开发 checkpatch.sh 使用方法

checkpatch.sh 是对 checkpatch.pl 的封装 , 在opteeos 官方脚本里面 scripts/ 下 可以找到

有如下使用方法

Usage: checkpatch.sh [--working]                 Check working area
       checkpatch.sh <commit>...                 Check specific commit(s)
       checkpatch.sh --diff <commit1> <commit2>  Check diff commit1...commit2
       checkpatch.sh --cached                    Check staging area
       checkpatch.sh --help                      This help

 

使用该脚本之前需要先声明 CHECKPATH 环境变量

export CHECKPATCH=/mnt/fileroot/hongbin.wang/workspace/android_U/common/common14-5.15/common/scripts/checkpatch.pl

 

注意: 不能使用server自带的 /usr/src/linux-headers-4.4.0-176-generic/scripts/checkpatch.pl , 脚本会自动取找这个文件但是 该文件太老了,不适用, 于是需要指定新的checkpatch.pl

使用方法:

  1.  自己本地做了修改,还未提交到暂存区,此时git 在工作区有更新, 还未进入暂存区,这时候使用 --working 参数 检查

    cd optee_os/
    ./scripts/checkpatch.sh --working

     

  2. 自己本地做了修改,已经提交暂存区,这时候使用 --cached 参数检查

    cd optee_os/
    ./scripts/checkpatch.sh --cached

     

  3. 自己本地修改, 已经做了提交,这时候是一个新的commit 产生,使用 具体的commit 参数检查

    cd optee_os/
    ./scripts/checkpatch.sh  4ba904fc977459f362dd2b18e43c1556d4c0b0ae
    Checking commit(s):
    4ba904fc9 rng: s1a: optimized the code for hrng using ring only mode[1/1]
    No codespell typos will be found - file '/usr/share/codespell/dictionary.txt': No such file or directory
    WARNING: line length of 82 exceeds 80 columns
    #35: FILE: core/arch/arm/plat-meson/s1a/rng_support.c:175:
    +       aml_write_reg32(RNG_CFG_RESEED, aml_read_reg32(RNG_CFG_RESEED) | (1<<25));
     
    CHECK: spaces preferred around that '<<' (ctx:VxV)
    #35: FILE: core/arch/arm/plat-meson/s1a/rng_support.c:175:
    +       aml_write_reg32(RNG_CFG_RESEED, aml_read_reg32(RNG_CFG_RESEED) | (1<<25));
                                                                               ^
     
    total: 0 errors, 1 warnings, 1 checks, 10 lines checked

     

  4. 对当前整个项目文件进行检查

    cd optee_os/
    ./scripts/checkpatch.sh  HEAD
     
    total: 1321 errors, 7855 warnings, 113 checks, 36458 lines checked

     

官方介绍文档: Coding standards — OP-TEE documentation documentation (optee.readthedocs.io)

posted @ 2024-05-14 17:03  颜小雀  阅读(11)  评论(0编辑  收藏  举报