Skip to contentSkip to conversation

staging: usbip: stub_main: correctly handle return value

PATCH In review navin patidar 2 participants 2 messages Sep 10, 2013 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 staging: usbip: stub_main: correctly handle return value

ret == 0 means success, anything else is failure.

---
 drivers/staging/usbip/stub_main.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/usbip/stub_main.c +2 -2
index 33027cc..baf857f 100644
@@ -255,14 +255,14 @@ static int __init usbip_host_init(void)
 	}
 
 	ret = usb_register(&stub_driver);
-	if (ret < 0) {
+	if (ret) {
 		pr_err("usb_register failed %d\n", ret);
 		goto err_usb_register;
 	}
 
 	ret = driver_create_file(&stub_driver.drvwrap.driver,
 				 &driver_attr_match_busid);
-	if (ret < 0) {
+	if (ret) {
 		pr_err("driver_create_file failed\n");
 		goto err_create_file;
 	}
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 2 lines · navin patidar

ret == 0 means success, anything else is failure.

Hopefully, it's only returning negative error codes. Otherwise it needs a different fix.

There isn't an official kernel style on if "if (ret < 0)" is better than "if (ret)". Some subsystems have a preference but most don't care. It's up to the maintainer to choose.

Your patch is fine, but the changelog is misleading. It should just say "I prefer the other style" instead of "This code is wrong and has buggy error handling".

regards,
dan carpenter