From 1ba7d1c87a20e88fff367f212c3f17d8a5832933 Mon Sep 17 00:00:00 2001 From: Joseph Chen Date: Wed, 12 Apr 2023 08:35:19 +0000 Subject: [PATCH] scripts: checkpatch: Add more strict end line check Signed-off-by: Joseph Chen Change-Id: I7a08928d1bcb62978e9dc603c81f952248eee98b --- scripts/checkpatch.sh | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/scripts/checkpatch.sh b/scripts/checkpatch.sh index 4a788478..ec7cc0fd 100755 --- a/scripts/checkpatch.sh +++ b/scripts/checkpatch.sh @@ -43,8 +43,9 @@ function check_doc() FILE=`sed -n "/^+| 20[0-9][0-9]-/p" ${DIFF_DOC_ALL} | tr -d " " | awk -F "|" '{ print $3 }'` COMMIT=`sed -n "/^+| 20[0-9][0-9]-/p" ${DIFF_DOC_ALL} | tr -d " " | awk -F "|" '{ print $4 }'` SEVERITY=`sed -n "/^+| 20[0-9][0-9]-/p" ${DIFF_DOC_ALL} | tr -d " " | awk -F "|" '{ print $5 }'` - HORIZONTAL_LINE=`sed -n "/^+------$/p" ${DIFF_DOC_ALL}` - END_LINE=`tail -n 1 ${DIFF_DOC_ALL}` + END_LINE_3=`tail -n 3 ${DIFF_DOC_ALL} | sed -n '1p'` + END_LINE_2=`tail -n 3 ${DIFF_DOC_ALL} | sed -n '2p'` + END_LINE_1=`tail -n 3 ${DIFF_DOC_ALL} | sed -n '3p'` HOST_YEAR=`date | awk '{ print $6 }'` # echo "### ${COMMIT}, ${SEVERITY}, ${TITLE}, ${FILE}" @@ -172,14 +173,16 @@ function check_doc() fi # check horizontal line - if [ -z "${HORIZONTAL_LINE}" ]; then - echo "ERROR: ${DOC}: No horizontal line '------' at the last of new content" + if [ "${END_LINE_2}" != "+------" ]; then + echo "ERROR: ${DOC}: No horizontal line '------' found at the last of new content" exit 1 fi - - # check horizontal line - if [ "${END_LINE}" == "+------" ]; then - echo "ERROR: ${DOC}: No blank line after '------'" + if [ "${END_LINE_3}" != "+" ]; then + echo "ERROR: ${DOC}: No blank line found before horizontal line '------'" + exit 1 + fi + if [ "${END_LINE_1}" != "+" ]; then + echo "ERROR: ${DOC}: No blank line found after horizontal line '------'" exit 1 fi