From 5a35edcb9a0a44310d870dac240216a701b1e88d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 22 Dec 2008 22:33:03 +0000 Subject: [PATCH] use a single >>32 instead of "(value / 65536) / 65536", just make sure that the shift is done on a 64bit type --- src/misc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/misc.c b/src/misc.c index 22f8c12b..e1f00a01 100644 --- a/src/misc.c +++ b/src/misc.c @@ -51,8 +51,7 @@ libssh2_ntohu32(const unsigned char *buf) /* }}} */ /* {{{ libssh2_ntohu64 - * Note: Some 32-bit platforms have issues with bitops on long longs - * Work around this by doing expensive (but safer) arithmetic ops with optimization defying parentheses + * */ libssh2_uint64_t libssh2_ntohu64(const unsigned char *buf) @@ -85,7 +84,7 @@ libssh2_htonu32(unsigned char *buf, unsigned long value) void libssh2_htonu64(unsigned char *buf, libssh2_uint64_t value) { - unsigned long msl = (value / 65536) / 65536; + unsigned long msl = ((libssh2_uint64_t)value >> 32); buf[0] = (msl >> 24) & 0xFF; buf[1] = (msl >> 16) & 0xFF;