Refinements / bug fixes of the changes introduced in the previous commit:

- Only replace sBUG/sBUG_ON by BUG/BUG_ON when this macro is being used, not
  in its definition.
- Fixed bugs in algorithm for preserving the original code during a sparse run.


git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@1076 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2009-09-06 11:09:21 +00:00
parent bea5b6dfc8
commit 9d4e2f9399
2 changed files with 23 additions and 8 deletions

View File

@@ -69,11 +69,19 @@ diff -uprN orig/linux-${kernel_version}/$2 linux-${kernel_version}/$2
+++ linux-${kernel_version}/$2
@@ -0,0 +1,$(wc -l "$1" | { read a b; echo $a; }) @@
EOF
if [ "${2%.[ch]}" != "$2" ]; then
sed -e 's/sBUG(/BUG(/g' -e 's/sBUG_ON(/BUG_ON(/g' -e 's/^/+/' \
-e 's/^ \([^ ]*:\)$/\1/' < "$1"
# Insert a '+'-sign at the start of each line.
sed -e 's/^/+/' < "$1" | \
if [ "${replace_sbug_by_bug}" = "true" ]; then
sed -e 's/sBUG(\([^)]\)/BUG(\1/g' -e 's/sBUG_ON(\([^)]\)/BUG_ON(\1/g'
else
sed -e 's/sBUG(/BUG(/g' -e 's/sBUG_ON(/BUG_ON(/g' -e 's/^/+/' < "$1"
cat
fi \
| \
if [ "${2%.[ch]}" != "$2" ]; then
# Make sure that labels (goto-targets) are left-aligned.
sed -e 's/^ \([^ ]*:\)$/\1/'
else
cat
fi
fi
}
@@ -138,6 +146,7 @@ mpt_scst="false"
multiple_patches="false"
patchdir=""
specialize_patch_options="-v delete_disabled_code=1"
replace_sbug_by_bug="true"
if [ ! -e scst -o ! -e iscsi-scst -o ! -e srpt -o ! -e scst_local ]; then
echo "Please run this script from inside the SCST subversion source tree."
@@ -151,7 +160,10 @@ do
'-h') usage; exit 1;;
'-l') shift;;
'-m') mpt_scst="true"; shift;;
'-n') specialize_patch_options="-v delete_disabled_code=0"; shift;;
'-n') specialize_patch_options="-v delete_disabled_code=0"
replace_sbug_by_bug="false"
shift
;;
'-p') multiple_patches="true"; patchdir="$2"; shift; shift;;
'-q') qla2x00t="true"; shift;;
'--') shift;;

View File

@@ -224,6 +224,7 @@ function handle_if()
function process_preprocessor_statement() {
last_if_nesting_level = if_nesting_level
orig_stmnt = $0
evaluated = evaluate($0)
condition = 1
delete_next_blank_line = 0
@@ -263,7 +264,7 @@ function process_preprocessor_statement() {
}
if (delete_disabled_code == 0 || (output && (! condition || condition && matching_if !~ "^+#if [01]")))
{
line[lines++]=$0
line[lines++] = orig_stmnt
}
else if (evaluated ~ "^+#define SCSI_EXEC_REQ_FIFO_DEFINED$" \
|| evaluated ~ "^+#define SCST_IO_CONTEXT$")
@@ -314,6 +315,8 @@ BEGIN {
printf "Error: kernel version (%s) is out of range.\n", kernel_version
exit 1
}
if (delete_disabled_code != 0 && delete_disabled_code != 1)
delete_disabled_code = 0
# Variable initialization.
lines = 0
@@ -346,7 +349,7 @@ BEGIN {
dump_lines()
match($0, "^@@ -([0-9]*),([0-9]*) \\+([0-9]*),([0-9]*) @@(.*)$", h)
}
else if (delete_disabled_output && delete_next_blank_line && match($0, "^+$"))
else if (delete_disabled_code && delete_next_blank_line && match($0, "^+$"))
{
lines_deleted++
delete_next_blank_line = 0
@@ -358,7 +361,7 @@ BEGIN {
{
process_preprocessor_statement()
}
else if (delete_disabled_output == 0 || output)
else if (delete_disabled_code == 0 || output)
{
# Store the line that was just read.
line[lines++]=$0