[PATCH][5/5][resend] floppy.c: Fix device_create_file() warning

Previous thread: [PATCH][4/5][resend] floppy.c: Add explicit/better printk() levels by Jesper Juhl on Monday, March 19, 2007 - 8:10 am. (1 message)

Next thread: Oops after cd /sys/.../cpufreq/; rmmod; cat stats/time_in_state by Alexey Dobriyan on Monday, March 19, 2007 - 8:30 am. (13 messages)
From: Jesper Juhl
Date: Monday, March 19, 2007 - 8:11 am

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.
    
Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
Acked-by: Alan Cox <alan@redhat.com>
Acked-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---

diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 577c621..9d543f3 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -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;
-

From: Andi Kleen
Date: Monday, March 19, 2007 - 8:13 am

That change looks pretty useless. Either the error should be handled correctly
by bailing out or the warn_unused_results should be dropped.

-Andi
-

From: Jesper Juhl
Date: Monday, March 19, 2007 - 8:16 am

At least letting the user know that something failed is better than
the current situation of just failing silently I'd say.

-- 
Jesper Juhl <jesper.juhl@gmail.com>
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
-

From: Andi Kleen
Date: Monday, March 19, 2007 - 8:20 am

I don't think so. That's just bloat.

-Andi
-

From: Jesper Juhl
Date: Monday, March 19, 2007 - 10:42 am

Ok, how about one of the following then?  
Personally I'd be ok with either one.


Either this : 

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 577c621..9d543f3 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -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 : 


Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 577c621..9d543f3 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -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;

-

Previous thread: [PATCH][4/5][resend] floppy.c: Add explicit/better printk() levels by Jesper Juhl on Monday, March 19, 2007 - 8:10 am. (1 message)