Re: [PATCH 1/2] shell: Fix clang warnings about "string plus integer"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Dec 15, 2018 at 06:49:31PM +0100, Antonio Ospite wrote:
> Building with clang results in some warnings about integer values being
> added to strings:
> 
> -----------------------------------------------------------------------
> eval.c:1138:13: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
>                 p = " %s" + (1 - sep);
>                     ~~~~~~^~~~~~~~~~~
> eval.c:1138:13: note: use array indexing to silence this warning
>                 p = " %s" + (1 - sep);
>                           ^
>                     &     [          ]
> 1 warning generated.
> 
> ...
> 
> jobs.c:1424:16: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
>                         str = "\"}" + !(quoted & 1);
>                               ~~~~~~^~~~~~~~~~~~~~~
> jobs.c:1424:16: note: use array indexing to silence this warning
>                         str = "\"}" + !(quoted & 1);
>                                     ^
>                               &     [              ]
> 1 warning generated.
> -----------------------------------------------------------------------
> 
> While the code itself is fine and the warnings are indeed harmless,
> fixing them also makes the semantic more explicit: what it is actually
> being increased is the address which points to the start of the string
> in order to skip the initial character when some conditions are met.
> 
> Signed-off-by: Antonio Ospite <ao2@xxxxxx>
> ---
>  src/eval.c | 3 ++-
>  src/jobs.c | 3 ++-
>  2 files changed, 4 insertions(+), 2 deletions(-)

All applied.  Thanks.
-- 
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux