diff mbox series

[BlueZ,v1,1/4] util: Add UTIL_IOV_INIT

Message ID 20240129212036.163298-1-luiz.dentz@gmail.com (mailing list archive)
State Accepted
Commit 8e472230055d8d1809d7dadf00919c2f81043ab7
Headers show
Series [BlueZ,v1,1/4] util: Add UTIL_IOV_INIT | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch success CheckPatch PASS
tedd_an/GitLint success Gitlint PASS
tedd_an/BuildEll success Build ELL PASS
tedd_an/BluezMake success Bluez Make PASS
tedd_an/MakeCheck success Bluez Make Check PASS
tedd_an/MakeDistcheck success Make Distcheck PASS
tedd_an/CheckValgrind success Check Valgrind PASS
tedd_an/CheckSmatch success CheckSparse PASS
tedd_an/bluezmakeextell success Make External ELL PASS
tedd_an/IncrementalBuild success Incremental Build PASS
tedd_an/ScanBuild warning ScanBuild: In file included from tools/mesh-gatt/crypto.c:32: ./src/shared/util.h:236:9: warning: 1st function call argument is an uninitialized value return be32_to_cpu(get_unaligned((const uint32_t *) ptr)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ./src/shared/util.h:33:26: note: expanded from macro 'be32_to_cpu' #define be32_to_cpu(val) bswap_32(val) ^~~~~~~~~~~~~ /usr/include/byteswap.h:34:21: note: expanded from macro 'bswap_32' #define bswap_32(x) __bswap_32 (x) ^~~~~~~~~~~~~~ In file included from tools/mesh-gatt/crypto.c:32: ./src/shared/util.h:246:9: warning: 1st function call argument is an uninitialized value return be64_to_cpu(get_unaligned((const uint64_t *) ptr)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ./src/shared/util.h:34:26: note: expanded from macro 'be64_to_cpu' #define be64_to_cpu(val) bswap_64(val) ^~~~~~~~~~~~~ /usr/include/byteswap.h:37:21: note: expanded from macro 'bswap_64' #define bswap_64(x) __bswap_64 (x) ^~~~~~~~~~~~~~ 2 warnings generated.

Commit Message

Luiz Augusto von Dentz Jan. 29, 2024, 9:20 p.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This adds UTIL_IOV_INIT macro which can be used to init elements of
struct iovec with a byte array.
---
 src/shared/lc3.h  | 24 ++++++++----------------
 src/shared/util.h |  8 ++++++++
 2 files changed, 16 insertions(+), 16 deletions(-)

Comments

bluez.test.bot@gmail.com Jan. 29, 2024, 11:04 p.m. UTC | #1
This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=821071

---Test result---

Test Summary:
CheckPatch                    PASS      6.40 seconds
GitLint                       PASS      1.31 seconds
BuildEll                      PASS      23.90 seconds
BluezMake                     PASS      705.38 seconds
MakeCheck                     PASS      11.31 seconds
MakeDistcheck                 PASS      166.06 seconds
CheckValgrind                 PASS      226.45 seconds
CheckSmatch                   PASS      332.44 seconds
bluezmakeextell               PASS      107.91 seconds
IncrementalBuild              PASS      2677.89 seconds
ScanBuild                     WARNING   963.25 seconds

Details
##############################
Test: ScanBuild - WARNING
Desc: Run Scan Build
Output:
In file included from tools/mesh-gatt/crypto.c:32:
./src/shared/util.h:236:9: warning: 1st function call argument is an uninitialized value
        return be32_to_cpu(get_unaligned((const uint32_t *) ptr));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./src/shared/util.h:33:26: note: expanded from macro 'be32_to_cpu'
#define be32_to_cpu(val) bswap_32(val)
                         ^~~~~~~~~~~~~
/usr/include/byteswap.h:34:21: note: expanded from macro 'bswap_32'
#define bswap_32(x) __bswap_32 (x)
                    ^~~~~~~~~~~~~~
In file included from tools/mesh-gatt/crypto.c:32:
./src/shared/util.h:246:9: warning: 1st function call argument is an uninitialized value
        return be64_to_cpu(get_unaligned((const uint64_t *) ptr));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./src/shared/util.h:34:26: note: expanded from macro 'be64_to_cpu'
#define be64_to_cpu(val) bswap_64(val)
                         ^~~~~~~~~~~~~
/usr/include/byteswap.h:37:21: note: expanded from macro 'bswap_64'
#define bswap_64(x) __bswap_64 (x)
                    ^~~~~~~~~~~~~~
2 warnings generated.



---
Regards,
Linux Bluetooth
patchwork-bot+bluetooth@kernel.org Jan. 30, 2024, 6:40 p.m. UTC | #2
Hello:

This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Mon, 29 Jan 2024 16:20:33 -0500 you wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> This adds UTIL_IOV_INIT macro which can be used to init elements of
> struct iovec with a byte array.
> ---
>  src/shared/lc3.h  | 24 ++++++++----------------
>  src/shared/util.h |  8 ++++++++
>  2 files changed, 16 insertions(+), 16 deletions(-)

Here is the summary with links:
  - [BlueZ,v1,1/4] util: Add UTIL_IOV_INIT
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=8e472230055d
  - [BlueZ,v1,2/4] client/player: Add metadata support to struct capabilities
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=423fcc4c4ce8
  - [BlueZ,v1,3/4] client/player: Use util_iov_dup/util_iov_free whenever possible
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=2faff4cadfe3
  - [BlueZ,v1,4/4] client/player: Add .name field to struct capabilities
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=74e49f67e940

You are awesome, thank you!
diff mbox series

Patch

diff --git a/src/shared/lc3.h b/src/shared/lc3.h
index e6b043699bc1..3a8c6f7b5841 100644
--- a/src/shared/lc3.h
+++ b/src/shared/lc3.h
@@ -7,14 +7,6 @@ 
  *
  */
 
-#define data(args...) ((const unsigned char[]) { args })
-
-#define LC3_IOV(args...) \
-	{ \
-		.iov_base = (void *)data(args), \
-		.iov_len = sizeof(data(args)), \
-	}
-
 #define LC3_ID			0x06
 
 #define LC3_BASE		0x01
@@ -53,11 +45,11 @@ 
 #define LC3_FRAME_COUNT		(LC3_BASE + 4)
 
 #define LC3_CAPABILITIES(_freq, _duration, _chan_count, _len_min, _len_max) \
-	LC3_IOV(0x02, LC3_FREQ, _freq, _freq >> 8, \
-		0x02, LC3_DURATION, _duration, \
-		0x02, LC3_CHAN_COUNT, _chan_count, \
-		0x05, LC3_FRAME_LEN, _len_min, _len_min >> 8, \
-		_len_max, _len_max >> 8)
+	UTIL_IOV_INIT(0x02, LC3_FREQ, _freq, _freq >> 8, \
+			0x02, LC3_DURATION, _duration, \
+			0x02, LC3_CHAN_COUNT, _chan_count, \
+			0x05, LC3_FRAME_LEN, _len_min, _len_min >> 8, \
+			_len_max, _len_max >> 8)
 
 #define LC3_CONFIG_BASE		0x01
 
@@ -80,9 +72,9 @@ 
 #define LC3_CONFIG_FRAME_LEN	(LC3_CONFIG_BASE + 3)
 
 #define LC3_CONFIG(_freq, _duration, _len) \
-	LC3_IOV(0x02, LC3_CONFIG_FREQ, _freq, \
-		0x02, LC3_CONFIG_DURATION, _duration, \
-		0x03, LC3_CONFIG_FRAME_LEN, _len, _len >> 8)
+	UTIL_IOV_INIT(0x02, LC3_CONFIG_FREQ, _freq, \
+			0x02, LC3_CONFIG_DURATION, _duration, \
+			0x03, LC3_CONFIG_FRAME_LEN, _len, _len >> 8)
 
 #define LC3_CONFIG_8(_duration, _len) \
 	LC3_CONFIG(LC3_CONFIG_FREQ_8KHZ, _duration, _len)
diff --git a/src/shared/util.h b/src/shared/util.h
index 596663b8519c..6322b13d612a 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -151,6 +151,14 @@  ssize_t util_getrandom(void *buf, size_t buflen, unsigned int flags);
 uint8_t util_get_uid(uint64_t *bitmap, uint8_t max);
 void util_clear_uid(uint64_t *bitmap, uint8_t id);
 
+#define util_data(args...) ((const unsigned char[]) { args })
+
+#define UTIL_IOV_INIT(args...) \
+{ \
+	.iov_base = (void *)util_data(args), \
+	.iov_len = sizeof(util_data(args)), \
+}
+
 struct iovec *util_iov_dup(const struct iovec *iov, size_t cnt);
 int util_iov_memcmp(const struct iovec *iov1, const struct iovec *iov2);
 void util_iov_memcpy(struct iovec *iov, void *src, size_t len);