[BZ,#16876] Fix typo in nptl/sockperf.c
diff mbox

Message ID 20140427160257.GA5627@domone.podge
State New
Headers show

Commit Message

Ondřej Bílka April 27, 2014, 4:02 p.m. UTC
Hi, as described in

https://sourceware.org/bugzilla/show_bug.cgi?id=16876

relevant if test does not make sense as it tests if pointer is negative.
A clisock variable is unused outside of this test so we should fix it to
intended behaviour.

OK to commit?


	[BZ #16876]
	* nptl/sockperf.c (client): Check if socket exist.

Comments

Ondřej Bílka May 3, 2014, 9:18 a.m. UTC | #1
On Sun, Apr 27, 2014 at 06:02:57PM +0200, Ondřej Bílka wrote:
> Hi, as described in
> 
> https://sourceware.org/bugzilla/show_bug.cgi?id=16876
> 
> relevant if test does not make sense as it tests if pointer is negative.
> A clisock variable is unused outside of this test so we should fix it to
> intended behaviour.
> 
> OK to commit?
> 
> 
> 	[BZ #16876]
> 	* nptl/sockperf.c (client): Check if socket exist.
> 
> diff --git a/nptl/sockperf.c b/nptl/sockperf.c
> index 740fb88..2d4b872 100644
> --- a/nptl/sockperf.c
> +++ b/nptl/sockperf.c
> @@ -71,7 +71,6 @@ client (void *arg)
>    struct thread_param *param = arg;
>    unsigned int cnt;
>    unsigned int nserv = param->nserv;
> -  int clisock[nserv];
>    struct pollfd servpoll[nserv];
>    struct sockaddr_un servaddr;
>    socklen_t servlen;
> @@ -102,7 +101,7 @@ client (void *arg)
>    for (cnt = 0; cnt < nserv; ++cnt)
>      {
>        servpoll[cnt].fd = socket (AF_UNIX, SOCK_STREAM, 0);
> -      if (clisock < 0)
> +      if (servpoll[cnt].fd < 0)
>  	{
>  	  puts ("cannot create socket in client");
>  	  return NULL;
Will Newton May 6, 2014, 8:03 a.m. UTC | #2
On 27 April 2014 17:02, Ondřej Bílka <neleai@seznam.cz> wrote:
> Hi, as described in
>
> https://sourceware.org/bugzilla/show_bug.cgi?id=16876
>
> relevant if test does not make sense as it tests if pointer is negative.
> A clisock variable is unused outside of this test so we should fix it to
> intended behaviour.
>
> OK to commit?
>
>
>         [BZ #16876]
>         * nptl/sockperf.c (client): Check if socket exist.

"Check socket return value" would be clearer I think, but otherwise
looks ok to me.

> diff --git a/nptl/sockperf.c b/nptl/sockperf.c
> index 740fb88..2d4b872 100644
> --- a/nptl/sockperf.c
> +++ b/nptl/sockperf.c
> @@ -71,7 +71,6 @@ client (void *arg)
>    struct thread_param *param = arg;
>    unsigned int cnt;
>    unsigned int nserv = param->nserv;
> -  int clisock[nserv];
>    struct pollfd servpoll[nserv];
>    struct sockaddr_un servaddr;
>    socklen_t servlen;
> @@ -102,7 +101,7 @@ client (void *arg)
>    for (cnt = 0; cnt < nserv; ++cnt)
>      {
>        servpoll[cnt].fd = socket (AF_UNIX, SOCK_STREAM, 0);
> -      if (clisock < 0)
> +      if (servpoll[cnt].fd < 0)
>         {
>           puts ("cannot create socket in client");
>           return NULL;

Patch
diff mbox

diff --git a/nptl/sockperf.c b/nptl/sockperf.c
index 740fb88..2d4b872 100644
--- a/nptl/sockperf.c
+++ b/nptl/sockperf.c
@@ -71,7 +71,6 @@  client (void *arg)
   struct thread_param *param = arg;
   unsigned int cnt;
   unsigned int nserv = param->nserv;
-  int clisock[nserv];
   struct pollfd servpoll[nserv];
   struct sockaddr_un servaddr;
   socklen_t servlen;
@@ -102,7 +101,7 @@  client (void *arg)
   for (cnt = 0; cnt < nserv; ++cnt)
     {
       servpoll[cnt].fd = socket (AF_UNIX, SOCK_STREAM, 0);
-      if (clisock < 0)
+      if (servpoll[cnt].fd < 0)
 	{
 	  puts ("cannot create socket in client");
 	  return NULL;