From: David Miller <davem@davemloft.net>
To: natechancellor@gmail.com
Cc: isdn@linux-pingi.de, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, ndesaulniers@google.com
Subject: Re: [PATCH v2] isdn: avm: Fix string plus integer warning from Clang
Date: Sat, 19 Jan 2019 10:02:00 -0800 (PST) [thread overview]
Message-ID: <20190119.100200.853063369704641480.davem@davemloft.net> (raw)
In-Reply-To: <20190110054107.6069-1-natechancellor@gmail.com>
From: Nathan Chancellor <natechancellor@gmail.com>
Date: Wed, 9 Jan 2019 22:41:08 -0700
> A recent commit in Clang expanded the -Wstring-plus-int warning, showing
> some odd behavior in this file.
>
> drivers/isdn/hardware/avm/b1.c:426:30: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
> cinfo->version[j] = "\0\0" + 1;
> ~~~~~~~^~~
> drivers/isdn/hardware/avm/b1.c:426:30: note: use array indexing to silence this warning
> cinfo->version[j] = "\0\0" + 1;
> ^
> & [ ]
> 1 warning generated.
>
> This is equivalent to just "\0". Nick pointed out that it is smarter to
> use "" instead of "\0" because "" is used elsewhere in the kernel and
> can be deduplicated at the linking stage.
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/309
> Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
>
> v1 -> v2:
>
> * Use "" instead of "\0", as they are equivalent, but "" can be
> deduplicated by the linker, as pointed out by Nick.
Applied, that was certainly a funny construct....
It obviously is trying to initialize the array elements to pointers
to empty strings.
prev parent reply other threads:[~2019-01-19 18:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-08 5:06 [PATCH] isdn: avm: Fix string plus integer warning from Clang Nathan Chancellor
2019-01-08 17:50 ` Nick Desaulniers
2019-01-08 17:54 ` Nathan Chancellor
2019-01-10 5:41 ` [PATCH v2] " Nathan Chancellor
2019-01-10 18:57 ` Nick Desaulniers
2019-01-10 18:57 ` Nick Desaulniers
2019-01-19 18:02 ` David Miller [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190119.100200.853063369704641480.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=isdn@linux-pingi.de \
--cc=linux-kernel@vger.kernel.org \
--cc=natechancellor@gmail.com \
--cc=ndesaulniers@google.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).