diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2022-05-02 15:23:37 +0100 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2022-05-02 15:38:48 +0100 |
commit | 6b8c94a6e3094ab75fcfe319fa2bc100f4e329ec (patch) | |
tree | 6c6ee0a2e7f77084f721ed33ff5b8856ec43fb61 /apps/tagcache.c | |
parent | 366f00a3d3dc6517e7dcb1bbebb887c4f795320b (diff) | |
download | rockbox-6b8c94a6e3094ab75fcfe319fa2bc100f4e329ec.tar.gz rockbox-6b8c94a6e3094ab75fcfe319fa2bc100f4e329ec.zip |
Fix some non-portable alignment values
UBSan reports an avalanche of unaligned pointer bugs stemming from
hardcoded 4-byte alignments used in certain places. Use sizeof(long)
instead to align to the machine word size.
Change-Id: I28e505212462c5268afa24e95df3a103ac3e2213
Diffstat (limited to 'apps/tagcache.c')
-rw-r--r-- | apps/tagcache.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/apps/tagcache.c b/apps/tagcache.c index c18380854e..b6d15e7a1f 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c | |||
@@ -2258,17 +2258,12 @@ static int tempbuf_sort(int fd) | |||
2258 | while (idlist->next != NULL) | 2258 | while (idlist->next != NULL) |
2259 | idlist = idlist->next; | 2259 | idlist = idlist->next; |
2260 | 2260 | ||
2261 | ALIGN_BUFFER(tempbuf_pos, tempbuf_left, alignof(struct tempbuf_id_list)); | ||
2261 | tempbuf_left -= sizeof(struct tempbuf_id_list); | 2262 | tempbuf_left -= sizeof(struct tempbuf_id_list); |
2262 | if (tempbuf_left - 4 < 0) | 2263 | if (tempbuf_left < 0) |
2263 | return -1; | 2264 | return -1; |
2264 | 2265 | ||
2265 | idlist->next = (struct tempbuf_id_list *)&tempbuf[tempbuf_pos]; | 2266 | idlist->next = (struct tempbuf_id_list *)&tempbuf[tempbuf_pos]; |
2266 | if (tempbuf_pos & 0x03) | ||
2267 | { | ||
2268 | tempbuf_pos = (tempbuf_pos & ~0x03) + 0x04; | ||
2269 | tempbuf_left -= 3; | ||
2270 | idlist->next = (struct tempbuf_id_list *)&tempbuf[tempbuf_pos]; | ||
2271 | } | ||
2272 | tempbuf_pos += sizeof(struct tempbuf_id_list); | 2267 | tempbuf_pos += sizeof(struct tempbuf_id_list); |
2273 | 2268 | ||
2274 | idlist = idlist->next; | 2269 | idlist = idlist->next; |