Message ID | 20190408212648.2407234-6-arnd@arndb.de |
---|---|
State | Accepted |
Commit | 27b141fc234a3670d21bd742c35d7205d03cbb3a |
Headers | show |
Series | [01/12] s390: remove -fno-strength-reduce flag | expand |
On Mon, Apr 08, 2019 at 11:26:19PM +0200, Arnd Bergmann wrote: > clang points out that the return code from this function is > undefined for one of the error paths: > > ../drivers/s390/net/ctcm_main.c:1595:7: warning: variable 'result' is used uninitialized whenever 'if' condition is true > [-Wsometimes-uninitialized] > if (priv->channel[direction] == NULL) { > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ../drivers/s390/net/ctcm_main.c:1638:9: note: uninitialized use occurs here > return result; > ^~~~~~ > ../drivers/s390/net/ctcm_main.c:1595:3: note: remove the 'if' if its condition is always false > if (priv->channel[direction] == NULL) { > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ../drivers/s390/net/ctcm_main.c:1539:12: note: initialize the variable 'result' to silence this warning > int result; > ^ > > Make it return -ENODEV here, as in the related failure cases. > gcc has a known bug in underreporting some of these warnings > when it has already eliminated the assignment of the return code > based on some earlier optimization step. > > Signed-off-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Nathan Chancellor <natechancellor@gmail.com> > --- > drivers/s390/net/ctcm_main.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/s390/net/ctcm_main.c b/drivers/s390/net/ctcm_main.c > index 7617d21cb296..f63c5c871d3d 100644 > --- a/drivers/s390/net/ctcm_main.c > +++ b/drivers/s390/net/ctcm_main.c > @@ -1595,6 +1595,7 @@ static int ctcm_new_device(struct ccwgroup_device *cgdev) > if (priv->channel[direction] == NULL) { > if (direction == CTCM_WRITE) > channel_free(priv->channel[CTCM_READ]); > + result = -ENODEV; > goto out_dev; > } > priv->channel[direction]->netdev = dev; > -- > 2.20.0 >
On Mon, 8 Apr 2019 23:26:19 +0200 Arnd Bergmann <arnd@arndb.de> wrote: > clang points out that the return code from this function is > undefined for one of the error paths: > > ../drivers/s390/net/ctcm_main.c:1595:7: warning: variable 'result' is used uninitialized whenever 'if' condition is true > [-Wsometimes-uninitialized] > if (priv->channel[direction] == NULL) { > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ../drivers/s390/net/ctcm_main.c:1638:9: note: uninitialized use occurs here > return result; > ^~~~~~ > ../drivers/s390/net/ctcm_main.c:1595:3: note: remove the 'if' if its condition is always false > if (priv->channel[direction] == NULL) { > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ../drivers/s390/net/ctcm_main.c:1539:12: note: initialize the variable 'result' to silence this warning > int result; > ^ > > Make it return -ENODEV here, as in the related failure cases. > gcc has a known bug in underreporting some of these warnings > when it has already eliminated the assignment of the return code > based on some earlier optimization step. > > Signed-off-by: Arnd Bergmann <arnd@arndb.de> Added to our internal tree for Julian to pick up. -- blue skies, Martin. "Reality continues to ruin my life." - Calvin.
diff --git a/drivers/s390/net/ctcm_main.c b/drivers/s390/net/ctcm_main.c index 7617d21cb296..f63c5c871d3d 100644 --- a/drivers/s390/net/ctcm_main.c +++ b/drivers/s390/net/ctcm_main.c @@ -1595,6 +1595,7 @@ static int ctcm_new_device(struct ccwgroup_device *cgdev) if (priv->channel[direction] == NULL) { if (direction == CTCM_WRITE) channel_free(priv->channel[CTCM_READ]); + result = -ENODEV; goto out_dev; } priv->channel[direction]->netdev = dev;
clang points out that the return code from this function is undefined for one of the error paths: ../drivers/s390/net/ctcm_main.c:1595:7: warning: variable 'result' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] if (priv->channel[direction] == NULL) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../drivers/s390/net/ctcm_main.c:1638:9: note: uninitialized use occurs here return result; ^~~~~~ ../drivers/s390/net/ctcm_main.c:1595:3: note: remove the 'if' if its condition is always false if (priv->channel[direction] == NULL) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../drivers/s390/net/ctcm_main.c:1539:12: note: initialize the variable 'result' to silence this warning int result; ^ Make it return -ENODEV here, as in the related failure cases. gcc has a known bug in underreporting some of these warnings when it has already eliminated the assignment of the return code based on some earlier optimization step. Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- drivers/s390/net/ctcm_main.c | 1 + 1 file changed, 1 insertion(+) -- 2.20.0