[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Wed, 6 May 2020 00:37:11 +0300
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Pavel Machek <pavel@...x.de>
Cc: Sasha Levin <sashal@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Stable <stable@...r.kernel.org>,
Dan Williams <dan.j.williams@...el.com>,
Nicolas Ferre <nicolas.ferre@...rochip.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Vinod Koul <vkoul@...nel.org>
Subject: Re: [PATCH 4.19 28/37] dmaengine: dmatest: Fix iteration non-stop logic
On Tue, May 5, 2020 at 6:57 PM Pavel Machek <pavel@...x.de> wrote:
> On Tue 2020-05-05 11:32:27, Sasha Levin wrote:
> > On Tue, May 05, 2020 at 05:05:37PM +0300, Andy Shevchenko wrote:
...
> > I'm a bit confused about this too. Maybe it's too early in the morning,
> > so I wrote this little test program:
> >
> > #include <stdio.h>
> > #include <stdlib.h>
> >
> > int main(int argc, char *argv[])
> > {
> > int a = atoi(argv[1]);
> > int b = atoi(argv[2]);
> >
> > if (!a && !b)
> > printf("A");
> > else
> > printf("B");
> >
> > if (!(a || b))
> > printf("A");
> > else
> > printf("B");
> >
> > printf("\n");
> >
> > return 0;
> > }
> >
> > Andy, could you give an example of two values which will print something
> > other than "AA" or "BB"?
>
> The issue here is "sideffects". Does b have to be evaluated at all?
> There is no difference between
>
> int a, b;
> if (a && b)
>
> and
>
> if ((!!a) & (!!b))
> .
>
> But there would be difference between
>
> int a, b;
> if (a && b++)
>
> and
> if ((!!a) & (!!(b++)))
>
> But:
>
> 1) && and || behave same way w.r.t. side effects
>
> 2) in the patch we are talking about b has no important side effects
I have to admit that this seems like a luck and the real issue somewhere else.
Definitely another test should be performed.
Thank you, Pavel, for pointing this out.
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists