Commit af8124b
platform: fix -Wcast-align warnings in memory_buffer_alloc.c
Cast from 'unsigned char *' to 'memory_header *' through an
intermediate 'void *' to suppress -Wcast-align warnings.
Some Clang-based toolchains (e.g. MetaWare/ARC) enable -Wcast-align
as part of -Wall, unlike standard Clang on x86/ARM. Combined with
-Werror this turns the casts into fatal build errors.
The casts are already alignment-safe at runtime:
- In mbedtls_memory_buffer_alloc_init(), buf is explicitly aligned
to MBEDTLS_MEMORY_ALIGN_MULTIPLE before the cast.
- In buffer_alloc_calloc(), p is computed from an aligned base plus
aligned offsets (sizeof(memory_header) and len are both multiples
of MBEDTLS_MEMORY_ALIGN_MULTIPLE).
- In buffer_alloc_free(), p is derived from a previously aligned
allocation pointer minus the aligned header size.
Signed-off-by: Mohamed Moawad <moawad@synopsys.com>1 parent 67f5f79 commit af8124b
1 file changed
Lines changed: 9 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
294 | 294 | | |
295 | 295 | | |
296 | 296 | | |
297 | | - | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
298 | 300 | | |
299 | 301 | | |
300 | 302 | | |
| |||
375 | 377 | | |
376 | 378 | | |
377 | 379 | | |
378 | | - | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
379 | 383 | | |
380 | 384 | | |
381 | 385 | | |
| |||
586 | 590 | | |
587 | 591 | | |
588 | 592 | | |
589 | | - | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
590 | 596 | | |
591 | 597 | | |
592 | 598 | | |
| |||
0 commit comments