diff --git a/scripts/generate-kernel-patch b/scripts/generate-kernel-patch index 5ee478fb5..6f981d3d2 100755 --- a/scripts/generate-kernel-patch +++ b/scripts/generate-kernel-patch @@ -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;; diff --git a/scripts/specialize-patch b/scripts/specialize-patch index 753bcff97..8b71a406b 100755 --- a/scripts/specialize-patch +++ b/scripts/specialize-patch @@ -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