Cleanup use of strlen() to check for empty string
PATCH 1/1 Cleanup use of strlen() to check for empty string
I came across checks for strlen(s)==0 a few places in drivers/xen. Here is a patch to fix that.
Jacob
--
Save time and bandwidth with EDelta: http://www.diku.dk/~jacobg/edelta/
linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c +1 -1
@@ -226,7 +226,7 @@ dev->nodename); goto free_be; } -if (strlen (frontend) ==0 || !xenbus_exists (frontend,"" )) { +if (*frontend=='\0' || !xenbus_exists (frontend,"" )) {/* If we can't get a frontend path and a frontend-id, * then our bus-id is no longer valid and we need to * destroy the backend device.
linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c +1 -1
@@ -537,7 +537,7 @@ NULL);if (XENBUS_EXIST_ERR (err)) goto out; -if (backend &&strlen (backend) ==0 ) { +if (backend && *backend =='\0' ) { err = -ENOENT ; goto out; }
linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c +1 -1
@@ -160,7 +160,7 @@ dev->nodename); goto free_be; } -if (strlen (frontend) ==0 || !xenbus_exists (frontend,"" )) { +if (*frontend=='\0' || !xenbus_exists (frontend,"" )) {/* If we can't get a frontend path and a frontend-id, * then our bus-id is no longer valid and we need to * destroy the backend device.
linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c +1 -1
@@ -230,7 +230,7 @@ dev->nodename); goto free_be; } -if (strlen (frontend) ==0 || !xenbus_exists (frontend,"" )) { +if (*frontend=='\0' || !xenbus_exists (frontend,"" )) {/* If we can't get a frontend path and a frontend-id, * then our bus-id is no longer valid and we need to * destroy the backend device.
linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c +1 -1
@@ -1090,7 +1090,7 @@ NULL);if (XENBUS_EXIST_ERR (err)) goto out; -if (backend &&strlen (backend) ==0 ) { +if (backend && *backend=='\0' ) { err = -ENOENT ; goto out; }
linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c +1 -1
@@ -209,7 +209,7 @@ dev->nodename); goto free_be; } -if (strlen (frontend) ==0 || !xenbus_exists (frontend,"" )) { +if (*frontend=='\0' || !xenbus_exists (frontend,"" )) {/* If we can't get a frontend path and a frontend-id, * then our bus-id is no longer valid and we need to * destroy the backend device.
linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c +1 -1
@@ -314,7 +314,7 @@ NULL);if (XENBUS_EXIST_ERR (err)) goto out; -if (backend &&strlen (backend) ==0 ) { +if (backend && *backend=='\0' ) { err = -ENOENT ; goto out; }
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c +1 -1
@@ -130,7 +130,7 @@ NULL);if (err)return err; -if (strlen (frontend) ==0 ) +if (*frontend=='\0' ) err = -ERANGE ;if (!err && !xenbus_exists (frontend,"" ))
linux-2.6-xen-sparse/include/asm-xen/xenbus.h +1 -1
@@ -129,7 +129,7 @@void xenbus_resume (void );#define XENBUS_IS_ERR_READ (str) ({ \ - if (!IS_ERR(str) && strlen(str) == 0) { \ + if (!IS_ERR(str) && *str=='\0') { \ kfree(str); \ str = ERR_PTR(-ERANGE); \ } \
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 2 lines · Jacob Gorm Hansen
I came across checks for strlen(s)==0 a few places in
drivers/xen. Here is a patch to fix that.
Isn't your patch exactly equivalent? None of that code is time critical enough that a call to strlen matters.
-- Keir
Quoted 8 lines · Keir Fraser
Quoted 2 lines · Jacob Gorm Hansen
I came across checks for strlen(s)==0 a few places in
drivers/xen. Here is a patch to fix that.Isn't your patch exactly equivalent? None of that code is time critical enough that a call to strlen matters.
It's just gross (looping over the entire length of a string just to see if the first char is empty) that's all. Apply if you will.
Jacob