* [PATCH] net: atm: Use IS_ENABLED in atm_dev_ioctl
@ 2019-03-07 16:57 Nathan Chancellor
2019-03-07 17:53 ` David Miller
2019-03-07 18:11 ` [PATCH] net: atm: Add another IS_ENABLED(CONFIG_COMPAT) " Nathan Chancellor
0 siblings, 2 replies; 4+ messages in thread
From: Nathan Chancellor @ 2019-03-07 16:57 UTC (permalink / raw)
To: David S. Miller
Cc: netdev, linux-kernel, clang-built-linux, Nick Desaulniers,
Nathan Chancellor
When building with -Wsometimes-uninitialized, Clang warns:
net/atm/resources.c:256:6: warning: variable 'number' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
net/atm/resources.c:212:7: warning: variable 'iobuf_len' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
Clang won't realize that compat is 0 when CONFIG_COMPAT is not set until
the constant folding stage, which happens after this semantic analysis.
Use IS_ENABLED instead so that the zero is present at the semantic
analysis stage, which eliminates this warning.
Link: https://github.com/ClangBuiltLinux/linux/issues/386
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
I don't think this looks the greatest because of the IS_ENABLED + #ifdef
but the only other solution I could think of looks way uglier to me:
https://gist.github.com/74650e9139f704a5435f82fc80d59969
net/atm/resources.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/net/atm/resources.c b/net/atm/resources.c
index bada395ecdb1..3e9f6391319e 100644
--- a/net/atm/resources.c
+++ b/net/atm/resources.c
@@ -203,13 +203,9 @@ int atm_dev_ioctl(unsigned int cmd, void __user *arg, int compat)
int __user *sioc_len;
int __user *iobuf_len;
-#ifndef CONFIG_COMPAT
- compat = 0; /* Just so the compiler _knows_ */
-#endif
-
switch (cmd) {
case ATM_GETNAMES:
- if (compat) {
+ if (IS_ENABLED(CONFIG_COMPAT) && compat) {
#ifdef CONFIG_COMPAT
struct compat_atm_iobuf __user *ciobuf = arg;
compat_uptr_t cbuf;
@@ -253,7 +249,7 @@ int atm_dev_ioctl(unsigned int cmd, void __user *arg, int compat)
break;
}
- if (compat) {
+ if (IS_ENABLED(CONFIG_COMPAT) && compat) {
#ifdef CONFIG_COMPAT
struct compat_atmif_sioc __user *csioc = arg;
compat_uptr_t carg;
--
2.21.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] net: atm: Use IS_ENABLED in atm_dev_ioctl
2019-03-07 16:57 [PATCH] net: atm: Use IS_ENABLED in atm_dev_ioctl Nathan Chancellor
@ 2019-03-07 17:53 ` David Miller
2019-03-07 18:11 ` [PATCH] net: atm: Add another IS_ENABLED(CONFIG_COMPAT) " Nathan Chancellor
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2019-03-07 17:53 UTC (permalink / raw)
To: natechancellor; +Cc: netdev, linux-kernel, clang-built-linux, ndesaulniers
From: Nathan Chancellor <natechancellor@gmail.com>
Date: Thu, 7 Mar 2019 09:57:42 -0700
> When building with -Wsometimes-uninitialized, Clang warns:
>
> net/atm/resources.c:256:6: warning: variable 'number' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
> net/atm/resources.c:212:7: warning: variable 'iobuf_len' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
>
> Clang won't realize that compat is 0 when CONFIG_COMPAT is not set until
> the constant folding stage, which happens after this semantic analysis.
> Use IS_ENABLED instead so that the zero is present at the semantic
> analysis stage, which eliminates this warning.
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/386
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] net: atm: Add another IS_ENABLED(CONFIG_COMPAT) in atm_dev_ioctl
2019-03-07 16:57 [PATCH] net: atm: Use IS_ENABLED in atm_dev_ioctl Nathan Chancellor
2019-03-07 17:53 ` David Miller
@ 2019-03-07 18:11 ` Nathan Chancellor
2019-03-07 18:59 ` David Miller
1 sibling, 1 reply; 4+ messages in thread
From: Nathan Chancellor @ 2019-03-07 18:11 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, linux-kernel, Nathan Chancellor
I removed compat's universal assignment to 0, which allows this if
statement to fall through when compat is passed with a value other
than 0.
Fixes: f9d19a7494e5 ("net: atm: Use IS_ENABLED in atm_dev_ioctl")
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
Sorry for not paying more attention :(
net/atm/resources.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/atm/resources.c b/net/atm/resources.c
index 3e9f6391319e..889349c6d90d 100644
--- a/net/atm/resources.c
+++ b/net/atm/resources.c
@@ -413,7 +413,7 @@ int atm_dev_ioctl(unsigned int cmd, void __user *arg, int compat)
}
/* fall through */
default:
- if (compat) {
+ if (IS_ENABLED(CONFIG_COMPAT) && compat) {
#ifdef CONFIG_COMPAT
if (!dev->ops->compat_ioctl) {
error = -EINVAL;
--
2.21.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] net: atm: Add another IS_ENABLED(CONFIG_COMPAT) in atm_dev_ioctl
2019-03-07 18:11 ` [PATCH] net: atm: Add another IS_ENABLED(CONFIG_COMPAT) " Nathan Chancellor
@ 2019-03-07 18:59 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2019-03-07 18:59 UTC (permalink / raw)
To: natechancellor; +Cc: netdev, linux-kernel
From: Nathan Chancellor <natechancellor@gmail.com>
Date: Thu, 7 Mar 2019 11:11:26 -0700
> I removed compat's universal assignment to 0, which allows this if
> statement to fall through when compat is passed with a value other
> than 0.
>
> Fixes: f9d19a7494e5 ("net: atm: Use IS_ENABLED in atm_dev_ioctl")
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-03-07 18:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-07 16:57 [PATCH] net: atm: Use IS_ENABLED in atm_dev_ioctl Nathan Chancellor
2019-03-07 17:53 ` David Miller
2019-03-07 18:11 ` [PATCH] net: atm: Add another IS_ENABLED(CONFIG_COMPAT) " Nathan Chancellor
2019-03-07 18:59 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.