[pacman-dev] [PATCH] Fix clang 8 string-plus-int warnings

Andrew Gregory andrew.gregory.8 at gmail.com
Sat Apr 6 18:17:38 UTC 2019


On 04/05/19 at 12:02am, Rikard Falkeborn wrote:
> Clang 8 warns that adding a string to an integer does not append to
> string. Indeed it doesn't, but that was not the intentetion. Use array
> indexing as suggested by the compiler to silence the warning. There
> should be no functional change.
> 
> Example of warning message:
> 
>     alpm.c:71:54: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
>             sprintf(hookdir, "%s%s", myhandle->root, SYSHOOKDIR + 1);
>                                                      ~~~~~~~~~~~^~~
>     alpm.c:71:54: note: use array indexing to silence this warning
>             sprintf(hookdir, "%s%s", myhandle->root, SYSHOOKDIR + 1);
>                                                                 ^
>                                                      &          [  ]
>     1 warning generated.
> ---
>  lib/libalpm/alpm.c | 2 +-
>  src/pacman/conf.c  | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)

I think this warning is dumb, but I guess the fix doesn't hurt anything.  ACK


More information about the pacman-dev mailing list