Re: Minor - patch 1.6.x - Fix some warnings in Connection.c
Omg haha I'm an oaf. Thanks! I'm surprised that also didn't cause another warning. On May 26, 2016 12:19 AM, "Willy Tarreau" wrote: > Hi Jonathan, > > On Tue, May 24, 2016 at 05:04:16AM -0500, Jonathan Fisher wrote: > > What's the style you prefer? > > This one without the double negation :-) > > - if (!memcmp(line, "TCP4 ", 5) != 0) { > + if (memcmp(line, "TCP4 ", 5) == 0) { > > I've just backported it now. > > Cheers, > Willy > >
Re: Minor - patch 1.6.x - Fix some warnings in Connection.c
Hi Jonathan, On Tue, May 24, 2016 at 05:04:16AM -0500, Jonathan Fisher wrote: > What's the style you prefer? This one without the double negation :-) - if (!memcmp(line, "TCP4 ", 5) != 0) { + if (memcmp(line, "TCP4 ", 5) == 0) { I've just backported it now. Cheers, Willy
Re: Minor - patch 1.6.x - Fix some warnings in Connection.c
What's the style you prefer? On May 24, 2016 1:10 AM, "Willy Tarreau" wrote: > Hi Jonathan, > > On Fri, May 20, 2016 at 01:14:31PM -0400, Jonathan Fisher wrote: > > These warnings bother me. > > > > > > > > -- > > *Jonathan S. Fisher* > > Senior Software Engineer > > https://twitter.com/exabrial > > http://www.tomitribe.com > > https://www.tomitribe.io > > > diff --git a/src/connection.c b/src/connection.c > > index 991cae3..12cdef0 100644 > > --- a/src/connection.c > > +++ b/src/connection.c > > @@ -385,7 +385,7 @@ int conn_recv_proxy(struct connection *conn, int > flag) > > if (trash.len < 9) /* shortest possible line */ > > goto missing; > > > > - if (!memcmp(line, "TCP4 ", 5) != 0) { > > + if ((!memcmp(line, "TCP4 ", 5)) != 0) { > > u32 src3, dst3, sport, dport; > > > > line += 5; > > @@ -426,7 +426,7 @@ int conn_recv_proxy(struct connection *conn, int > flag) > > ((struct sockaddr_in *)&conn->addr.to)->sin_port > = htons(dport); > > conn->flags |= CO_FL_ADDR_FROM_SET | CO_FL_ADDR_TO_SET; > > } > > - else if (!memcmp(line, "TCP6 ", 5) != 0) { > > + else if ((!memcmp(line, "TCP6 ", 5)) != 0) { > > u32 sport, dport; > > char *src_s; > > char *dst_s, *sport_s, *dport_s; > > Well, these fixes make the code even uglier than what it was. Please note > that these ones were already fixed some time ago by this patch > > commit 42ff05e2d3d10e8a1e070e66e8883c5eabe196d7 > Author: David CARLIER > Date: Thu Mar 24 09:22:36 2016 + > > CLEANUP: connection: fix double negation on memcmp() > > Nothing harmful in here, just clarify that it applies to the whole > expression. > > I'm noticing that I didn't backport this patch, I should pick it. > > Thanks, > Willy >
Re: Minor - patch 1.6.x - Fix some warnings in Connection.c
Hi Jonathan, On Fri, May 20, 2016 at 01:14:31PM -0400, Jonathan Fisher wrote: > These warnings bother me. > > > > -- > *Jonathan S. Fisher* > Senior Software Engineer > https://twitter.com/exabrial > http://www.tomitribe.com > https://www.tomitribe.io > diff --git a/src/connection.c b/src/connection.c > index 991cae3..12cdef0 100644 > --- a/src/connection.c > +++ b/src/connection.c > @@ -385,7 +385,7 @@ int conn_recv_proxy(struct connection *conn, int flag) > if (trash.len < 9) /* shortest possible line */ > goto missing; > > - if (!memcmp(line, "TCP4 ", 5) != 0) { > + if ((!memcmp(line, "TCP4 ", 5)) != 0) { > u32 src3, dst3, sport, dport; > > line += 5; > @@ -426,7 +426,7 @@ int conn_recv_proxy(struct connection *conn, int flag) > ((struct sockaddr_in *)&conn->addr.to)->sin_port = > htons(dport); > conn->flags |= CO_FL_ADDR_FROM_SET | CO_FL_ADDR_TO_SET; > } > - else if (!memcmp(line, "TCP6 ", 5) != 0) { > + else if ((!memcmp(line, "TCP6 ", 5)) != 0) { > u32 sport, dport; > char *src_s; > char *dst_s, *sport_s, *dport_s; Well, these fixes make the code even uglier than what it was. Please note that these ones were already fixed some time ago by this patch commit 42ff05e2d3d10e8a1e070e66e8883c5eabe196d7 Author: David CARLIER Date: Thu Mar 24 09:22:36 2016 + CLEANUP: connection: fix double negation on memcmp() Nothing harmful in here, just clarify that it applies to the whole expression. I'm noticing that I didn't backport this patch, I should pick it. Thanks, Willy
Minor - patch 1.6.x - Fix some warnings in Connection.c
These warnings bother me. -- *Jonathan S. Fisher* Senior Software Engineer https://twitter.com/exabrial http://www.tomitribe.com https://www.tomitribe.io diff --git a/src/connection.c b/src/connection.c index 991cae3..12cdef0 100644 --- a/src/connection.c +++ b/src/connection.c @@ -385,7 +385,7 @@ int conn_recv_proxy(struct connection *conn, int flag) if (trash.len < 9) /* shortest possible line */ goto missing; - if (!memcmp(line, "TCP4 ", 5) != 0) { + if ((!memcmp(line, "TCP4 ", 5)) != 0) { u32 src3, dst3, sport, dport; line += 5; @@ -426,7 +426,7 @@ int conn_recv_proxy(struct connection *conn, int flag) ((struct sockaddr_in *)&conn->addr.to)->sin_port = htons(dport); conn->flags |= CO_FL_ADDR_FROM_SET | CO_FL_ADDR_TO_SET; } - else if (!memcmp(line, "TCP6 ", 5) != 0) { + else if ((!memcmp(line, "TCP6 ", 5)) != 0) { u32 sport, dport; char *src_s; char *dst_s, *sport_s, *dport_s;