mirror of
				https://github.com/libssh2/libssh2.git
				synced 2025-11-03 22:13:11 +03:00 
			
		
		
		
	use a single >>32 instead of "(value / 65536) / 65536", just make sure that
the shift is done on a 64bit type
This commit is contained in:
		@@ -51,8 +51,7 @@ libssh2_ntohu32(const unsigned char *buf)
 | 
				
			|||||||
/* }}} */
 | 
					/* }}} */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* {{{ libssh2_ntohu64
 | 
					/* {{{ 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_uint64_t
 | 
				
			||||||
libssh2_ntohu64(const unsigned char *buf)
 | 
					libssh2_ntohu64(const unsigned char *buf)
 | 
				
			||||||
@@ -85,7 +84,7 @@ libssh2_htonu32(unsigned char *buf, unsigned long value)
 | 
				
			|||||||
void
 | 
					void
 | 
				
			||||||
libssh2_htonu64(unsigned char *buf, libssh2_uint64_t value)
 | 
					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[0] = (msl >> 24) & 0xFF;
 | 
				
			||||||
    buf[1] = (msl >> 16) & 0xFF;
 | 
					    buf[1] = (msl >> 16) & 0xFF;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user