Re: [PATCH] Fix styling issues reported by checkpatch in usr/gen_init_cpio.c

From: Alshehhi Family
Date: Mon Dec 06 2021 - 00:54:01 EST



This is my first Patch to the linux kernel. I am not sure whether
details on how this patch is tested should be included in the commit
message or not. Nevertheless, here are the details.

Original:

/home/husain/src/linux/scripts/checkpatch.pl --file --terse --emacs /home/husain/src/linux/usr/gen_init_cpio.c
/home/husain/src/linux/usr/gen_init_cpio.c:42: WARNING: space prohibited between function name and open parenthesis '('
/home/husain/src/linux/usr/gen_init_cpio.c:76: WARNING: const array should probably be static const
/home/husain/src/linux/usr/gen_init_cpio.c:79: WARNING: quoted string split across lines
/home/husain/src/linux/usr/gen_init_cpio.c:83: WARNING: Unnecessary typecast of c90 int constant - '(long) 0' could be '0L'
/home/husain/src/linux/usr/gen_init_cpio.c:84: WARNING: Unnecessary typecast of c90 int constant - '(long) 0' could be '0L'
/home/husain/src/linux/usr/gen_init_cpio.c:86: WARNING: Unnecessary typecast of c90 int constant - '(long) 0' could be '0L'
/home/husain/src/linux/usr/gen_init_cpio.c:92: WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
/home/husain/src/linux/usr/gen_init_cpio.c:110: ERROR: space required after that ',' (ctx:VxV)
/home/husain/src/linux/usr/gen_init_cpio.c:111: WARNING: quoted string split across lines
/home/husain/src/linux/usr/gen_init_cpio.c:119: WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
/home/husain/src/linux/usr/gen_init_cpio.c:124: WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
/home/husain/src/linux/usr/gen_init_cpio.c:143: WARNING: Comparisons should place the constant on the right side of the test
/home/husain/src/linux/usr/gen_init_cpio.c:159: ERROR: space required after that ',' (ctx:VxV)
/home/husain/src/linux/usr/gen_init_cpio.c:160: WARNING: quoted string split across lines
/home/husain/src/linux/usr/gen_init_cpio.c:173: WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
/home/husain/src/linux/usr/gen_init_cpio.c:214: WARNING: Comparisons should place the constant on the right side of the test
/home/husain/src/linux/usr/gen_init_cpio.c:253: ERROR: space required after that ',' (ctx:VxV)
/home/husain/src/linux/usr/gen_init_cpio.c:254: WARNING: quoted string split across lines
/home/husain/src/linux/usr/gen_init_cpio.c:267: WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
/home/husain/src/linux/usr/gen_init_cpio.c:285: WARNING: Comparisons should place the constant on the right side of the test
/home/husain/src/linux/usr/gen_init_cpio.c:311: WARNING: space prohibited between function name and open parenthesis '('
/home/husain/src/linux/usr/gen_init_cpio.c:313: WARNING: space prohibited between function name and open parenthesis '('
/home/husain/src/linux/usr/gen_init_cpio.c:331: WARNING: space prohibited between function name and open parenthesis '('
/home/husain/src/linux/usr/gen_init_cpio.c:335: WARNING: space prohibited between function name and open parenthesis '('
/home/husain/src/linux/usr/gen_init_cpio.c:337: WARNING: space prohibited between function name and open parenthesis '('
/home/husain/src/linux/usr/gen_init_cpio.c:344: ERROR: trailing statements should be on next line
/home/husain/src/linux/usr/gen_init_cpio.c:349: ERROR: space required after that ',' (ctx:VxV)
/home/husain/src/linux/usr/gen_init_cpio.c:350: WARNING: quoted string split across lines
/home/husain/src/linux/usr/gen_init_cpio.c:382: ERROR: trailing whitespace
/home/husain/src/linux/usr/gen_init_cpio.c:384: ERROR: trailing statements should be on next line
/home/husain/src/linux/usr/gen_init_cpio.c:385: ERROR: trailing statements should be on next line
/home/husain/src/linux/usr/gen_init_cpio.c:398: WARNING: sizeof expanded should be sizeof(expanded)
/home/husain/src/linux/usr/gen_init_cpio.c:418: WARNING: Comparisons should place the constant on the right side of the test
/home/husain/src/linux/usr/gen_init_cpio.c:430: WARNING: space prohibited between function name and open parenthesis '('
/home/husain/src/linux/usr/gen_init_cpio.c:452: ERROR: code indent should use tabs where possible
/home/husain/src/linux/usr/gen_init_cpio.c:454: ERROR: trailing statements should be on next line
/home/husain/src/linux/usr/gen_init_cpio.c:527: WARNING: space prohibited between function name and open parenthesis '('
/home/husain/src/linux/usr/gen_init_cpio.c:577: ERROR: do not use assignment in if condition
/home/husain/src/linux/usr/gen_init_cpio.c:595: ERROR: space prohibited after that '!' (ctx:BxW)
/home/husain/src/linux/usr/gen_init_cpio.c:595: ERROR: do not use assignment in if condition
/home/husain/src/linux/usr/gen_init_cpio.c:613: ERROR: space prohibited after that '!' (ctx:BxW)
/home/husain/src/linux/usr/gen_init_cpio.c:613: ERROR: do not use assignment in if condition
/home/husain/src/linux/usr/gen_init_cpio.c:622: WARNING: Missing a blank line after declarations
/home/husain/src/linux/usr/gen_init_cpio.c:622: ERROR: space prohibited after that '!' (ctx:BxW)
/home/husain/src/linux/usr/gen_init_cpio.c:623: ERROR: do not use assignment in if condition
/home/husain/src/linux/usr/gen_init_cpio.c:631: WARNING: Comparisons should place the constant on the right side of the test
total: 17 errors, 29 warnings, 640 lines checked

After applying the change:

/home/husain/src/linux/scripts/checkpatch.pl --file --terse --emacs /home/husain/src/linux/usr/gen_init_cpio.c
/home/husain/src/linux/usr/gen_init_cpio.c:76: WARNING: const array should probably be static const
/home/husain/src/linux/usr/gen_init_cpio.c:79: WARNING: quoted string split across lines
/home/husain/src/linux/usr/gen_init_cpio.c:111: WARNING: quoted string split across lines
/home/husain/src/linux/usr/gen_init_cpio.c:160: WARNING: quoted string split across lines
/home/husain/src/linux/usr/gen_init_cpio.c:254: WARNING: quoted string split across lines
/home/husain/src/linux/usr/gen_init_cpio.c:351: WARNING: quoted string split across lines
/home/husain/src/linux/usr/gen_init_cpio.c:581: ERROR: do not use assignment in if condition
/home/husain/src/linux/usr/gen_init_cpio.c:599: ERROR: do not use assignment in if condition
/home/husain/src/linux/usr/gen_init_cpio.c:617: ERROR: do not use assignment in if condition
/home/husain/src/linux/usr/gen_init_cpio.c:628: ERROR: do not use assignment in if condition
total: 4 errors, 6 warnings, 645 lines checked