From 15aaf94fd41a559487c6e1011f4d6d8fb1249db5 Mon Sep 17 00:00:00 2001 From: Joseph Chen Date: Fri, 9 Sep 2022 02:17:58 +0000 Subject: [PATCH] scripts: checkpatch: Imporve coding style Signed-off-by: Joseph Chen Change-Id: I7ac7fad968f704eb749f6787495aecf732a364ce --- scripts/checkpatch.sh | 131 +++++++++++++++++++----------------------- 1 file changed, 59 insertions(+), 72 deletions(-) diff --git a/scripts/checkpatch.sh b/scripts/checkpatch.sh index c4dc9a2d..54ff27d1 100755 --- a/scripts/checkpatch.sh +++ b/scripts/checkpatch.sh @@ -1,115 +1,102 @@ #!/bin/bash set -e -pack_loader_image() +function pack_loader_image() { - local files ini - - files=`ls ./RKBOOT/*MINIALL*.ini` - for ini in ${files} + for FILE in `ls ./RKBOOT/*MINIALL*.ini` do - if [ -f "${ini}" ]; then - # Ignore unused - if [ "${ini}" = "./RKBOOT/RK302AMINIALL.ini" -o \ - "${ini}" = "./RKBOOT/RK30BMINIALL.ini" -o \ - "${ini}" = "./RKBOOT/RK30MINIALL.ini" -o \ - "${ini}" = "./RKBOOT/RK310BMINIALL.ini" ]; then - continue; - fi - - if grep -q '^PATH=img/' ${ini}; then - continue; - fi - - echo "pack Input: ${ini}" - ./tools/boot_merger ${ini} - rm -f *loader*.bin *download*.bin *idblock*.img - echo + if [ "${FILE}" = "./RKBOOT/RK302AMINIALL.ini" -o \ + "${FILE}" = "./RKBOOT/RK30BMINIALL.ini" -o \ + "${FILE}" = "./RKBOOT/RK30MINIALL.ini" -o \ + "${FILE}" = "./RKBOOT/RK310BMINIALL.ini" ]; then + continue; fi + + if grep -q '^PATH=img/' ${FILE}; then + continue; + fi + + echo "Pack loader: ${FILE}" + ./tools/boot_merger ${FILE} + rm -f *loader*.bin *download*.bin *idblock*.img + echo done } -pack_trust_image() +function pack_trust_image() { - local files ini TOS TOS_TA - -# Pack 32-bit trust - files=`ls ./RKTRUST/*TOS*.ini` - for ini in ${files} + # Pack 32-bit trust + for FILE in `ls ./RKTRUST/*TOS*.ini` do - if ! test -s ${ini}; then + if ! test -s ${FILE}; then continue; - elif ! grep -q '^TOS/' ${ini}; then + elif ! grep -q 'TOS' ${FILE}; then continue; - elif grep -q '^PATH=img/' ${ini}; then + elif grep -q '^PATH=img/' ${FILE}; then continue; fi - if [ -f "${ini}" ]; then - echo "pack Input: ${ini}" + echo "Pack trust: ${FILE}" + # Parse orignal path + TOS=`sed -n "/TOS=/s/TOS=//p" ${FILE}|tr -d '\r'` + TOS_TA=`sed -n "/TOSTA=/s/TOSTA=//p" ${FILE}|tr -d '\r'` - # Parse orignal path - TOS=`sed -n "/TOS=/s/TOS=//p" ${ini}|tr -d '\r'` - TOS_TA=`sed -n "/TOSTA=/s/TOSTA=//p" ${ini}|tr -d '\r'` + # replace "./tools/rk_tools/" with "./" to compatible legacy ini content of rkdevelop branch + TOS=$(echo ${TOS} | sed "s/tools\/rk_tools\//\.\//g") + TOS_TA=$(echo ${TOS_TA} | sed "s/tools\/rk_tools\//\.\//g") - # replace "./tools/rk_tools/" with "./" to compatible legacy ini content of rkdevelop branch - TOS=$(echo ${TOS} | sed "s/tools\/rk_tools\//\.\//g") - TOS_TA=$(echo ${TOS_TA} | sed "s/tools\/rk_tools\//\.\//g") - - if [ x${TOS_TA} != x -a x${TOS} != x ]; then - ./tools/loaderimage --pack --trustos ${TOS} ./trust.img 0x68400000 - ./tools/loaderimage --pack --trustos ${TOS_TA} ./trust_with_ta.img 0x68400000 - elif [ ${TOS} ]; then - ./tools/loaderimage --pack --trustos ${TOS} ./trust.img 0x68400000 - elif [ ${TOS_TA} ]; then - ./tools/loaderimage --pack --trustos ${TOS_TA} ./trust.img 0x68400000 - else - exit 1 - fi - rm -f trust*.img - echo + if [ x${TOS_TA} != x -a x${TOS} != x ]; then + ./tools/loaderimage --pack --trustos ${TOS} ./trust.img 0x68400000 + ./tools/loaderimage --pack --trustos ${TOS_TA} ./trust_with_ta.img 0x68400000 + elif [ ${TOS} ]; then + ./tools/loaderimage --pack --trustos ${TOS} ./trust.img 0x68400000 + elif [ ${TOS_TA} ]; then + ./tools/loaderimage --pack --trustos ${TOS_TA} ./trust.img 0x68400000 + else + exit 1 fi + rm -f trust*.img + echo done -# Pack 64-bit trust - files=`ls ./RKTRUST/*TRUST*.ini` - for ini in ${files} + # Pack 64-bit trust + for FILE in `ls ./RKTRUST/*TRUST*.ini` do - if grep -q '^PATH=img/' ${ini}; then + if grep -q '^PATH=img/' ${FILE}; then continue; fi - if [ -f "${ini}" ]; then - echo "pack Input: ${ini}" - ./tools/trust_merger ${ini} - rm trust*.img - echo - fi + echo "Pack trust: ${FILE}" + ./tools/trust_merger ${FILE} + rm -f trust*.img + echo done } -check_dirty() +function check_dirty() { - for file in `find -name '*spl*.bin' -o -name '*tpl*.bin' -o -name '*usbplug*.bin'`; do - if strings ${file} | grep '\-dirty ' ; then - echo "ERROR: ${file} is dirty" + for FILE in `find -name '*spl*.bin' -o -name '*tpl*.bin' -o -name '*usbplug*.bin'`; do + echo "Checking dirty: ${FILE}" + if strings ${FILE} | grep '\-dirty ' ; then + echo "ERROR: ${FILE} is dirty" exit 1 fi done } -check_stripped() +function check_stripped() { - for elf in `find -name '*bl31*.elf'`; do - info=`file ${elf}` - if echo ${info} | grep -q "not stripped" ; then - echo "ERROR: ${elf} is not stripped" + for FILE in `find -name '*bl31*.elf'`; do + echo "Checking strip: ${FILE}" + INFO=`file ${FILE}` + if echo ${INFO} | grep -q "not stripped" ; then + echo "ERROR: ${FILE} is not stripped" exit 1 fi done } -finish() +function finish() { echo "Packing loader and trust successfully." echo