floppy.c: Fix device_create_file() warning
Subsystems (2)
PATCH RESEND 5/5 floppy.c: Fix device_create_file() warning
This fixes the warning
warning: ignoring return value of device_create_file', declared with attribute warn_unused_result in function floppy_init'.
It does this by checking the return value and printing a warning message in case of no success.
---
drivers/block/floppy.c +6 -1
@@ -4302,7 +4302,12 @@ static int __init floppy_init(void)if (err) goto out_flush_work; -device_create_file (&floppy_device[drive].dev,&dev_attr_cmos); + err =device_create_file (&floppy_device[drive].dev, &dev_attr_cmos); +if (err) +printk (KERN_WARNING "Unable to create sysfs attribute " +"file for floppy device: %s\n" , + floppy_device[drive].name); +/* to be cleaned up... */ disks[drive]->private_data = (void *)(long )drive; disks[drive]->queue = floppy_queue;
drivers/block/floppy.c static int __init floppy_init(void) · line 4309
Quoted 8 lines
drivers/block/floppy.c +5
-1-device_create_file (&floppy_device[drive].dev,&dev_attr_cmos); + err =device_create_file (&floppy_device[drive].dev, &dev_attr_cmos); +if (err) +printk (KERN_WARNING "Unable to create sysfs attribute " +"file for floppy device: %s\n" , + floppy_device[drive].name);
That change looks pretty useless. Either the error should be handled correctly by bailing out or the warn_unused_results should be dropped.
-Andi
Quoted 9 lines · Andi Kleen
drivers/block/floppy.c static int __init floppy_init(void) · line 4309
Quoted 8 lines
drivers/block/floppy.c +5
-1-device_create_file (&floppy_device[drive].dev,&dev_attr_cmos); + err =device_create_file (&floppy_device[drive].dev, &dev_attr_cmos); +if (err) +printk (KERN_WARNING "Unable to create sysfs attribute " +"file for floppy device: %s\n" , + floppy_device[drive].name);
Quoted 3 lines
That change looks pretty useless. Either the error should be handled correctly by bailing out or the
warn_unused_resultsshould be dropped.
At least letting the user know that something failed is better than the current situation of just failing silently I'd say.
Signature · 3 lines
Jesper Juhl <[email protected]> Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html Plain text mails only, please http://www.expita.com/nomime.html
Quoted 10 lines · Jesper Juhl
Quoted 9 lines · Andi Kleen
Quoted 8 lines
drivers/block/floppy.c +5
-1-device_create_file (&floppy_device[drive].dev,&dev_attr_cmos); + err =device_create_file (&floppy_device[drive].dev, &dev_attr_cmos); +if (err) +printk (KERN_WARNING "Unable to create sysfs attribute " +"file for floppy device: %s\n" , + floppy_device[drive].name);
Quoted 5 lines
Quoted 3 lines
That change looks pretty useless. Either the error should be handled correctly by bailing out or the
warn_unused_resultsshould be dropped.At least letting the user know that something failed is better than the current situation of just failing silently I'd say.
I don't think so. That's just bloat.
-Andi
Quoted 10 lines · On Monday 19 March 2007 16:20:00 Andi Kleen wrote:
Quoted 9 lines · Jesper Juhl
Quoted 8 lines · Andi Kleen
Quoted 7 lines
-
device_create_file(&floppy_device[drive].dev,&dev_attr_cmos); +
err = device_create_file(&floppy_device[drive].dev,&dev_attr_cmos); + if (err)
+ printk(KERN_WARNING "Unable to create sysfs
attribute " + "file for floppy device:
%s\n", + floppy_device[drive].name);
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
That change looks pretty useless. Either the error should be handled correctly by bailing out or the
warn_unused_resultsshould be dropped.At least letting the user know that something failed is better than the current situation of just failing silently I'd say.
I don't think so. That's just bloat.
Ok, how about one of the following then?
Personally I'd be ok with either one.
Either this :
---
drivers/block/floppy.c +8 -1
@@ -4302,7 +4302,12 @@ static int __init floppy_init(void)if (err) goto out_flush_work; -device_create_file (&floppy_device[drive].dev,&dev_attr_cmos); + err =device_create_file (&floppy_device[drive].dev, &dev_attr_cmos); +if (err) { +printk (KERN_WARNING "Unable to create sysfs attribute " +"file for floppy device: %s\n" , + floppy_device[drive].name); + goto out_flush_work; + } +/* to be cleaned up... */
disks[drive]->private_data = (void *)(long)drive; disks[drive]->queue = floppy_queue;
or this :
---
drivers/block/floppy.c +4 -1
@@ -4302,7 +4302,12 @@ static int __init floppy_init(void)if (err) goto out_flush_work; -device_create_file (&floppy_device[drive].dev,&dev_attr_cmos); + err =device_create_file (&floppy_device[drive].dev, &dev_attr_cmos); +if (err) + goto out_flush_work; +/* to be cleaned up... */ disks[drive]->private_data = (void *)(long )drive; disks[drive]->queue = floppy_queue;