All of lore.kernel.org
 help / color / mirror / Atom feed
* [BlueZ v3 0/6] Add helper for "cleanup" variable attribute
@ 2026-05-11 13:18 Bastien Nocera
  2026-05-11 13:18 ` [BlueZ v3 1/6] all: Remove more unneeded MIN/MAX macro definition Bastien Nocera
                   ` (6 more replies)
  0 siblings, 7 replies; 16+ messages in thread
From: Bastien Nocera @ 2026-05-11 13:18 UTC (permalink / raw)
  To: linux-bluetooth

As discussed in:
https://lore.kernel.org/linux-bluetooth/ed949f2550f79a4bef19bd482bf8b069ad5b7e0c.camel@hadess.net/

Implement a cleanup helper.

The MIN/MAX fix is here because it touches the same hunk in src/main.c
as the other patches. Feel free to pick it up straight away while the
rest is discussed.

Changes since v2:
- Add macros to declare cleanup for specific types
- Add file descriptor cleanup
- Add "steal" helpers for fd and pointers
- Add unit tests

Changes since v1:
- Fixed checkpatch warnings

Bastien Nocera (6):
  all: Remove more unneeded MIN/MAX macro definition
  shared/util: Add helper for "cleanup" variable attribute
  doc: Recommend using _cleanup_ and friends
  main: Use _cleanup_() to simplify configuration parsing
  client: Use _cleanup_fd_ to simplify urandom access
  btattach: Use _cleanup_fd_ to simplify error paths

 client/mgmt.c                 |   5 +-
 doc/maintainer-guidelines.rst |   3 +
 lib/bluetooth/hci.c           |   4 --
 src/main.c                    | 103 ++++++++++------------------------
 src/shared/gatt-server.c      |   8 ---
 src/shared/util.h             |  40 +++++++++++++
 tools/btattach.c              |  18 ++----
 unit/test-util.c              |  65 +++++++++++++++++++++
 8 files changed, 145 insertions(+), 101 deletions(-)

-- 
2.54.0


^ permalink raw reply	[flat|nested] 16+ messages in thread
* [BlueZ v2 1/5] all: Remove more unneeded MIN/MAX macro definition
@ 2026-05-06 14:30 Bastien Nocera
  2026-05-06 21:28 ` Add helper for "cleanup" variable attribute bluez.test.bot
  0 siblings, 1 reply; 16+ messages in thread
From: Bastien Nocera @ 2026-05-06 14:30 UTC (permalink / raw)
  To: linux-bluetooth

---
 lib/bluetooth/hci.c      | 4 ----
 src/main.c               | 4 ----
 src/shared/gatt-server.c | 8 --------
 3 files changed, 16 deletions(-)

diff --git a/lib/bluetooth/hci.c b/lib/bluetooth/hci.c
index 44eea054b0ac..f50a30c610be 100644
--- a/lib/bluetooth/hci.c
+++ b/lib/bluetooth/hci.c
@@ -33,10 +33,6 @@
 #include "hci.h"
 #include "hci_lib.h"
 
-#ifndef MIN
-#define MIN(x, y) ((x) < (y) ? (x) : (y))
-#endif
-
 typedef struct {
 	char *str;
 	unsigned int val;
diff --git a/src/main.c b/src/main.c
index 9a3d2da25d4d..8aa19a3e3346 100644
--- a/src/main.c
+++ b/src/main.c
@@ -205,10 +205,6 @@ static const struct group_table {
 	{ }
 };
 
-#ifndef MIN
-#define MIN(x, y) ((x) < (y) ? (x) : (y))
-#endif
-
 static int8_t check_sirk_alpha_numeric(char *str)
 {
 	int8_t val = 0;
diff --git a/src/shared/gatt-server.c b/src/shared/gatt-server.c
index 6273899965c0..709a8f94bb6a 100644
--- a/src/shared/gatt-server.c
+++ b/src/shared/gatt-server.c
@@ -26,14 +26,6 @@
 #include "src/shared/util.h"
 #include "src/shared/timeout.h"
 
-#ifndef MAX
-#define MAX(a, b) ((a) > (b) ? (a) : (b))
-#endif
-
-#ifndef MIN
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
-#endif
-
 /*
  * TODO: This is an arbitrary limit. Come up with something reasonable or
  * perhaps an API to set this value if there is a use case for it.
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread
* [BlueZ 1/5] all: Remove more unneeded MIN/MAX macro definition
@ 2026-05-06  9:14 Bastien Nocera
  2026-05-06 11:15 ` Add helper for "cleanup" variable attribute bluez.test.bot
  0 siblings, 1 reply; 16+ messages in thread
From: Bastien Nocera @ 2026-05-06  9:14 UTC (permalink / raw)
  To: linux-bluetooth

---
 lib/bluetooth/hci.c      | 4 ----
 src/main.c               | 4 ----
 src/shared/gatt-server.c | 8 --------
 3 files changed, 16 deletions(-)

diff --git a/lib/bluetooth/hci.c b/lib/bluetooth/hci.c
index 44eea054b0ac..f50a30c610be 100644
--- a/lib/bluetooth/hci.c
+++ b/lib/bluetooth/hci.c
@@ -33,10 +33,6 @@
 #include "hci.h"
 #include "hci_lib.h"
 
-#ifndef MIN
-#define MIN(x, y) ((x) < (y) ? (x) : (y))
-#endif
-
 typedef struct {
 	char *str;
 	unsigned int val;
diff --git a/src/main.c b/src/main.c
index 9a3d2da25d4d..8aa19a3e3346 100644
--- a/src/main.c
+++ b/src/main.c
@@ -205,10 +205,6 @@ static const struct group_table {
 	{ }
 };
 
-#ifndef MIN
-#define MIN(x, y) ((x) < (y) ? (x) : (y))
-#endif
-
 static int8_t check_sirk_alpha_numeric(char *str)
 {
 	int8_t val = 0;
diff --git a/src/shared/gatt-server.c b/src/shared/gatt-server.c
index 6273899965c0..709a8f94bb6a 100644
--- a/src/shared/gatt-server.c
+++ b/src/shared/gatt-server.c
@@ -26,14 +26,6 @@
 #include "src/shared/util.h"
 #include "src/shared/timeout.h"
 
-#ifndef MAX
-#define MAX(a, b) ((a) > (b) ? (a) : (b))
-#endif
-
-#ifndef MIN
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
-#endif
-
 /*
  * TODO: This is an arbitrary limit. Come up with something reasonable or
  * perhaps an API to set this value if there is a use case for it.
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2026-06-09 14:23 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-11 13:18 [BlueZ v3 0/6] Add helper for "cleanup" variable attribute Bastien Nocera
2026-05-11 13:18 ` [BlueZ v3 1/6] all: Remove more unneeded MIN/MAX macro definition Bastien Nocera
2026-05-11 17:27   ` Add helper for "cleanup" variable attribute bluez.test.bot
2026-05-11 13:18 ` [BlueZ v3 2/6] shared/util: " Bastien Nocera
2026-05-11 13:18 ` [BlueZ v3 3/6] doc: Recommend using _cleanup_ and friends Bastien Nocera
2026-05-11 13:18 ` [BlueZ v3 4/6] main: Use _cleanup_() to simplify configuration parsing Bastien Nocera
2026-05-11 13:35   ` [BlueZ,v3,4/6] " bluez.test.bot
2026-05-11 13:18 ` [BlueZ v3 5/6] client: Use _cleanup_fd_ to simplify urandom access Bastien Nocera
2026-05-11 13:18 ` [BlueZ v3 6/6] btattach: Use _cleanup_fd_ to simplify error paths Bastien Nocera
2026-05-12 19:20 ` [BlueZ v3 0/6] Add helper for "cleanup" variable attribute patchwork-bot+bluetooth
2026-05-12 19:38   ` Luiz Augusto von Dentz
2026-05-12 20:12     ` Bastien Nocera
2026-05-12 20:40     ` Pauli Virtanen
2026-06-09 13:58       ` Bastien Nocera
  -- strict thread matches above, loose matches on Subject: below --
2026-05-06 14:30 [BlueZ v2 1/5] all: Remove more unneeded MIN/MAX macro definition Bastien Nocera
2026-05-06 21:28 ` Add helper for "cleanup" variable attribute bluez.test.bot
2026-05-06  9:14 [BlueZ 1/5] all: Remove more unneeded MIN/MAX macro definition Bastien Nocera
2026-05-06 11:15 ` Add helper for "cleanup" variable attribute bluez.test.bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.