From: Jacob Gorm Hansen Subject: [PATCH] Cleanup use of strlen() to check for empty string Date: Wed, 5 Oct 2005 00:50:20 +0200 Message-ID: Reply-To: Jacob Gorm Hansen Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_15207_14691688.1128466220596" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org ------=_Part_15207_14691688.1128466220596 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I came across checks for strlen(s)=3D=3D0 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/ ------=_Part_15207_14691688.1128466220596 Content-Type: application/octet-stream; name=strlen_cleanup.patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="strlen_cleanup.patch" diff -r 00037ba13f0b linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c --- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Tue Oct 4 17:23:58 2005 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Wed Oct 5 00:46:36 2005 @@ -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. diff -r 00037ba13f0b linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c Tue Oct 4 17:23:58 2005 +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c Wed Oct 5 00:46:36 2005 @@ -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; } diff -r 00037ba13f0b linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c --- a/linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c Tue Oct 4 17:23:58 2005 +++ b/linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c Wed Oct 5 00:46:36 2005 @@ -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. diff -r 00037ba13f0b linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c --- a/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c Tue Oct 4 17:23:58 2005 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c Wed Oct 5 00:46:36 2005 @@ -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. diff -r 00037ba13f0b linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Tue Oct 4 17:23:58 2005 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Wed Oct 5 00:46:36 2005 @@ -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; } diff -r 00037ba13f0b linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c --- a/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c Tue Oct 4 17:23:58 2005 +++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c Wed Oct 5 00:46:36 2005 @@ -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. diff -r 00037ba13f0b linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c --- a/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c Tue Oct 4 17:23:58 2005 +++ b/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c Wed Oct 5 00:46:36 2005 @@ -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; } diff -r 00037ba13f0b linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Tue Oct 4 17:23:58 2005 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Wed Oct 5 00:46:36 2005 @@ -130,7 +130,7 @@ NULL); if (err) return err; - if (strlen(frontend) == 0) + if (*frontend=='\0') err = -ERANGE; if (!err && !xenbus_exists(frontend, "")) diff -r 00037ba13f0b linux-2.6-xen-sparse/include/asm-xen/xenbus.h --- a/linux-2.6-xen-sparse/include/asm-xen/xenbus.h Tue Oct 4 17:23:58 2005 +++ b/linux-2.6-xen-sparse/include/asm-xen/xenbus.h Wed Oct 5 00:46:36 2005 @@ -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); \ } \ ------=_Part_15207_14691688.1128466220596 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel ------=_Part_15207_14691688.1128466220596--