[sane-devel] ambiguous post-increment in canon-sane.c

Johannes Meixner jsmeix at suse.de
Fri Dec 8 13:54:29 CET 2006


Hello,

In sane-backends-1.0.18 in backend/canon-sane.c there is an
ambiguous post-increment in the read_fs2710 function.

I get a compiler warning on PowerPC architecture regarding the
  *p++ = *(p + 1);
expression:
WARNING: Program uses invalid operation (likely same variable used twice
WARNING: and post/pre incremented in the same expression).
WARNING: (x = x++;) ... Needs to be split in two operations.

This should fix it (at least it makes the compiler happy ;-)
-----------------------------------------------------------------------
--- backend/canon-sane.c.orig   2006-12-08 12:05:25.000000000 +0100
+++ backend/canon-sane.c        2006-12-08 13:13:33.000000000 +0100
@@ -1797,7 +1797,8 @@ read_fs2710 (SANE_Handle handle, SANE_By
       for (p = buf; p < buf + nread; p++)
        {
          b = *p;
-         *p++ = *(p + 1);
+         *p = *(p + 1);
+         p++;
          *p = b;
        }
 #endif
-----------------------------------------------------------------------


Kind Regards
Johannes Meixner
-- 
SUSE LINUX Products GmbH, Maxfeldstrasse 5      Mail: jsmeix at suse.de
90409 Nuernberg, Germany                    WWW: http://www.suse.de/



More information about the sane-devel mailing list