Skip to contentSkip to conversation

cxgb3: Fix __must_check warning.

PATCH In review Dan Noe 2 participants 5 messages Apr 2, 2008

Subsystems (2)
lore
Share & tools
lore

Dan Noe

author
#0 lore raw

PATCH 1/1 cxgb3: Fix __must_check warning.

Fix the warning:
drivers/net/cxgb3/cxgb3_main.c: In function ‘offload_open’:
drivers/net/cxgb3/cxgb3_main.c:936: warning: ignoring return value of ‘sysfs_create_group’, declared with attribute warn_unused_result

Now the return value is checked; if sysfs_create_group() returns failure, a warning is printed, and the code continues as before.

---
 drivers/net/cxgb3/cxgb3_main.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

My first patch - feedback is appreciated, please be gentle. Thanks!

drivers/net/cxgb3/cxgb3_main.c +2 -1
index fd2e05b..3007fe1 100644
@@ -1015,7 +1015,8 @@ static int offload_open(struct net_device *dev)
 	init_smt(adapter);
 
 	/* Never mind if the next step fails */
-	sysfs_create_group(&tdev->lldev->dev.kobj, &offload_attr_group);
+	if (sysfs_create_group(&tdev->lldev->dev.kobj, &offload_attr_group))
+		printk(KERN_WARNING DRV_NAME ": cannot create sysfs group\n");
 
 	/* Call back all registered clients */
 	cxgb3_add_clients(tdev);
Signature · 1 line
1.5.2.5
#1 lore raw
Quoted 19 lines · Dan Noe

Fix the warning:
drivers/net/cxgb3/cxgb3_main.c: In function ‘offload_open’:
drivers/net/cxgb3/cxgb3_main.c:936: warning: ignoring return value of ‘sysfs_create_group’, declared with attribute warn_unused_result

Now the return value is checked; if sysfs_create_group() returns failure, a warning is printed, and the code continues as before.

---
 drivers/net/cxgb3/cxgb3_main.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

My first patch - feedback is appreciated, please be gentle. Thanks!

drivers/net/cxgb3/cxgb3_main.c +0 -0
index fd2e05b..3007fe1 100644

drivers/net/cxgb3/cxgb3_main.c static int offload_open(struct net_device *dev) · line 1019

Quoted 6 lines
drivers/net/cxgb3/cxgb3_main.c +2 -1
@@ -1015,7 +1015,8 @@ static int offload_open(struct net_device *dev)
 	init_smt(adapter);
 
 	/* Never mind if the next step fails */
-	sysfs_create_group(&tdev->lldev->dev.kobj, &offload_attr_group);
+	if (sysfs_create_group(&tdev->lldev->dev.kobj, &offload_attr_group))
+		printk(KERN_WARNING DRV_NAME ": cannot create sysfs group\n");

Two things:

1) You've obsoleted the preceding comment, so you might as well remove it.

2) The original author quite explicitly didn't think this was worth a printk. printk calls expand the kernel binary, which has a cost, so we shouldn't be adding printk calls *just* to shut up a build warning. Personally, I think this is the sort of thing I might like to know about if I were debugging something, so it might make sense to make it a dev_dbg. When DEBUG is not set, no printk gets compiled in, so the binary stays lean, but you can still get the message if you compile with DEBUG enabled.

-- Chris

author
#2 lore raw

PATCH 1/1 cxgb3: Fix __must_check warning with dev_dbg.

Fix the warning:
drivers/net/cxgb3/cxgb3_main.c: In function ‘offload_open’:
drivers/net/cxgb3/cxgb3_main.c:936: warning: ignoring return value of
‘sysfs_create_group’, declared with attribute warn_unused_result

Now the return value is checked; if sysfs_create_group() returns failure, a warning is printed using dev_dbg, and the code continues as before. Use of dev_dbg ensures printk is not needlessly included unless desired for debugging.

---
 drivers/net/cxgb3/cxgb3_main.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/cxgb3/cxgb3_main.c +2 -2
index fd2e05b..0ddc34a 100644
@@ -1014,8 +1014,8 @@ static int offload_open(struct net_device *dev)
 		     adapter->port[0]->mtu : 0xffff);
 	init_smt(adapter);
 
-	/* Never mind if the next step fails */
-	sysfs_create_group(&tdev->lldev->dev.kobj, &offload_attr_group);
+	if (sysfs_create_group(&tdev->lldev->dev.kobj, &offload_attr_group))
+		dev_dbg(&dev->dev, ": cannot create sysfs group\n");
 
 	/* Call back all registered clients */
 	cxgb3_add_clients(tdev);
Signature · 1 line
1.5.2.5
#3 lore raw

Re: [PATCH] cxgb3: Fix __must_check warning with dev_dbg.

Quoted 20 lines · Dan Noe

Fix the warning:
drivers/net/cxgb3/cxgb3_main.c: In function ‘offload_open’:
drivers/net/cxgb3/cxgb3_main.c:936: warning: ignoring return value of
‘sysfs_create_group’, declared with attribute warn_unused_result

Now the return value is checked; if sysfs_create_group() returns failure, a warning is printed using dev_dbg, and the code continues as before. Use of dev_dbg ensures printk is not needlessly included unless desired for debugging.

---
 drivers/net/cxgb3/cxgb3_main.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/cxgb3/cxgb3_main.c +0 -0
index fd2e05b..0ddc34a 100644

drivers/net/cxgb3/cxgb3_main.c static int offload_open(struct net_device *dev) · line 1021

Quoted 10 lines
drivers/net/cxgb3/cxgb3_main.c +2 -2
@@ -1014,8 +1014,8 @@ static int offload_open(struct net_device *dev)
 		     adapter->port[0]->mtu : 0xffff);
 	init_smt(adapter);
 
-	/* Never mind if the next step fails */
-	sysfs_create_group(&tdev->lldev->dev.kobj, &offload_attr_group);
+	if (sysfs_create_group(&tdev->lldev->dev.kobj, &offload_attr_group))
+		dev_dbg(&dev->dev, ": cannot create sysfs group\n");
 
 	/* Call back all registered clients */
 	cxgb3_add_clients(tdev);

Close. dev_dbg() invokes dev_printk(), which provides the ": ", so you can take those two characters out of the string literal.

-- Chris

author
#4 lore raw

PATCH 1/1 cxgb3: Fix __must_check warning with dev_dbg.

Fix the warning:
drivers/net/cxgb3/cxgb3_main.c: In function ‘offload_open’:
drivers/net/cxgb3/cxgb3_main.c:936: warning: ignoring return value of
‘sysfs_create_group’, declared with attribute warn_unused_result

Now the return value is checked; if sysfs_create_group() returns failure, a warning is printed using dev_dbg, and the code continues as before. Use of dev_dbg ensures printk is not needlessly included unless desired for debugging.

---
 drivers/net/cxgb3/cxgb3_main.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Fixed to use the correct format for dev_dbg, and to use dev_dbg as suggested by Chris Snook. Thanks.

drivers/net/cxgb3/cxgb3_main.c +2 -2
index fd2e05b..05e5f59 100644
@@ -1014,8 +1014,8 @@ static int offload_open(struct net_device *dev)
 		     adapter->port[0]->mtu : 0xffff);
 	init_smt(adapter);
 
-	/* Never mind if the next step fails */
-	sysfs_create_group(&tdev->lldev->dev.kobj, &offload_attr_group);
+	if (sysfs_create_group(&tdev->lldev->dev.kobj, &offload_attr_group))
+		dev_dbg(&dev->dev, "cannot create sysfs group\n");
 
 	/* Call back all registered clients */
 	cxgb3_add_clients(tdev);
Signature · 1 line
1.5.2.5