shared/util: Add MIN/MAX implementations
PATCH 1/2 shared/util: Add MIN/MAX implementations
And remove it from src/sdpd-request.c to avoid a redefinition warning at compile-time.
--- src/sdpd-request.c | 2 -- src/shared/util.h | 6 ++++++ 2 files changed, 6 insertions(+), 2 deletions(-)
src/sdpd-request.c +0 -2
@@ -40,8 +40,6 @@ typedef struct {#define SDP_CONT_STATE_SIZE (sizeof(uint8_t) + sizeof(sdp_cont_state_t)) -#define MIN (x, y) ((x) < (y)) ? (x): (y) -typedef struct sdp_cont_info sdp_cont_info_t ;struct sdp_cont_info {
src/shared/util.h +6 -0
@@ -22,6 +22,12 @@#define ARRAY_SIZE (arr) (sizeof(arr) / sizeof((arr)[0]))#define BIT (n) (1 << (n)) +#undef MIN +#define MIN (a, b) ((a) > (b) ? (a) : (b)) + +#undef MAX +#define MAX (a, b) ((a) < (b) ? (a) : (b)) +#if __BYTE_ORDER == __LITTLE_ENDIAN#define le16_to_cpu (val) (val)#define le32_to_cpu (val) (val)
Signature · 1 line
2.53.0
PATCH 2/2 emulator: Remove compile-time header only glib dep
btvirt relied on a glib header macro to use MIN/MAX, but didn't link against it, meaning that it was dependent on other programs in the project using glib to compile correctly.
Remove the include and use our own implementation instead.
--- emulator/btdev.c | 2 -- 1 file changed, 2 deletions(-)
emulator/btdev.c +0 -2
@@ -25,8 +25,6 @@#include <fcntl.h> #include <unistd.h> -#include <glib.h> -#include "bluetooth/bluetooth.h" #include "bluetooth/hci.h"
Signature · 1 line
2.53.0
Luiz Augusto von Dentz
maintainerHi Bastien,
Quoted 26 lines · Bastien Nocera
And remove it from
src/sdpd-request.cto avoid a redefinition warning at compile-time.--- src/sdpd-request.c | 2 -- src/shared/util.h | 6 ++++++ 2 files changed, 6 insertions(+), 2 deletions(-)src/sdpd-request.c +0
-2@@ -40,8 +40,6 @@ typedef struct {#define SDP_CONT_STATE_SIZE (sizeof(uint8_t) + sizeof(sdp_cont_state_t)) -#define MIN (x, y) ((x) < (y)) ? (x): (y) -typedef struct sdp_cont_info sdp_cont_info_t ;struct sdp_cont_info {src/shared/util.h +0
-0
src/shared/util.h line 29
Quoted 8 lines
src/shared/util.h +5
-0@@ -22,6 +22,12 @@#define ARRAY_SIZE (arr) (sizeof(arr) / sizeof((arr)[0]))#define BIT (n) (1 << (n)) +#undef MIN +#define MIN (a, b) ((a) > (b) ? (a) : (b)) + +#undef MAX +#define MAX (a, b) ((a) < (b) ? (a) : (b))
This is causing many tests to fail with make check. It looks like the conditions are wrong, so MIN works as MAX and vice versa.
Quoted 7 lines
src/shared/util.h +0
-1#if __BYTE_ORDER == __LITTLE_ENDIAN#define le16_to_cpu (val) (val)#define le32_to_cpu (val) (val) --2.53.0
Signature · 1 line
Luiz Augusto von Dentz
Quoted 35 lines · Luiz Augusto von Dentz
Hi Bastien,
Quoted 31 lines · Bastien Nocera
And remove it from
src/sdpd-request.cto avoid a redefinition warning
at compile-time.
---
src/sdpd-request.c | 2 --
src/shared/util.h | 6 ++++++2 files changed, 6 insertions(+), 2 deletions(-)src/sdpd-request.c +0
-2@@ -40,8 +40,6 @@ typedef struct { #define SDP_CONT_STATE_SIZE (sizeof(uint8_t) + sizeof(sdp_cont_state_t)) -#define MIN (x, y) ((x) < (y)) ? (x): (y) - typedef struct sdp_cont_info sdp_cont_info_t;struct
sdp_cont_info{src/shared/util.h +0
-0@@ -22,6 +22,12 @@ #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) #define BIT(n) (1 << (n))
Quoted 8 lines
src/shared/util.h line 29
Quoted 5 lines
src/shared/util.h +5
-0+#undef MIN +#define MIN (a, b) ((a) > (b) ? (a) : (b)) + +#undef MAX +#define MAX (a, b) ((a) < (b) ? (a) : (b))This is causing many tests to fail with
make check. It looks like the conditions are wrong, so MIN works as MAX and vice versa.
Whoops, fixed.
Quoted 9 lines
Quoted 8 lines
src/shared/util.h +0
-1#if __BYTE_ORDER == __LITTLE_ENDIAN #define le16_to_cpu(val) (val) #define le32_to_cpu(val) (val) --2.53.0