Bug in mtd_speedtest?

Artem Bityutskiy dedekind1 at gmail.com
Mon Mar 7 05:09:40 EST 2011


On Fri, 2011-03-04 at 11:53 -0600, David Lambert wrote:
> Artem,
>      Please find attached patch.

Thank you, but you made pretty good job to prevent me from applying
it! :-)

> Index: mtd_speedtest.c
> ===================================================================
> RCS
> file: /home/cvsroot/ECMB/src/snapgear/linux-2.6.30.1.x/drivers/mtd/tests/mtd_speedtest.c,v
> retrieving revision 1.1.1.1
> diff -u -r1.1.1.1 mtd_speedtest.c

This means git am won't work... neither patch -p1 ...
Also, not author name (From:), not commit message, not Signed-off-by...

> --- mtd_speedtest.c     10 Aug 2009 19:42:00 -0000      1.1.1.1
> +++ mtd_speedtest.c     4 Mar 2011 17:51:23 -0000
> @@ -281,13 +281,14 @@
>  
>  static long calc_speed(void)
>  {
> -       long ms, k, speed;
> +       uint64_t k;
> +       long ms;
>  
> -       ms = (finish.tv_sec - start.tv_sec) * 1000 +
> -            (finish.tv_usec - start.tv_usec) / 1000;
> -       k = goodebcnt * mtd->erasesize / 1024;
> -       speed = (k * 1000) / ms;
> -       return speed;
> +       ms = (finish.tv_sec - start.tv_sec) * 1000 + /* Time in milli-seconds from start to ...*/
> +            (finish.tv_usec - start.tv_usec) / 1000;     /* finish */

This would not pass scripts/checkpatch.pl. Please, kill the comments.
Also, I you use spaces instead of tabs...

> +       k = (goodebcnt * (mtd->erasesize / 1024) * 1000); /* Number of kBytes transferred * 1000 */
> +       do_div(k, ms);    /* k now contains number of kBytes/second */

The old code had a check against ms == 0, you removed it, why?

> +       return k;

Anyway, since I anyway spent 20 minutes with this patch, here is what I
ended up. I've pushed it to my l2 tree. If I made a mistake or you are
unhappy about it, please, send your *properly formatted* version
instead.

Thanks!



More information about the linux-mtd mailing list