[sane-devel] C undefined operations in sane-backends-1.0.7-beta1

Jaeger, Gerhard G. Jaeger" <gjaeger@sysgo.de
Fri, 25 Jan 2002 12:27:03 +0100


Hi there, 

let's have a look at the warnings from the Plustek backend.
The lines that produce the problem include the following statement:

_SWAP(x,y)	(x)^=(y)^=(x)^=(y)

So what? Where's the problem here?

If you take the following expamle, only _SWAP_1 produces the warning,
but does in fact the same as _SWAP_2. I assume, that _SWAP_2 can 
be replaced by _SWAP_1 without any problems...

#include <stdio.h>

#define _SWAP_1(x,y)    ((x)^=(y)^=(x)^=(y))
#define _SWAP_2(x,y) {(x)^=(y); (y)^=(x); (x)^=(y);}

int main( void )
{
        int x,y;

        x = 0xABCDEF01;
        y = 0xFFFFFFFF;
        printf("1. x=0x%08x, y=0x%08x\n", x, y);

        _SWAP_1(x,y);
        printf("2. x=0x%08x, y=0x%08x\n", x, y);

        x = 0xABCDEF01;
        y = 0xFFFFFFFF;
        printf("1. x=0x%08x, y=0x%08x\n", x, y);

        _SWAP_2(x,y);
        printf("2. x=0x%08x, y=0x%08x\n", x, y);

        return 0;
}


I could change this, but why? 
Maybe there's somebody out there to enlighten me!

Gerhard


On Mittwoch, 23. Januar 2002 10:55, Tim Waugh wrote:
[SNIP]
> I get these warnings when compiling sane-backends-1.0.7-beta1.  They
> are for things like:
>
> 	bit = ++bit % 8;
>
> which are indeed undefined.
> plustek-usbshading.c:1056: warning: operation on `wR' may be undefined
> plustek-usbshading.c:1059: warning: operation on `wG' may be undefined
> plustek-usbshading.c:1062: warning: operation on `wB' may be undefined
> plustek-usbshading.c:1090: warning: operation on `wR' may be undefined
> plustek-usbshading.c:1092: warning: operation on `wG' may be undefined
> plustek-usbshading.c:1094: warning: operation on `wB' may be undefined
> plustek-usbshading.c:1168: warning: operation on `wV' may be undefined
> plustek-usbshading.c:1186: warning: operation on `wV' may be undefined