Re: memset argument order misuses

From: Andrew Morton
Date: Sun Feb 13 2005 - 00:31:44 EST


Joe Korty <joe.korty@xxxxxxxx> wrote:
>
> Hi Andrew,
> A simple 'grep memset.*\<0);' shows argument order errors in several uses
> of memset.
>
> This grep was inspired by Al Viro's recent patch, megaraid_mbox fix,
> which fixed this problem in the megaraid driver.
>

heh. Lsydexic s/390 developers. Thanks, I guess we should scoot this into
2.6.11.


>
> Regards,
> Joe
> --
> "Money can buy bandwidth, but latency is forever" -- John Mashey
>
>
>
> diff -Nura base/drivers/s390/block/dasd_genhd.c new/drivers/s390/block/dasd_genhd.c
> --- base/drivers/s390/block/dasd_genhd.c 2004-12-24 16:35:24.000000000 -0500
> +++ new/drivers/s390/block/dasd_genhd.c 2005-02-12 21:55:48.546192009 -0500
> @@ -149,8 +149,8 @@
> * Can't call delete_partitions directly. Use ioctl.
> * The ioctl also does locking and invalidation.
> */
> - memset(&bpart, sizeof(struct blkpg_partition), 0);
> - memset(&barg, sizeof(struct blkpg_ioctl_arg), 0);
> + memset(&bpart, 0, sizeof(struct blkpg_partition));
> + memset(&barg, 0, sizeof(struct blkpg_ioctl_arg));
> barg.data = &bpart;
> barg.op = BLKPG_DEL_PARTITION;
> for (bpart.pno = device->gdp->minors - 1; bpart.pno > 0; bpart.pno--)
> diff -Nura base/drivers/s390/cio/cmf.c new/drivers/s390/cio/cmf.c
> --- base/drivers/s390/cio/cmf.c 2004-12-24 16:33:48.000000000 -0500
> +++ new/drivers/s390/cio/cmf.c 2005-02-12 21:56:08.430256458 -0500
> @@ -526,7 +526,7 @@
> time = get_clock() - cdev->private->cmb_start_time;
> spin_unlock_irqrestore(cdev->ccwlock, flags);
>
> - memset(data, sizeof(struct cmbdata), 0);
> + memset(data, 0, sizeof(struct cmbdata));
>
> /* we only know values before device_busy_time */
> data->size = offsetof(struct cmbdata, device_busy_time);
> @@ -736,7 +736,7 @@
> time = get_clock() - cdev->private->cmb_start_time;
> spin_unlock_irqrestore(cdev->ccwlock, flags);
>
> - memset (data, sizeof(struct cmbdata), 0);
> + memset (data, 0, sizeof(struct cmbdata));
>
> /* we only know values before device_busy_time */
> data->size = offsetof(struct cmbdata, device_busy_time);
> diff -Nura base/drivers/s390/cio/css.c new/drivers/s390/cio/css.c
> --- base/drivers/s390/cio/css.c 2005-02-12 21:51:28.000000000 -0500
> +++ new/drivers/s390/cio/css.c 2005-02-12 21:56:20.066538550 -0500
> @@ -527,7 +527,7 @@
> new_slow_sch = kmalloc(sizeof(struct slow_subchannel), GFP_ATOMIC);
> if (!new_slow_sch)
> return -ENOMEM;
> - memset(new_slow_sch, sizeof(struct slow_subchannel), 0);
> + memset(new_slow_sch, 0, sizeof(struct slow_subchannel));
> new_slow_sch->schid = schid;
> spin_lock_irqsave(&slow_subchannel_lock, flags);
> list_add_tail(&new_slow_sch->slow_list, &slow_subchannels_head);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/