Skip to contentSkip to conversation

PCI: remove an unnecessary if statement

PATCH In review Zhen Lei 2 participants 2 messages Sep 10, 2015 – Sep 18, 2015 PCI

lore
Share & tools
lore

Zhen Lei

author
#0 lore raw

PATCH 1/1 PCI: remove an unnecessary if statement

This patch have no functional change. Successful return count, otherwise return -ENODEV.

---
 drivers/pci/pci-driver.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/pci/pci-driver.c +3 -5
index 52a880c..02919ec 100644
@@ -172,7 +172,7 @@ static ssize_t store_remove_id(struct device_driver *driver, const char *buf,
 	__u32 vendor, device, subvendor = PCI_ANY_ID,
 		subdevice = PCI_ANY_ID, class = 0, class_mask = 0;
 	int fields = 0;
-	int retval = -ENODEV;
+	size_t retval = -ENODEV;
 
 	fields = sscanf(buf, "%x %x %x %x %x %x",
 			&vendor, &device, &subvendor, &subdevice,
@@ -190,15 +190,13 @@ static ssize_t store_remove_id(struct device_driver *driver, const char *buf,
 		    !((id->class ^ class) & class_mask)) {
 			list_del(&dynid->node);
 			kfree(dynid);
-			retval = 0;
+			retval = count;
 			break;
 		}
 	}
 	spin_unlock(&pdrv->dynids.lock);
 
-	if (retval)
-		return retval;
-	return count;
+	return retval;
 }
 static DRIVER_ATTR(remove_id, S_IWUSR, NULL, store_remove_id);
 

--
2.5.0

maintainer
#1 lore raw
Quoted 4 lines · Zhen Lei

This patch have no functional change. Successful return count, otherwise return -ENODEV.

Applied with changelog below to pci/misc for v4.4, thanks!

commit 9222097f0d2f88db602c0340d19d90a1c72b5fec

Author: Zhen Lei <[email protected]>
Date:   Thu Sep 10 18:40:31 2015 +0800

PCI: Remove unnecessary "if" statement

In store_remove_id(), set the default return value to -ENODEV, and overwrite it with the input buffer size if we find a matching list entry. Then we don't need to test whether to return an error or the count.

No functional change.

[bhelgaas: changelog]
Quoted 43 lines
---
 drivers/pci/pci-driver.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/pci/pci-driver.c +3 -6
index 52a880c..02919ec 100644
@@ -172,7 +172,7 @@ static ssize_t store_remove_id(struct device_driver *driver, const char *buf,
 	__u32 vendor, device, subvendor = PCI_ANY_ID,
 		subdevice = PCI_ANY_ID, class = 0, class_mask = 0;
 	int fields = 0;
-	int retval = -ENODEV;
+	size_t retval = -ENODEV;
 
 	fields = sscanf(buf, "%x %x %x %x %x %x",
 			&vendor, &device, &subvendor, &subdevice,
@@ -190,15 +190,13 @@ static ssize_t store_remove_id(struct device_driver *driver, const char *buf,
 		    !((id->class ^ class) & class_mask)) {
 			list_del(&dynid->node);
 			kfree(dynid);
-			retval = 0;
+			retval = count;
 			break;
 		}
 	}
 	spin_unlock(&pdrv->dynids.lock);
 
-	if (retval)
-		return retval;
-	return count;
+	return retval;
 }
 static DRIVER_ATTR(remove_id, S_IWUSR, NULL, store_remove_id);
 
--

2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html