Skip to contentSkip to conversation

util: Fix C++ invalid pointer conversion

PATCH Othman 1 participant 1 message Nov 10, 2020 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Othman

#1 lore raw

Apologies for the duplicate patches.

-Ossama

Quoted 32 lines

-----Original Message-----
From: Ossama Othman <[email protected]>
Sent: Friday, November 06, 2020 9:10 AM
To: ell(a)lists.01.org
Cc: Othman, Ossama <[email protected]>
Subject: [PATCH] util: Fix C++ invalid pointer conversion

Cast the void* arguments of l_secure_memcmp() to uint8_t* during assignment to the latter. C++ doesn't allow assignment of a void* to a pointer of another type without a cast. This allows <ell/util.h> to once again be used in C++ code.

---
 ell/util.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
ell/util.h +2 -3
index 0b3e1a8..f3dd57a 100644
@@ -351,8 +351,8 @@ const char *l_util_get_debugfs_path(void);
 static inline int l_secure_memcmp(const void *a, const void *b,
 					size_t size)
 {
-	const volatile uint8_t *aa = a;
-	const volatile uint8_t *bb = b;
+	const volatile uint8_t *aa = (const uint8_t *) a;
+	const volatile uint8_t *bb = (const uint8_t *) b;
 	int res = 0, diff, mask;
 
 	/*
--

2.25.1