From: Tom Lendacky <thomas.lendacky@amd.com>
To: Julia Lawall <julia.lawall@lip6.fr>
Cc: <netdev@vger.kernel.org>, <kbuild-all@01.org>
Subject: Re: [net-next:master 664/670] drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c:1421:7-9: WARNING: possible condition with no effect (if == else)
Date: Mon, 14 Nov 2016 08:49:22 -0600 [thread overview]
Message-ID: <9b026acd-7bfc-cc6e-5f11-acb6b94a2347@amd.com> (raw)
In-Reply-To: <alpine.DEB.2.20.1611131910380.1946@hadrien>
On 11/13/2016 12:12 PM, Julia Lawall wrote:
> It looks like the code on lines 1422 and 1424 is the same, so either the
> test may be unnecessary, or one of the branches is wrong.
I was trying to show that for a cable length of less than 5 meters I was
using a specific sub-command and that for anything longer I was falling
back to the 5 meter value. I can see how it doesn't look right and I'll
clean it up with a patch.
>
> Coccinelle is also comparing about a comparison on an unsigned value in
> line 1900, but the code for that is not listed in the report below.
Ok, good catch. I'll fix this up with a patch also.
Thanks,
Tom
>
> julia
>
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git master
> head: f7ad3d4b83e694347cddc96d956143068bef32c9
> commit: abf0a1c2b26ad964d19b143ce46735e1b0667f29 [664/670] amd-xgbe: Add support for SFP+ modules
> :::::: branch date: 16 minutes ago
> :::::: commit date: 12 hours ago
>
>>> drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c:1421:7-9: WARNING: possible condition with no effect (if == else)
> --
>>> drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c:1900:6-9: WARNING: Unsigned expression compared with zero: ret < 0
>
> git remote add net-next https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git
> git remote update net-next
> git checkout abf0a1c2b26ad964d19b143ce46735e1b0667f29
> vim +1421 drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c
>
> abf0a1c2 Lendacky, Thomas 2016-11-10 1405 {
> abf0a1c2 Lendacky, Thomas 2016-11-10 1406 struct xgbe_phy_data *phy_data = pdata->phy_data;
> abf0a1c2 Lendacky, Thomas 2016-11-10 1407 unsigned int s0;
> abf0a1c2 Lendacky, Thomas 2016-11-10 1408
> abf0a1c2 Lendacky, Thomas 2016-11-10 1409 xgbe_phy_start_ratechange(pdata);
> abf0a1c2 Lendacky, Thomas 2016-11-10 1410
> abf0a1c2 Lendacky, Thomas 2016-11-10 1411 /* 10G/SFI */
> abf0a1c2 Lendacky, Thomas 2016-11-10 1412 s0 = 0;
> abf0a1c2 Lendacky, Thomas 2016-11-10 1413 XP_SET_BITS(s0, XP_DRIVER_SCRATCH_0, COMMAND, 3);
> abf0a1c2 Lendacky, Thomas 2016-11-10 1414 if (phy_data->sfp_cable != XGBE_SFP_CABLE_PASSIVE) {
> abf0a1c2 Lendacky, Thomas 2016-11-10 1415 XP_SET_BITS(s0, XP_DRIVER_SCRATCH_0, SUB_COMMAND, 0);
> abf0a1c2 Lendacky, Thomas 2016-11-10 1416 } else {
> abf0a1c2 Lendacky, Thomas 2016-11-10 1417 if (phy_data->sfp_cable_len <= 1)
> abf0a1c2 Lendacky, Thomas 2016-11-10 1418 XP_SET_BITS(s0, XP_DRIVER_SCRATCH_0, SUB_COMMAND, 1);
> abf0a1c2 Lendacky, Thomas 2016-11-10 1419 else if (phy_data->sfp_cable_len <= 3)
> abf0a1c2 Lendacky, Thomas 2016-11-10 1420 XP_SET_BITS(s0, XP_DRIVER_SCRATCH_0, SUB_COMMAND, 2);
> abf0a1c2 Lendacky, Thomas 2016-11-10 @1421 else if (phy_data->sfp_cable_len <= 5)
> abf0a1c2 Lendacky, Thomas 2016-11-10 1422 XP_SET_BITS(s0, XP_DRIVER_SCRATCH_0, SUB_COMMAND, 3);
> abf0a1c2 Lendacky, Thomas 2016-11-10 1423 else
> abf0a1c2 Lendacky, Thomas 2016-11-10 1424 XP_SET_BITS(s0, XP_DRIVER_SCRATCH_0, SUB_COMMAND, 3);
> abf0a1c2 Lendacky, Thomas 2016-11-10 1425 }
> abf0a1c2 Lendacky, Thomas 2016-11-10 1426
> abf0a1c2 Lendacky, Thomas 2016-11-10 1427 /* Call FW to make the change */
> abf0a1c2 Lendacky, Thomas 2016-11-10 1428 XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_0, s0);
> abf0a1c2 Lendacky, Thomas 2016-11-10 1429 XP_IOWRITE(pdata, XP_DRIVER_SCRATCH_1, 0);
>
> ---
> 0-DAY kernel test infrastructure Open Source Technology Center
> https://lists.01.org/pipermail/kbuild-all Intel Corporation
>
prev parent reply other threads:[~2016-11-14 14:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-13 18:12 [net-next:master 664/670] drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c:1421:7-9: WARNING: possible condition with no effect (if == else) Julia Lawall
2016-11-14 14:49 ` Tom Lendacky [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=9b026acd-7bfc-cc6e-5f11-acb6b94a2347@amd.com \
--to=thomas.lendacky@amd.com \
--cc=julia.lawall@lip6.fr \
--cc=kbuild-all@01.org \
--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 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.