fix assignment in if-clause in smsc(4)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

fix assignment in if-clause in smsc(4)

Ricardo Mestre-2
Hi,

smsc(4) needs a fix to an assignment which I found with cppcheck. FreeBSD also
made this change 2 years ago on rev 295608.

OK?

Index: if_smsc.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/if_smsc.c,v
retrieving revision 1.31
diff -u -p -u -r1.31 if_smsc.c
--- if_smsc.c 29 Jul 2017 17:24:04 -0000 1.31
+++ if_smsc.c 24 Aug 2018 10:31:21 -0000
@@ -774,7 +774,7 @@ smsc_chip_init(struct smsc_softc *sc)
  smsc_write_reg(sc, SMSC_PM_CTRL, SMSC_PM_CTRL_PHY_RST);
 
  if ((err = smsc_wait_for_bits(sc, SMSC_PM_CTRL,
-    SMSC_PM_CTRL_PHY_RST) != 0)) {
+    SMSC_PM_CTRL_PHY_RST)) != 0) {
  smsc_warn_printf(sc, "timed-out waiting for phy reset to "
     "complete\n");
  goto init_failed;

Reply | Threaded
Open this post in threaded view
|

Re: fix assignment in if-clause in smsc(4)

Jeremie Courreges-Anglas-2
On Fri, Aug 24 2018, Ricardo Mestre <[hidden email]> wrote:
> Hi,
>
> smsc(4) needs a fix to an assignment which I found with cppcheck. FreeBSD also
> made this change 2 years ago on rev 295608.
>
> OK?

This diff shouldn't change the semantics but it looks saner this way
indeed.  ok jca@

The return value of smsc_chip_init() isn't checked, should it be?

> Index: if_smsc.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/usb/if_smsc.c,v
> retrieving revision 1.31
> diff -u -p -u -r1.31 if_smsc.c
> --- if_smsc.c 29 Jul 2017 17:24:04 -0000 1.31
> +++ if_smsc.c 24 Aug 2018 10:31:21 -0000
> @@ -774,7 +774,7 @@ smsc_chip_init(struct smsc_softc *sc)
>   smsc_write_reg(sc, SMSC_PM_CTRL, SMSC_PM_CTRL_PHY_RST);
>  
>   if ((err = smsc_wait_for_bits(sc, SMSC_PM_CTRL,
> -    SMSC_PM_CTRL_PHY_RST) != 0)) {
> +    SMSC_PM_CTRL_PHY_RST)) != 0) {
>   smsc_warn_printf(sc, "timed-out waiting for phy reset to "
>      "complete\n");
>   goto init_failed;
>

--
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply | Threaded
Open this post in threaded view
|

Re: fix assignment in if-clause in smsc(4)

Ricardo Mestre-2
I think it should since it might return != 0, but what exactly should be
done in this case? I don't have such hardware to test those conditions
and if it keeps working anyway or not if it happens.

On 13:25 Fri 24 Aug     , Jeremie Courreges-Anglas wrote:

> On Fri, Aug 24 2018, Ricardo Mestre <[hidden email]> wrote:
> > Hi,
> >
> > smsc(4) needs a fix to an assignment which I found with cppcheck. FreeBSD also
> > made this change 2 years ago on rev 295608.
> >
> > OK?
>
> This diff shouldn't change the semantics but it looks saner this way
> indeed.  ok jca@
>
> The return value of smsc_chip_init() isn't checked, should it be?
>
> > Index: if_smsc.c
> > ===================================================================
> > RCS file: /cvs/src/sys/dev/usb/if_smsc.c,v
> > retrieving revision 1.31
> > diff -u -p -u -r1.31 if_smsc.c
> > --- if_smsc.c 29 Jul 2017 17:24:04 -0000 1.31
> > +++ if_smsc.c 24 Aug 2018 10:31:21 -0000
> > @@ -774,7 +774,7 @@ smsc_chip_init(struct smsc_softc *sc)
> >   smsc_write_reg(sc, SMSC_PM_CTRL, SMSC_PM_CTRL_PHY_RST);
> >  
> >   if ((err = smsc_wait_for_bits(sc, SMSC_PM_CTRL,
> > -    SMSC_PM_CTRL_PHY_RST) != 0)) {
> > +    SMSC_PM_CTRL_PHY_RST)) != 0) {
> >   smsc_warn_printf(sc, "timed-out waiting for phy reset to "
> >      "complete\n");
> >   goto init_failed;
> >
>
> --
> jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE
>