Re: [PATCH] usb: remove redundant conditions
Hi, "Geyslan G. Bem" writes: > 2015-12-10 12:13 GMT-03:00 Felipe Balbi : >> "Geyslan G. Bem" writes: >> >>> This patch removes redundant conditions. >>> >>> - (!A || (A && B)) is the same as (!A || B). >>> - (length && length > 5) can be reduced to a single evaluation. >>> >>> Caught by: cppcheck >>> >>> Signed-off-by: Geyslan G. Bem >>> --- >> >> I guess you didn't get previous comment in time; let's split this per >> driver so different maintainers can pick their parts. > > Okeydokey. :) thanks :-) -- balbi signature.asc Description: PGP signature
Re: [PATCH] usb: remove redundant conditions
2015-12-10 12:29 GMT-03:00 Geyslan G. Bem : > 2015-12-10 12:17 GMT-03:00 David Laight : >> From: Felipe Balbi >>> Sent: 10 December 2015 15:14 >>> "Geyslan G. Bem" writes: >>> >>> > This patch removes redundant conditions. >>> > >>> > - (!A || (A && B)) is the same as (!A || B). >>> > - (length && length > 5) can be reduced to a single evaluation. >>> > >>> > Caught by: cppcheck >>> > >>> > Signed-off-by: Geyslan G. Bem >>> > --- >>> >>> I guess you didn't get previous comment in time; let's split this per >>> driver so different maintainers can pick their parts. >> >> I also suspect that gcc will optimise out the redundant checks as well. > Yes, David. it will. > > Let's see. > > void f(int f, int s) > { > if (!f || (f && s)) > printf("branch\n"); > } > > Generates without optimization three comparisons: > > cmpl$0, -4(%rbp) > je .L2 > cmpl$0, -4(%rbp) > je .L4 > cmpl$0, -8(%rbp) > je .L4 > > But with -O2 it generates only two: > > testl %edi, %edi > je .L2 > testl %esi, %esi > je .L1 > > Despite that, I think that the patches are welcome since they silence > checkpatch and make code clearer. Don't you think? Sorry, silence "cppcheck". I'm mistaking the tool name. > >> >> David >> > > > > -- > Regards, > > Geyslan G. Bem > hackingbits.com -- Regards, Geyslan G. Bem hackingbits.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] usb: remove redundant conditions
2015-12-10 12:17 GMT-03:00 David Laight : > From: Felipe Balbi >> Sent: 10 December 2015 15:14 >> "Geyslan G. Bem" writes: >> >> > This patch removes redundant conditions. >> > >> > - (!A || (A && B)) is the same as (!A || B). >> > - (length && length > 5) can be reduced to a single evaluation. >> > >> > Caught by: cppcheck >> > >> > Signed-off-by: Geyslan G. Bem >> > --- >> >> I guess you didn't get previous comment in time; let's split this per >> driver so different maintainers can pick their parts. > > I also suspect that gcc will optimise out the redundant checks as well. Yes, David. it will. Let's see. void f(int f, int s) { if (!f || (f && s)) printf("branch\n"); } Generates without optimization three comparisons: cmpl$0, -4(%rbp) je .L2 cmpl$0, -4(%rbp) je .L4 cmpl$0, -8(%rbp) je .L4 But with -O2 it generates only two: testl %edi, %edi je .L2 testl %esi, %esi je .L1 Despite that, I think that the patches are welcome since they silence checkpatch and make code clearer. Don't you think? > > David > -- Regards, Geyslan G. Bem hackingbits.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH] usb: remove redundant conditions
From: Felipe Balbi > Sent: 10 December 2015 15:14 > "Geyslan G. Bem" writes: > > > This patch removes redundant conditions. > > > > - (!A || (A && B)) is the same as (!A || B). > > - (length && length > 5) can be reduced to a single evaluation. > > > > Caught by: cppcheck > > > > Signed-off-by: Geyslan G. Bem > > --- > > I guess you didn't get previous comment in time; let's split this per > driver so different maintainers can pick their parts. I also suspect that gcc will optimise out the redundant checks as well. David -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] usb: remove redundant conditions
2015-12-10 12:13 GMT-03:00 Felipe Balbi : > "Geyslan G. Bem" writes: > >> This patch removes redundant conditions. >> >> - (!A || (A && B)) is the same as (!A || B). >> - (length && length > 5) can be reduced to a single evaluation. >> >> Caught by: cppcheck >> >> Signed-off-by: Geyslan G. Bem >> --- > > I guess you didn't get previous comment in time; let's split this per > driver so different maintainers can pick their parts. Okeydokey. :) > > -- > balbi -- Regards, Geyslan G. Bem hackingbits.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] usb: remove redundant conditions
"Geyslan G. Bem" writes: > This patch removes redundant conditions. > > - (!A || (A && B)) is the same as (!A || B). > - (length && length > 5) can be reduced to a single evaluation. > > Caught by: cppcheck > > Signed-off-by: Geyslan G. Bem > --- I guess you didn't get previous comment in time; let's split this per driver so different maintainers can pick their parts. -- balbi signature.asc Description: PGP signature
Re: [PATCH] usb: remove redundant conditions
2015-12-10 11:50 GMT-03:00 Felipe Balbi : > > Hi, > > "Geyslan G. Bem" writes: >> This patch removes redundant conditions. >> >> - (!A || (A && B)) is the same as (!A || B). >> - (length && length > 5) can be reduced to a single evaluation. >> >> Caught by: cppcheck >> >> Signed-off-by: Geyslan G. Bem > > Can you split this into one patch per driver, that way it's easier to > apply by different maintainers. Balbi, sure, I can. Tks. > > -- > balbi -- Regards, Geyslan G. Bem hackingbits.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] usb: remove redundant conditions
Hi, "Geyslan G. Bem" writes: > This patch removes redundant conditions. > > - (!A || (A && B)) is the same as (!A || B). > - (length && length > 5) can be reduced to a single evaluation. > > Caught by: cppcheck > > Signed-off-by: Geyslan G. Bem Can you split this into one patch per driver, that way it's easier to apply by different maintainers. -- balbi signature.asc Description: PGP signature
Re: [PATCH] usb: remove redundant conditions
2015-12-10 7:44 GMT-03:00 Johan Hovold : > On Wed, Dec 09, 2015 at 10:52:42PM -0300, Geyslan G. Bem wrote: >> This patch removes redundant conditions. >> >> - (!A || (A && B)) is the same as (!A || B). >> - (length && length > 5) can be reduced to a single evaluation. >> >> Caught by: cppcheck >> >> Signed-off-by: Geyslan G. Bem >> --- >> drivers/usb/gadget/udc/s3c-hsudc.c | 2 +- >> drivers/usb/host/fhci-sched.c | 2 +- >> drivers/usb/musb/musb_gadget.c | 5 ++--- >> drivers/usb/serial/io_edgeport.c | 35 ++- >> drivers/usb/serial/mos7840.c | 2 +- >> 5 files changed, 19 insertions(+), 27 deletions(-) > > Please split out (at least) the usb-serial changes into two patches. Ok, I'll send v2 later. > > Johan -- Regards, Geyslan G. Bem hackingbits.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] usb: remove redundant conditions
On Wed, Dec 09, 2015 at 10:52:42PM -0300, Geyslan G. Bem wrote: > This patch removes redundant conditions. > > - (!A || (A && B)) is the same as (!A || B). > - (length && length > 5) can be reduced to a single evaluation. > > Caught by: cppcheck > > Signed-off-by: Geyslan G. Bem > --- > drivers/usb/gadget/udc/s3c-hsudc.c | 2 +- > drivers/usb/host/fhci-sched.c | 2 +- > drivers/usb/musb/musb_gadget.c | 5 ++--- > drivers/usb/serial/io_edgeport.c | 35 ++- > drivers/usb/serial/mos7840.c | 2 +- > 5 files changed, 19 insertions(+), 27 deletions(-) Please split out (at least) the usb-serial changes into two patches. Johan -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/