Re: [PATCH] scsi_debug: Convert to use root_device_register() androot_device_unregister()

From: Nicholas A. Bellinger
Date: Mon Sep 06 2010 - 19:43:25 EST


On Mon, 2010-09-06 at 16:41 -0700, Dmitry Torokhov wrote:
> On Mon, Sep 06, 2010 at 03:32:20PM -0700, Nicholas A. Bellinger wrote:
> > static int __init scsi_debug_init(void)
> > {
> > unsigned long sz;
> > int host_to_add;
> > int k;
> > - int ret;
> > + int ret = 0;
> >
>
> Please do not initialize error condition with success; when adding
> additional initialization it makes easy to miss assigning proper return
> value (as you seem to have) and return success in case of failure.

The reason this was added because my gcc (Debian 4.3.2-1.1) 4.3.2
complained about this being possibily uninitialized..

>
> > switch (scsi_debug_sector_size) {
> > case 512:
> > @@ -3352,10 +3343,9 @@ static int __init scsi_debug_init(void)
> > map_region(0, 2);
> > }
> >
> > - ret = device_register(&pseudo_primary);
> > - if (ret < 0) {
> > - printk(KERN_WARNING "scsi_debug: device_register error: %d\n",
> > - ret);
> > + pseudo_primary = root_device_register("pseudo_0");
> > + if (!(pseudo_primary)) {
>
> root_device_register() returns ERR_PTR-encoded error codes, you should
> do:
>
> if (IS_ERR(pseudo_primary)) {
> printk(KERN_WARNING "scsi_debug: root_device_register() error\n");
> ret = PTR_ERR(pseudo_primary);
> goto free_vm;
> }
>
> Same goes for your other patch.

<nod> Updating that now.

Thanks,

--nab


--
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/