zephyr/samples/microkernel/test
Yonattan Louise 3f1439bf2d Fix checkpatch issue - ERROR:OPEN_BRACE
The open braces of the 'if','for', 'while' and 'do' statements should be at the end on the
same line of the statement to comply with the defined coding style. E.g.:

	if (x is true) {
		we do y
	}

Change accomplished with the following script:

	#!/bin/bash

	checkpatch_script="$VXMICRO_BASE/scripts/checkpatch.pl --mailback --no-tree -f --emacs --summary-file --show-types --ignore BRACES,PRINTK_WITHOUT_KERN_LEVEL,SPLIT_STRING --max-line-length=100 "

	for file in $(find ./ -name "*.[ch]" ! -path "./scripts/*" ! -path "./host/src/wrsconfig/*" ! -path "*/outdir/*");
	do
		if [ ! -h $file ];
		then
			# obtaining the line's number where the error is reported in a reversed order
			reversed_lines="";
			for line in $(eval $checkpatch_script $file | grep "ERROR:OPEN_BRACE" | cut -d":" -f2)
			do
				reversed_lines="$line $reversed_lines";
			done;

			# fixing the issues in reverse order due to lines can be deleted affecting futher lines
			for line_reported in $(echo $reversed_lines);
			do
				# search for the line where the open brace is
				char_found="";
				let line=$line_reported-1;
				while [ ${#char_found} -eq 0 ]
				do
					let line=$line+1;
					char_found="$(sed -n ''$line' { /{/ p }' $file)";
				done

				let statement_line=$line-1;
				let brace_line=$line;

				# condition to avoid modifying lines that ends with the character "\"
				char_found="$(sed -n ''$statement_line' { /\\$/ p }' $file)";
				if [ ${#char_found} -eq 0 ];
				then
					# fix the issue
					echo "$file : reported on $line_reported (found on $brace_line -> moved to $statement_line)";
					sed -i ''$statement_line' { s/[ \t]*$//; s/\([ \t]*\/\*.*\*\/\)$/ {\1/; /{/ b already_done s/$/ {/; :already_done }; '$brace_line' { s/{[ \t]*//; /^[ \t]*$/ d }; ' $file;
				fi
			done
		fi
	done;

Change-Id: I517c40bb33840ef531f2319354350f578b238abb
Signed-off-by: Yonattan Louise <yonattan.a.louise.mendoza@intel.com>
2016-02-05 20:13:54 -05:00
..
test_bluetooth Bluetooth: Enable HCI_CORE debug for samples 2016-02-05 20:13:50 -05:00
test_critical Fix checkpatch issue - ERROR:OPEN_BRACE 2016-02-05 20:13:54 -05:00
test_events Remove references to Simics from README.txt files 2016-02-05 20:13:48 -05:00
test_fifo Remove references to Simics from README.txt files 2016-02-05 20:13:48 -05:00
test_fp_sharing Fix checkpatch issue - ERROR:OPEN_BRACE 2016-02-05 20:13:54 -05:00
test_libs Fix checkpatch issue - ERROR:OPEN_BRACE 2016-02-05 20:13:54 -05:00
test_mail Fix checkpatch issue - ERROR:OPEN_BRACE 2016-02-05 20:13:54 -05:00
test_map Remove references to Simics from README.txt files 2016-02-05 20:13:48 -05:00
test_mutex Fix checkpatch issue - ERROR:OPEN_BRACE 2016-02-05 20:13:54 -05:00
test_pipe Fix checkpatch issue - ERROR:OPEN_BRACE 2016-02-05 20:13:54 -05:00
test_pool samples: Use common ARRAY_SIZE() helper in all places 2016-02-05 20:13:54 -05:00
test_secure_string_api Fix checkpatch issue - ERROR:OPEN_BRACE 2016-02-05 20:13:54 -05:00
test_sema Fix checkpatch issue - ERROR:OPEN_BRACE 2016-02-05 20:13:54 -05:00
test_sprintf Fix checkpatch issue - ERROR:OPEN_BRACE 2016-02-05 20:13:54 -05:00
test_stackprot Fix checkpatch issue - ERROR:OPEN_BRACE 2016-02-05 20:13:54 -05:00
test_static_idt Fix checkpatch issue - ERROR:OPEN_BRACE 2016-02-05 20:13:54 -05:00
test_task Fix checkpatch issue - ERROR:OPEN_BRACE 2016-02-05 20:13:54 -05:00
test_task_irq Fix checkpatch issue - ERROR:OPEN_BRACE 2016-02-05 20:13:54 -05:00
test_tickless Fix checkpatch issue - ERROR:OPEN_BRACE 2016-02-05 20:13:54 -05:00
test_timer Change _nano_ticks to 64-bit 2016-02-05 20:13:52 -05:00
test_xip Fix checkpatch issue - ERROR:OPEN_BRACE 2016-02-05 20:13:54 -05:00