On Sun, Oct 16, 2016 at 08:44:34AM -0600, Todd C. Miller wrote:

> On Sun, 16 Oct 2016 16:06:39 +0200, Otto Moerbeek wrote:
> 
> > On Sun, Oct 16, 2016 at 07:07:36AM -0600, Todd C. Miller wrote:
> > 
> > > It is effectively the same in this case but using the boolean OR
> > > is less surprising and may quiet over zealous compilers.
> > 
> > Are you sure? For example, in cvs/diff3.c
> > t2 is not always initialized with this change.
> 
> Good catch, that makes a difference.  I'm no longer sure changing
> this is worth it as the alternative is also ugly.

indeed, but I have a slight preference for your code,

        -Otto

> 
>  - todd
> 
> Index: usr.bin/cvs/diff3.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/cvs/diff3.c,v
> retrieving revision 1.61
> diff -u -p -u -r1.61 diff3.c
> --- usr.bin/cvs/diff3.c       16 Oct 2016 13:03:40 -0000      1.61
> +++ usr.bin/cvs/diff3.c       16 Oct 2016 14:43:49 -0000
> @@ -543,7 +543,12 @@ merge(size_t m1, size_t m2)
>       d1 = d13;
>       d2 = d23;
>       j = 0;
> -     while ((t1 = (d1 < d13 + m1)) | (t2 = (d2 < d23 + m2))) {
> +     for (;;) {
> +             t1 = (d1 < d13 + m1);
> +             t2 = (d2 < d23 + m2);
> +             if (!t1 && !t2)
> +                     break;
> +
>               if (debug) {
>                       printf("%d,%d=%d,%d %d,%d=%d,%d\n",
>                       d1->old.from, d1->old.to,
> Index: usr.bin/diff3/diff3prog.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/diff3/diff3prog.c,v
> retrieving revision 1.18
> diff -u -p -u -r1.18 diff3prog.c
> --- usr.bin/diff3/diff3prog.c 16 Oct 2016 13:03:40 -0000      1.18
> +++ usr.bin/diff3/diff3prog.c 16 Oct 2016 14:43:49 -0000
> @@ -301,7 +301,12 @@ merge(int m1, int m2)
>       d1 = d13;
>       d2 = d23;
>       j = 0;
> -     while ((t1 = (d1 < d13 + m1)) | (t2 = (d2 < d23 + m2))) {
> +     for (;;) {
> +             t1 = (d1 < d13 + m1);
> +             t2 = (d2 < d23 + m2);
> +             if (!t1 && !t2)
> +                     break;
> +
>               if (debug) {
>                       printf("%d,%d=%d,%d %d,%d=%d,%d\n",
>                       d1->old.from,d1->old.to,
> Index: usr.bin/rcs/diff3.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/rcs/diff3.c,v
> retrieving revision 1.39
> diff -u -p -u -r1.39 diff3.c
> --- usr.bin/rcs/diff3.c       26 Aug 2016 09:02:54 -0000      1.39
> +++ usr.bin/rcs/diff3.c       16 Oct 2016 14:43:49 -0000
> @@ -636,7 +636,12 @@ merge(size_t m1, size_t m2)
>       d1 = d13;
>       d2 = d23;
>       j = 0;
> -     while ((t1 = (d1 < d13 + m1)) | (t2 = (d2 < d23 + m2))) {
> +     for (;;) {
> +             t1 = (d1 < d13 + m1);
> +             t2 = (d2 < d23 + m2);
> +             if (!t1 && !t2)
> +                     break;
> +
>               if (debug) {
>                       printf("%d,%d=%d,%d %d,%d=%d,%d\n",
>                       d1->old.from, d1->old.to,

Reply via email to