[Bug 1192] warning: comparison between signed and unsigned

bugzilla-daemon at mindrot.org
Mon, 22 May 2006 03:31:50 -0000

Summary: warning: comparison between signed and unsigned
           Product: Portable OpenSSH
           Version: 4.3p2
          Platform: amd64
               URL: http://www.openbsd.org/cgi-

bin/cvsweb/src/usr.bin/ssh/scp.c.diff?r1=1.121&r2=1.122&
                    f=h
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: scp
        AssignedTo: bitbucket at mindrot.org
        ReportedBy: carenas at sajinet.com.pe


introduced as part of scp version 1.122 (OpenBSD 3.8/OpenSSH 4.2), and
which results in the following warning when compiled with
-Wsign-compare :

scp.c: In function `source':
scp.c:632: warning: comparison between signed and unsigned
scp.c:639: warning: comparison between signed and unsigned

the problem is that off_t is defined signed (long long for OpenBSD and
long int for linux/amd64), while size_t is unsigned (unsigned long for
OpenBSD and long unsigned int for Linux).

for LPI32 architectures (like i386), the expansion from unsigned long
(4 bytes) to long long (8 bytes) is safe, but no so for LP64
architectures (like amd64) where "long long" and "unsigned
long" are 8
bytes wide.