From: Kern Sibbald Date: Fri, 11 Sep 2009 10:28:23 +0000 (+0200) Subject: Create bigendian() inline to simplify code X-Git-Tag: Release-7.0.0~2633^2~3 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f9c90506d82416c0161dd070a68b21d4bc4c5ee2;p=bacula%2Fbacula Create bigendian() inline to simplify code --- diff --git a/bacula/src/baconfig.h b/bacula/src/baconfig.h index 08623a7a92..0f3d111acb 100644 --- a/bacula/src/baconfig.h +++ b/bacula/src/baconfig.h @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2008 Free Software Foundation Europe e.V. + Copyright (C) 2000-2009 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -750,4 +750,7 @@ extern "C" int mknod ( const char *path, int mode, dev_t device ); #endif */ +/* Determine endiannes */ +static inline bool bigendian() { return htonl(1) == 1L; } + #endif /* _BACONFIG_H */ diff --git a/bacula/src/lib/md5.c b/bacula/src/lib/md5.c index 05f49acb9b..393404633c 100644 --- a/bacula/src/lib/md5.c +++ b/bacula/src/lib/md5.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2007 Free Software Foundation Europe e.V. + Copyright (C) 2000-2009 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -59,7 +59,7 @@ void byteReverse(unsigned char *buf, unsigned longs) { uint32_t t; - if (htonl(1) == 1L) { + if (bigendian()) { do { t = (uint32_t) ((unsigned) buf[3] << 8 | buf[2]) << 16 | ((unsigned) buf[1] << 8 | buf[0]); diff --git a/bacula/src/lib/serial.c b/bacula/src/lib/serial.c index 6612e657df..6b803f16db 100644 --- a/bacula/src/lib/serial.c +++ b/bacula/src/lib/serial.c @@ -92,7 +92,7 @@ void serial_uint32(uint8_t * * const ptr, const uint32_t v) void serial_int64(uint8_t * * const ptr, const int64_t v) { - if (htonl(1) == 1L) { + if (bigendian()) { memcpy(*ptr, &v, sizeof(int64_t)); } else { int i; @@ -112,7 +112,7 @@ void serial_int64(uint8_t * * const ptr, const int64_t v) void serial_uint64(uint8_t * * const ptr, const uint64_t v) { - if (htonl(1) == 1L) { + if (bigendian()) { memcpy(*ptr, &v, sizeof(uint64_t)); } else { int i; @@ -132,7 +132,7 @@ void serial_uint64(uint8_t * * const ptr, const uint64_t v) void serial_btime(uint8_t * * const ptr, const btime_t v) { - if (htonl(1) == 1L) { + if (bigendian()) { memcpy(*ptr, &v, sizeof(btime_t)); } else { int i; @@ -158,7 +158,7 @@ void serial_btime(uint8_t * * const ptr, const btime_t v) void serial_float64(uint8_t * * const ptr, const float64_t v) { - if (htonl(1) == 1L) { + if (bigendian()) { memcpy(*ptr, &v, sizeof(float64_t)); } else { int i; @@ -232,7 +232,7 @@ uint64_t unserial_uint64(uint8_t * * const ptr) { uint64_t v; - if (htonl(1) == 1L) { + if (bigendian()) { memcpy(&v, *ptr, sizeof(uint64_t)); } else { int i; @@ -255,7 +255,7 @@ btime_t unserial_btime(uint8_t * * const ptr) { btime_t v; - if (htonl(1) == 1L) { + if (bigendian()) { memcpy(&v, *ptr, sizeof(btime_t)); } else { int i; @@ -285,7 +285,7 @@ float64_t unserial_float64(uint8_t * * const ptr) { float64_t v; - if (htonl(1) == 1L) { + if (bigendian()) { memcpy(&v, *ptr, sizeof(float64_t)); } else { int i;