* [PATCH net-next] bonding: check slave set command firstly
@ 2019-02-01 14:07 xiangxia.m.yue
2019-02-02 14:38 ` kbuild test robot
2019-02-03 19:20 ` David Miller
0 siblings, 2 replies; 4+ messages in thread
From: xiangxia.m.yue @ 2019-02-01 14:07 UTC (permalink / raw)
To: davem; +Cc: netdev, Tonghao Zhang
From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
This patch is a little improvement. If user use the
command shown as below, we should print the info [1]
instead of [2]. The eth0 exists actually, and it may
confuse user.
$ echo "eth0" > /sys/class/net/bond4/bonding/slaves
[1] "bond4: no command found in slaves file - use +ifname or -ifname"
[2] "write error: No such device"
Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
---
drivers/net/bonding/bond_options.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c
index 4d5d01c..5526229 100644
--- a/drivers/net/bonding/bond_options.c
+++ b/drivers/net/bonding/bond_options.c
@@ -1375,6 +1375,7 @@ static int bond_option_slaves_set(struct bonding *bond,
sscanf(newval->string, "%16s", command); /* IFNAMSIZ*/
ifname = command + 1;
if ((strlen(command) <= 1) ||
+ (command[0] != '+' && command[0] != '-') ||
!dev_valid_name(ifname))
goto err_no_cmd;
@@ -1396,9 +1397,6 @@ static int bond_option_slaves_set(struct bonding *bond,
netdev_dbg(bond->dev, "Removing slave %s\n", dev->name);
ret = bond_release(bond->dev, dev);
break;
-
- default:
- goto err_no_cmd;
}
out:
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] bonding: check slave set command firstly
2019-02-01 14:07 [PATCH net-next] bonding: check slave set command firstly xiangxia.m.yue
@ 2019-02-02 14:38 ` kbuild test robot
2019-02-03 4:59 ` Tonghao Zhang
2019-02-03 19:20 ` David Miller
1 sibling, 1 reply; 4+ messages in thread
From: kbuild test robot @ 2019-02-02 14:38 UTC (permalink / raw)
To: xiangxia.m.yue; +Cc: kbuild-all, davem, netdev, Tonghao Zhang
[-- Attachment #1: Type: text/plain, Size: 4578 bytes --]
Hi Tonghao,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on net-next/master]
url: https://github.com/0day-ci/linux/commits/xiangxia-m-yue-gmail-com/bonding-check-slave-set-command-firstly/20190202-215305
config: xtensa-allyesconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 8.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=8.2.0 make.cross ARCH=xtensa
Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings
All warnings (new ones prefixed by >>):
drivers/net/bonding/bond_options.c: In function 'bond_option_slaves_set':
>> drivers/net/bonding/bond_options.c:1403:9: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
return ret;
^~~
vim +/ret +1403 drivers/net/bonding/bond_options.c
0e2e5b66 Nikolay Aleksandrov 2014-01-22 1366
f3253339 stephen hemminger 2014-03-04 1367 static int bond_option_slaves_set(struct bonding *bond,
28f084cc stephen hemminger 2014-03-06 1368 const struct bond_opt_value *newval)
0e2e5b66 Nikolay Aleksandrov 2014-01-22 1369 {
0e2e5b66 Nikolay Aleksandrov 2014-01-22 1370 char command[IFNAMSIZ + 1] = { 0, };
0e2e5b66 Nikolay Aleksandrov 2014-01-22 1371 struct net_device *dev;
0e2e5b66 Nikolay Aleksandrov 2014-01-22 1372 char *ifname;
0e2e5b66 Nikolay Aleksandrov 2014-01-22 1373 int ret;
0e2e5b66 Nikolay Aleksandrov 2014-01-22 1374
0e2e5b66 Nikolay Aleksandrov 2014-01-22 1375 sscanf(newval->string, "%16s", command); /* IFNAMSIZ*/
0e2e5b66 Nikolay Aleksandrov 2014-01-22 1376 ifname = command + 1;
0e2e5b66 Nikolay Aleksandrov 2014-01-22 1377 if ((strlen(command) <= 1) ||
c9914772 Tonghao Zhang 2019-02-01 1378 (command[0] != '+' && command[0] != '-') ||
0e2e5b66 Nikolay Aleksandrov 2014-01-22 1379 !dev_valid_name(ifname))
0e2e5b66 Nikolay Aleksandrov 2014-01-22 1380 goto err_no_cmd;
0e2e5b66 Nikolay Aleksandrov 2014-01-22 1381
0e2e5b66 Nikolay Aleksandrov 2014-01-22 1382 dev = __dev_get_by_name(dev_net(bond->dev), ifname);
0e2e5b66 Nikolay Aleksandrov 2014-01-22 1383 if (!dev) {
eac306b4 Michael Dilmore 2017-06-26 1384 netdev_dbg(bond->dev, "interface %s does not exist!\n",
2de390ba Veaceslav Falico 2014-07-15 1385 ifname);
0e2e5b66 Nikolay Aleksandrov 2014-01-22 1386 ret = -ENODEV;
0e2e5b66 Nikolay Aleksandrov 2014-01-22 1387 goto out;
0e2e5b66 Nikolay Aleksandrov 2014-01-22 1388 }
0e2e5b66 Nikolay Aleksandrov 2014-01-22 1389
0e2e5b66 Nikolay Aleksandrov 2014-01-22 1390 switch (command[0]) {
0e2e5b66 Nikolay Aleksandrov 2014-01-22 1391 case '+':
eac306b4 Michael Dilmore 2017-06-26 1392 netdev_dbg(bond->dev, "Adding slave %s\n", dev->name);
33eaf2a6 David Ahern 2017-10-04 1393 ret = bond_enslave(bond->dev, dev, NULL);
0e2e5b66 Nikolay Aleksandrov 2014-01-22 1394 break;
0e2e5b66 Nikolay Aleksandrov 2014-01-22 1395
0e2e5b66 Nikolay Aleksandrov 2014-01-22 1396 case '-':
eac306b4 Michael Dilmore 2017-06-26 1397 netdev_dbg(bond->dev, "Removing slave %s\n", dev->name);
0e2e5b66 Nikolay Aleksandrov 2014-01-22 1398 ret = bond_release(bond->dev, dev);
0e2e5b66 Nikolay Aleksandrov 2014-01-22 1399 break;
0e2e5b66 Nikolay Aleksandrov 2014-01-22 1400 }
0e2e5b66 Nikolay Aleksandrov 2014-01-22 1401
0e2e5b66 Nikolay Aleksandrov 2014-01-22 1402 out:
0e2e5b66 Nikolay Aleksandrov 2014-01-22 @1403 return ret;
0e2e5b66 Nikolay Aleksandrov 2014-01-22 1404
0e2e5b66 Nikolay Aleksandrov 2014-01-22 1405 err_no_cmd:
2de390ba Veaceslav Falico 2014-07-15 1406 netdev_err(bond->dev, "no command found in slaves file - use +ifname or -ifname\n");
0e2e5b66 Nikolay Aleksandrov 2014-01-22 1407 ret = -EPERM;
0e2e5b66 Nikolay Aleksandrov 2014-01-22 1408 goto out;
0e2e5b66 Nikolay Aleksandrov 2014-01-22 1409 }
e9f0fb88 Mahesh Bandewar 2014-04-22 1410
:::::: The code at line 1403 was first introduced by commit
:::::: 0e2e5b66e9de377d69f50a456fdd60462889c64f bonding: convert slaves to use the new option API
:::::: TO: Nikolay Aleksandrov <nikolay@redhat.com>
:::::: CC: David S. Miller <davem@davemloft.net>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 56338 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] bonding: check slave set command firstly
2019-02-02 14:38 ` kbuild test robot
@ 2019-02-03 4:59 ` Tonghao Zhang
0 siblings, 0 replies; 4+ messages in thread
From: Tonghao Zhang @ 2019-02-03 4:59 UTC (permalink / raw)
To: David Miller; +Cc: Linux Kernel Network Developers
On Sat, Feb 2, 2019 at 10:38 PM kbuild test robot <lkp@intel.com> wrote:
>
> Hi Tonghao,
>
> Thank you for the patch! Perhaps something to improve:
>
> [auto build test WARNING on net-next/master]
>
> url: https://github.com/0day-ci/linux/commits/xiangxia-m-yue-gmail-com/bonding-check-slave-set-command-firstly/20190202-215305
> config: xtensa-allyesconfig (attached as .config)
> compiler: xtensa-linux-gcc (GCC) 8.2.0
> reproduce:
> wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # save the attached .config to linux build tree
> GCC_VERSION=8.2.0 make.cross ARCH=xtensa
>
> Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
> http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings
>
> All warnings (new ones prefixed by >>):
>
> drivers/net/bonding/bond_options.c: In function 'bond_option_slaves_set':
> >> drivers/net/bonding/bond_options.c:1403:9: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
> return ret;
> ^~~
the 'ret' is initialized actually before returning
> vim +/ret +1403 drivers/net/bonding/bond_options.c
>
> 0e2e5b66 Nikolay Aleksandrov 2014-01-22 1366
> f3253339 stephen hemminger 2014-03-04 1367 static int bond_option_slaves_set(struct bonding *bond,
> 28f084cc stephen hemminger 2014-03-06 1368 const struct bond_opt_value *newval)
> 0e2e5b66 Nikolay Aleksandrov 2014-01-22 1369 {
> 0e2e5b66 Nikolay Aleksandrov 2014-01-22 1370 char command[IFNAMSIZ + 1] = { 0, };
> 0e2e5b66 Nikolay Aleksandrov 2014-01-22 1371 struct net_device *dev;
> 0e2e5b66 Nikolay Aleksandrov 2014-01-22 1372 char *ifname;
> 0e2e5b66 Nikolay Aleksandrov 2014-01-22 1373 int ret;
> 0e2e5b66 Nikolay Aleksandrov 2014-01-22 1374
> 0e2e5b66 Nikolay Aleksandrov 2014-01-22 1375 sscanf(newval->string, "%16s", command); /* IFNAMSIZ*/
> 0e2e5b66 Nikolay Aleksandrov 2014-01-22 1376 ifname = command + 1;
> 0e2e5b66 Nikolay Aleksandrov 2014-01-22 1377 if ((strlen(command) <= 1) ||
> c9914772 Tonghao Zhang 2019-02-01 1378 (command[0] != '+' && command[0] != '-') ||
> 0e2e5b66 Nikolay Aleksandrov 2014-01-22 1379 !dev_valid_name(ifname))
> 0e2e5b66 Nikolay Aleksandrov 2014-01-22 1380 goto err_no_cmd;
> 0e2e5b66 Nikolay Aleksandrov 2014-01-22 1381
> 0e2e5b66 Nikolay Aleksandrov 2014-01-22 1382 dev = __dev_get_by_name(dev_net(bond->dev), ifname);
> 0e2e5b66 Nikolay Aleksandrov 2014-01-22 1383 if (!dev) {
> eac306b4 Michael Dilmore 2017-06-26 1384 netdev_dbg(bond->dev, "interface %s does not exist!\n",
> 2de390ba Veaceslav Falico 2014-07-15 1385 ifname);
> 0e2e5b66 Nikolay Aleksandrov 2014-01-22 1386 ret = -ENODEV;
> 0e2e5b66 Nikolay Aleksandrov 2014-01-22 1387 goto out;
> 0e2e5b66 Nikolay Aleksandrov 2014-01-22 1388 }
> 0e2e5b66 Nikolay Aleksandrov 2014-01-22 1389
> 0e2e5b66 Nikolay Aleksandrov 2014-01-22 1390 switch (command[0]) {
> 0e2e5b66 Nikolay Aleksandrov 2014-01-22 1391 case '+':
> eac306b4 Michael Dilmore 2017-06-26 1392 netdev_dbg(bond->dev, "Adding slave %s\n", dev->name);
> 33eaf2a6 David Ahern 2017-10-04 1393 ret = bond_enslave(bond->dev, dev, NULL);
> 0e2e5b66 Nikolay Aleksandrov 2014-01-22 1394 break;
> 0e2e5b66 Nikolay Aleksandrov 2014-01-22 1395
> 0e2e5b66 Nikolay Aleksandrov 2014-01-22 1396 case '-':
> eac306b4 Michael Dilmore 2017-06-26 1397 netdev_dbg(bond->dev, "Removing slave %s\n", dev->name);
> 0e2e5b66 Nikolay Aleksandrov 2014-01-22 1398 ret = bond_release(bond->dev, dev);
> 0e2e5b66 Nikolay Aleksandrov 2014-01-22 1399 break;
> 0e2e5b66 Nikolay Aleksandrov 2014-01-22 1400 }
> 0e2e5b66 Nikolay Aleksandrov 2014-01-22 1401
> 0e2e5b66 Nikolay Aleksandrov 2014-01-22 1402 out:
> 0e2e5b66 Nikolay Aleksandrov 2014-01-22 @1403 return ret;
> 0e2e5b66 Nikolay Aleksandrov 2014-01-22 1404
> 0e2e5b66 Nikolay Aleksandrov 2014-01-22 1405 err_no_cmd:
> 2de390ba Veaceslav Falico 2014-07-15 1406 netdev_err(bond->dev, "no command found in slaves file - use +ifname or -ifname\n");
> 0e2e5b66 Nikolay Aleksandrov 2014-01-22 1407 ret = -EPERM;
> 0e2e5b66 Nikolay Aleksandrov 2014-01-22 1408 goto out;
> 0e2e5b66 Nikolay Aleksandrov 2014-01-22 1409 }
> e9f0fb88 Mahesh Bandewar 2014-04-22 1410
>
> :::::: The code at line 1403 was first introduced by commit
> :::::: 0e2e5b66e9de377d69f50a456fdd60462889c64f bonding: convert slaves to use the new option API
>
> :::::: TO: Nikolay Aleksandrov <nikolay@redhat.com>
> :::::: CC: David S. Miller <davem@davemloft.net>
>
> ---
> 0-DAY kernel test infrastructure Open Source Technology Center
> https://lists.01.org/pipermail/kbuild-all Intel Corporation
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] bonding: check slave set command firstly
2019-02-01 14:07 [PATCH net-next] bonding: check slave set command firstly xiangxia.m.yue
2019-02-02 14:38 ` kbuild test robot
@ 2019-02-03 19:20 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2019-02-03 19:20 UTC (permalink / raw)
To: xiangxia.m.yue; +Cc: netdev
From: xiangxia.m.yue@gmail.com
Date: Fri, 1 Feb 2019 06:07:15 -0800
> From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
>
> This patch is a little improvement. If user use the
> command shown as below, we should print the info [1]
> instead of [2]. The eth0 exists actually, and it may
> confuse user.
>
> $ echo "eth0" > /sys/class/net/bond4/bonding/slaves
>
> [1] "bond4: no command found in slaves file - use +ifname or -ifname"
> [2] "write error: No such device"
>
> Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
Please fix the compiler warning reported to you.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-02-03 19:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-01 14:07 [PATCH net-next] bonding: check slave set command firstly xiangxia.m.yue
2019-02-02 14:38 ` kbuild test robot
2019-02-03 4:59 ` Tonghao Zhang
2019-02-03 19:20 ` David Miller
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).