zephyr/include
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
..
bluetooth Bluetooth: Add return parameter support to bt_hci_cmd_send_sync() 2016-02-05 20:13:50 -05:00
drivers pci: Put the public API header in the right location 2016-02-05 20:13:48 -05:00
microkernel Rename K_TimerBlocks to _k_timer_blocks 2016-02-05 20:13:54 -05:00
misc Add ARRAY_SIZE() helper macro 2016-02-05 20:13:54 -05:00
nanokernel Fix checkpatch issue - ERROR:OPEN_BRACE 2016-02-05 20:13:54 -05:00
toolchain Compiler specific configuration 2016-02-05 20:13:52 -05:00
abs_sym.h Make absolute symbol macros headers compiler dependent 2016-02-05 20:13:52 -05:00
clock_vars.h Change _nano_ticks to 64-bit 2016-02-05 20:13:52 -05:00
cputype.h Eliminate use of VXMICRO_HOST_TOOLS 2016-02-05 20:13:45 -05:00
kernel_version.h First commit 2015-04-10 16:44:37 -07:00
linker-defs.h Remove VIRT_ADDR_xxx macros 2016-02-05 20:13:39 -05:00
linker-tool-gcc.h First commit 2015-04-10 16:44:37 -07:00
linker-tool.h First commit 2015-04-10 16:44:37 -07:00
microkernel.h Relocate definition of microkernel server's stack area 2016-02-05 20:13:52 -05:00
nanokernel.h Change _nano_ticks to 64-bit 2016-02-05 20:13:52 -05:00
section_tags.h toolchain/arch: Remove section garbage collection ifdef guards 2016-02-05 20:13:48 -05:00
sections.h First commit 2015-04-10 16:44:37 -07:00
string_s.h First commit 2015-04-10 16:44:37 -07:00
sw_isr_table.h Rename _IsrTable to _sw_isr_table 2016-02-05 20:13:53 -05:00
toolchain.h Compiler specific configuration 2016-02-05 20:13:52 -05:00