Mailing List Archive

[Bug 1192] warning: comparison between signed and unsigned
http://bugzilla.mindrot.org/show_bug.cgi?id=1192

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@mindrot.org
ReportedBy: carenas@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.




------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

_______________________________________________
openssh-bugs mailing list
openssh-bugs@mindrot.org
http://www.mindrot.org/mailman/listinfo/openssh-bugs
[Bug 1192] warning: comparison between signed and unsigned [ In reply to ]
http://bugzilla.mindrot.org/show_bug.cgi?id=1192





------- Comment #1 from carenas@sajinet.com.pe 2006-05-22 13:36 -------
Created an attachment (id=1142)
--> (http://bugzilla.mindrot.org/attachment.cgi?id=1142&action=view)
reverting first snippet for scp.c version 1.122

compiling without warnings and validated for OpenBSD/amd64,
OpenBSD/i386 and Gentoo Linux 2006.0/x86_64




------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

_______________________________________________
openssh-bugs mailing list
openssh-bugs@mindrot.org
http://www.mindrot.org/mailman/listinfo/openssh-bugs
[Bug 1192] warning: comparison between signed and unsigned [ In reply to ]
http://bugzilla.mindrot.org/show_bug.cgi?id=1192





------- Comment #2 from dtucker@zip.com.au 2006-05-22 13:55 -------
(From update of attachment 1142)
>- size_t result;
>+ off_t i, amt, result, statbytes;

I don't think that's the right way forward since later there is:

result = atomicio(read, fd, bp->buf, amt)

and atomicio now returns a size_t.

Instead, I think we should be changing the progressmeter interface to
u_int64_t from off_t (since ultimately, the size it operates on is
fixed at 64 bits by the packet format of the sftp spec). This would
change "amt" and also fix the warning.

There's an old bug for this (#842) but I suspect the diff will need
some tweaking.




------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

_______________________________________________
openssh-bugs mailing list
openssh-bugs@mindrot.org
http://www.mindrot.org/mailman/listinfo/openssh-bugs
[Bug 1192] warning: comparison between signed and unsigned [ In reply to ]
http://bugzilla.mindrot.org/show_bug.cgi?id=1192





------- Comment #3 from dtucker@zip.com.au 2006-05-22 14:01 -------
Err, ignore comment #2. It's a similar but unrelated issue (but in the
same chunk of code).




------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

_______________________________________________
openssh-bugs mailing list
openssh-bugs@mindrot.org
http://www.mindrot.org/mailman/listinfo/openssh-bugs