Skip to contentSkip to conversation

radeonfb: check return value of sysfs_create_bin_file

PATCH In review Luca Tettamanti 3 participants 5 messages Oct 11, 2006 – Oct 12, 2006 Framebuffer layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 radeonfb: check return value of sysfs_create_bin_file

sysfs_create_bin_file() is marked as warn_unused_result but we don't actually check the return value.
Error is not fatal, the driver can operate fine without the files so just print a notice on failure.

---

 drivers/video/aty/radeon_base.c |   15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/video/aty/radeon_base.c +11 -4
index 0ed577e..bc2aac6 100644
@@ -2313,10 +2313,17 @@ #endif
 	radeon_check_modes(rinfo, mode_option);
 
 	/* Register some sysfs stuff (should be done better) */
-	if (rinfo->mon1_EDID)
-		sysfs_create_bin_file(&rinfo->pdev->dev.kobj, &edid1_attr);
-	if (rinfo->mon2_EDID)
-		sysfs_create_bin_file(&rinfo->pdev->dev.kobj, &edid2_attr);
+	if (rinfo->mon1_EDID) {
+		if (sysfs_create_bin_file(&rinfo->pdev->dev.kobj, &edid1_attr))
+			printk(KERN_INFO "radeonfb (%s): failed to create edid1 file. "
+				"Continuing anyway.\n", pci_name(rinfo->pdev));
+	}
+
+	if (rinfo->mon2_EDID) {
+		if (sysfs_create_bin_file(&rinfo->pdev->dev.kobj, &edid2_attr))
+			printk(KERN_INFO "radeonfb (%s): failed to create edid2 file. "
+				"Continuing anyway.\n", pci_name(rinfo->pdev));
+	}
 
 	/* save current mode regs before we switch into the new one
 	 * so we can restore this upon __exit

Luca

Signature · 2 lines
Dicono che il cane sia il miglior amico dell'uomo. Secondo me non e`
vero. Quanti dei vostri amici avete fatto castrare, recentemente?
#1 lore raw
Quoted 4 lines · Luca Tettamanti

sysfs_create_bin_file() is marked as warn_unused_result but we don't actually check the return value.
Error is not fatal, the driver can operate fine without the files so just print a notice on failure.

I find this whole business of must check return value for sysfs files to be gratuitous bloat. There are many cases (like this one) where we don't really care and a printk will just increase the kernel size for no good reason.

Maybe we can have a macro we can use to silence the warning when we don't care about the result ? Can gcc do that ?

Ben.

#2 lore raw

Il Thu, Oct 12, 2006 at 10:07:26AM +1000, Benjamin Herrenschmidt ha scritto:

Quoted 6 lines · Luca Tettamanti
Quoted 4 lines

sysfs_create_bin_file() is marked as warn_unused_result but we don't actually check the return value.
Error is not fatal, the driver can operate fine without the files so just print a notice on failure.

Quoted 7 lines

I find this whole business of must check return value for sysfs files to be gratuitous bloat. There are many cases (like this one) where we don't really care and a printk will just increase the kernel size for no good reason.

Maybe we can have a macro we can use to silence the warning when we don't care about the result ? Can gcc do that ?

Ugly macro:

#define UNCHECKED(func) do { if (func) {} } while(0)

maybe it's better to have something like this:

int __sysfs_create_bin_file(...);
inline int sysfs_create_bin_file(...) __attribute__((warn_unused_result));

inline int sysfs_create_bin_file(...) {
        return __sysfs_create_bin_file(...);
}

i.e. both checked and uncheck version of the same function.

Luca

Signature · 2 lines
Un apostolo vedendo Gesu` camminare sulle acque:
- Cazzo se e` buono 'sto fumo!!!
#3 lore raw
Quoted 12 lines · Luca Tettamanti

Il Thu, Oct 12, 2006 at 10:07:26AM +1000, Benjamin Herrenschmidt ha scritto:

Quoted 11 lines · Luca Tettamanti
Quoted 4 lines

sysfs_create_bin_file() is marked as warn_unused_result but we don't actually check the return value.
Error is not fatal, the driver can operate fine without the files so just print a notice on failure.

I find this whole business of must check return value for sysfs files to be gratuitous bloat. There are many cases (like this one) where we don't really care and a printk will just increase the kernel size for no good reason.

Quoted 6 lines
Quoted 2 lines

Maybe we can have a macro we can use to silence the warning when we don't care about the result ? Can gcc do that ?

Ugly macro:

#define UNCHECKED(func) do { if (func) {} } while(0)

Better, but only marginally:

#define UNCHECKED(func) (void)(func)

Andreas.

Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected]
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
#4 lore raw

Il Thu, Oct 12, 2006 at 05:54:55PM +0200, Andreas Schwab ha scritto:

Quoted 17 lines
Quoted 15 lines · Luca Tettamanti

Il Thu, Oct 12, 2006 at 10:07:26AM +1000, Benjamin Herrenschmidt ha scritto:

Quoted 13 lines · Luca Tettamanti
Quoted 4 lines

sysfs_create_bin_file() is marked as warn_unused_result but we don't actually check the return value.
Error is not fatal, the driver can operate fine without the files so just print a notice on failure.

I find this whole business of must check return value for sysfs files to be gratuitous bloat. There are many cases (like this one) where we don't really care and a printk will just increase the kernel size for no good reason.

Maybe we can have a macro we can use to silence the warning when we don't care about the result ? Can gcc do that ?

Quoted 7 lines
Quoted 3 lines

Ugly macro:

#define UNCHECKED(func) do { if (func) {} } while(0)

Better, but only marginally:

#define UNCHECKED(func) (void)(func)

Nope, I tried[1] before sending the mail ;) warn_unused_result requires that you _use_ the result.

Luca
[1] kronos:~$ gcc --version
gcc (GCC) 4.1.2 20061007 (prerelease) (Debian 4.1.1-16)

Signature · 2 lines
"It is more complicated than you think"
                -- The Eighth Networking Truth from RFC 1925