diff options
author | Hans Ulrich Niedermann <hun@n-dimensional.de> | 2010-01-29 12:08:52 +0100 |
---|---|---|
committer | Daniel Drake <dan@reactivated.net> | 2010-05-13 19:01:01 -0300 |
commit | 7ba92cff94bbba19284749c614c26141d3023f37 (patch) | |
tree | dc7c69dbe0ba9fc27d83e0ea4fc3d35ab6b2fc8b /libusb/libusb.h | |
parent | 3473ac6c6fab32202d02d87679ebdb24e7d2df98 (diff) | |
download | libusb-7ba92cff94bbba19284749c614c26141d3023f37.tar.gz |
libusb_cpu_to_le16: macro->static inline function
The libusb_cpu_to_le16 macro was a ({ ... }) expression, which
generates the following compiler warning every time it is used,
(and that is several times for every #include <libusb.h>):
libusb.h:880: warning: ISO C forbids braced-groups within expressions
With this patch, #include <libusb.h> stops generating compiler
warnings on gcc 4.4.
As libusb.h heavily relies on the use of static inline functions
those can be relied on to work properly, and there should not be
any significant difference in the code the compiler generates.
Diffstat (limited to 'libusb/libusb.h')
-rw-r--r-- | libusb/libusb.h | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/libusb/libusb.h b/libusb/libusb.h index f094a93..cfc9e92 100644 --- a/libusb/libusb.h +++ b/libusb/libusb.h @@ -39,16 +39,16 @@ extern "C" { * \param x the host-endian value to convert * \returns the value in little-endian byte order */ -#define libusb_cpu_to_le16(x) ({ \ - union { \ - uint8_t b8[2]; \ - uint16_t b16; \ - } _tmp; \ - uint16_t _tmp2 = (uint16_t)(x); \ - _tmp.b8[1] = _tmp2 >> 8; \ - _tmp.b8[0] = _tmp2 & 0xff; \ - _tmp.b16; \ -}) +static inline uint16_t libusb_cpu_to_le16(const uint16_t x) +{ + union { + uint8_t b8[2]; + uint16_t b16; + } _tmp; + _tmp.b8[1] = x >> 8; + _tmp.b8[0] = x & 0xff; + return _tmp.b16; +} /** \def libusb_le16_to_cpu * \ingroup misc |