[linux-nfc] [neard][PATCH v2 13/73] ndef: silence clang -Wcast-align warning
Krzysztof Kozlowski <[email protected]> Mon, 19 Jul 2021 13:07:19 +0200
| Newsgroups | org.01.lists.linux-nfc,dev.linux.lists.oe-linux-nfc |
|---|---|
| Message-ID | <[email protected]> |
Fix clang warning:
src/ndef.c:1196:28: error: cast from 'char *' to 'gunichar2 *' (aka 'unsigned short *') increases required alignment from 1 to 2 [-Werror,-Wcast-align]
g_str = g_utf16_to_utf8((gunichar2 *)txt, len, NULL,
^~~~~~~~~~~~~~~~
The case is safe as length of string is an even number.
Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
src/ndef.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/ndef.c b/src/ndef.c
index fdd44b467027..13e3356c2c4c 100644
--- a/src/ndef.c
+++ b/src/ndef.c
@@ -1198,7 +1198,8 @@ parse_text_payload(uint8_t *payload, uint32_t length)
txt = (char *)(payload + offset);
if (status)
- g_str = g_utf16_to_utf8((gunichar2 *)txt, len, NULL,
+ /* Cast to void to silence the 1-to-2 alignment warning */
+ g_str = g_utf16_to_utf8((gunichar2 *)(void *)txt, len, NULL,
NULL, NULL);
else
g_str = txt;
--
2.27.0
_______________________________________________
Linux-nfc mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s