scripts: unifdef: fix stringop-truncation warning
Subsystems (2)
PATCH 1/1 scripts: unifdef: fix stringop-truncation warning
From: Harshit Jain <[email protected]>
* This commit resolves the following warning when the mainline kernel is build with the android environment.
-> warning :-> https://gist.github.com/dev-harsh1998/757427b16a58f5498db3d87212a9651b
* This warning is persistant in all the currently maintained android kernel i.e 3.18, 4.4, 4.9, 4.14.
--- scripts/unifdef.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
scripts/unifdef.c +3 -3
@@ -395,8 +395,8 @@ usage(void)* When we have processed a group that starts off with a known-false * #if/#elif sequence (which has therefore been deleted) followed by a * #elif that we don't understand and therefore must keep, we edit the -* latter into a #if to keep the nesting correct. We use strncpy() to -* overwrite the 4 byte token "elif" with "if " without a '\0' byte. +* latter into a #if to keep the nesting correct. We use the memcpy() +* from the string header overwrite the 4 byte token "elif" with "if ". * * When we find a true #elif in a group, the following block will * always be kept and the rest of the sequence after the next #elif or
@@ -450,7 +450,7 @@ static void Idrop (void) { Fdrop(); ignoreon(); }static void Itrue (void ) {Ftrue ();ignoreon (); }static void Ifalse (void ) {Ffalse ();ignoreon (); }/* modify this line */ -static void Mpass (void ) {strncpy (keyword,"if " ,4 );Pelif (); } +static void Mpass (void ) {memcpy (keyword,"if " ,4 );Pelif (); }static void Mtrue (void ) {keywordedit ("else" );state (IS_TRUE_MIDDLE ); }static void Melif (void ) {keywordedit ("endif" );state (IS_FALSE_TRAILER ); }static void Melse (void ) {keywordedit ("endif" );state (IS_FALSE_ELSE ); }
Signature · 1 line
2.18.0
Hi Harshit,
Quoted 3 lines · Harshit Jain
From: Harshit Jain <[email protected]>
* This commit resolves the following warning when the mainline kernel is build with the android environment.
Typo: built
Quoted 2 lines
-> warning :-> https://gist.github.com/dev-harsh1998/757427b16a58f5498db3d87212a9651b
Try to avoid links to external pages (specially if they are only 2 lines :-).
Quoted 2 lines
* This warning is persistant in all the currently maintained android kernel i.e 3.18, 4.4, 4.9, 4.14.
Typos: persistent, kernels, i.e.
Quoted 22 lines
Signed-off-by Harshit Jain <[email protected]>--- scripts/unifdef.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)scripts/unifdef.c +2
-2@@ -395,8 +395,8 @@ usage(void)* When we have processed a group that starts off with a known-false * #if/#elif sequence (which has therefore been deleted) followed by a * #elif that we don't understand and therefore must keep, we edit the -* latter into a #if to keep the nesting correct. We use strncpy() to -* overwrite the 4 byte token "elif" with "if " without a '\0' byte. +* latter into a #if to keep the nesting correct. We use the memcpy() +* from the string header overwrite the 4 byte token "elif" with "if ". * * When we find a true #elif in a group, the following block will * always be kept and the rest of the sequence after the next #elif or
scripts/unifdef.c static void Idrop (void) { Fdrop(); ignoreon(); } · line 453
Quoted 5 lines
scripts/unifdef.c +1
-1@@ -450,7 +450,7 @@ static void Idrop (void) { Fdrop(); ignoreon(); }static void Itrue (void ) {Ftrue ();ignoreon (); }static void Ifalse (void ) {Ffalse ();ignoreon (); }/* modify this line */ -static void Mpass (void ) {strncpy (keyword,"if " ,4 );Pelif (); } +static void Mpass (void ) {memcpy (keyword,"if " ,4 );Pelif (); }
Seems like keyword shouldn't use __attribute__((nonstring)), so this looks right.
Cheers,
Miguel
Quoted 6 lines
scripts/unifdef.c +0
-1static void Mtrue (void ) {keywordedit ("else" );state (IS_TRUE_MIDDLE ); }static void Melif (void ) {keywordedit ("endif" );state (IS_FALSE_TRAILER ); }static void Melse (void ) {keywordedit ("endif" );state (IS_FALSE_ELSE ); } --2.18.0
Quoted 1 line · Miguel Ojeda
Hi Harshit,
Another two nitpicks:
* Since this is the second version of the patch, write "[PATCH v2]"
in the title instead; that way people know you have sent an earlier version. On top of that, you should explain the differences between each version after the "---" line (i.e. the part that does not belong to the commit message).
* You may want to write down who you CC'd (e.g. Tony and the stable
mailing list) in "Cc: ..." lines before the Signed-off-by line.
Thanks for the patch!
Hope that helps,
Miguel
Quoted 59 lines
Quoted 3 lines · Harshit Jain
From: Harshit Jain <[email protected]>
* This commit resolves the following warning when the mainline kernel is build with the android environment.
Typo: built
Quoted 2 lines
-> warning :-> https://gist.github.com/dev-harsh1998/757427b16a58f5498db3d87212a9651b
Try to avoid links to external pages (specially if they are only 2 lines :-).
Quoted 2 lines
* This warning is persistant in all the currently maintained android kernel i.e 3.18, 4.4, 4.9, 4.14.
Typos: persistent, kernels, i.e.
Quoted 22 lines
Signed-off-by Harshit Jain <[email protected]>--- scripts/unifdef.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)scripts/unifdef.c +2
-2@@ -395,8 +395,8 @@ usage(void)* When we have processed a group that starts off with a known-false * #if/#elif sequence (which has therefore been deleted) followed by a * #elif that we don't understand and therefore must keep, we edit the -* latter into a #if to keep the nesting correct. We use strncpy() to -* overwrite the 4 byte token "elif" with "if " without a '\0' byte. +* latter into a #if to keep the nesting correct. We use the memcpy() +* from the string header overwrite the 4 byte token "elif" with "if ". * * When we find a true #elif in a group, the following block will * always be kept and the rest of the sequence after the next #elif or scripts/unifdef.c static void Idrop (void) { Fdrop(); ignoreon(); } · line 453
Quoted 5 lines
scripts/unifdef.c +1
-1@@ -450,7 +450,7 @@ static void Idrop (void) { Fdrop(); ignoreon(); }static void Itrue (void ) {Ftrue ();ignoreon (); }static void Ifalse (void ) {Ffalse ();ignoreon (); }/* modify this line */ -static void Mpass (void ) {strncpy (keyword,"if " ,4 );Pelif (); } +static void Mpass (void ) {memcpy (keyword,"if " ,4 );Pelif (); }Seems like keyword shouldn't use __attribute__((nonstring)), so this looks right.
Cheers,
MiguelQuoted 6 lines
scripts/unifdef.c +0
-1static void Mtrue (void ) {keywordedit ("else" );state (IS_TRUE_MIDDLE ); }static void Melif (void ) {keywordedit ("endif" );state (IS_FALSE_TRAILER ); }static void Melse (void ) {keywordedit ("endif" );state (IS_FALSE_ELSE ); } --2.18.0