bad print in hdparm.c

Mike Frysinger vapier at gentoo.org
Wed May 20 08:51:29 UTC 2009


On Wednesday 20 May 2009 04:43:39 walter harms wrote:
> Amir Rapson schrieb:
> > A wrong print out when setting spin down timeout using hdparm:
> >
> > diff -Nuar busybox-1.13.3/miscutils/hdparm.c
> > busybox-1.13.3.new/miscutils/hdparm.c
> > --- busybox-1.13.3/miscutils/hdparm.c   2009-02-26 13:47:23.000000000
> > +0200 +++ busybox-1.13.3.new/miscutils/hdparm.c   2009-05-20
> > 11:02:38.000000000 +0300
> > @@ -1453,7 +1453,7 @@
> >         printf("%u minutes %u seconds", standby / 12, (standby*5) % 60);
> >     } else if (standby <= 251) {
> >         unsigned t = (standby - 240); /* t is in 30 min units */;
> > -       printf("%u.%c hours", t / 2, (t & 1) ? '0' : '5');
> > +       printf("%u.%c hours", t / 2, (t & 1) ? '5' : '0');
> >     }
> >     if (standby == 253)
> >         printf("vendor-specific");
>
> maybe you can reduce this also ?
>
> >printf("%u minutes %u seconds", standby / 12, (standby*5) % 60);
>
> <printf("%u minutes %u seconds", standby / 12, standby % 12);

better to write it as (60 / 5) so people dont get confused as to where this 
magic 12 is coming from
-mike


More information about the busybox mailing list