Commit 672e4dd
authored
Fix format specifier warnings on 32-bit architectures (i686) (#3791)
During compilation on i686 (32-bit) architecture with GCC 15, format
specifier warnings appear due to type size differences between 32-bit
and 64-bit platforms.
```
server.c: In function 'on_frame_recv_callback':
warning: format '%ld' expects argument of type 'long int', but argument 14
has type 'size_t' {aka 'unsigned int'} [-Wformat=]
638 | LM_DBG("h2 header [%d], %p %ld\n", frame->hd.type, frame->headers.nva, frame->headers.nvlen);
dm_impl.c: In function 'dm_avps2json':
warning: format '%ld' expects argument of type 'long int', but argument 15
has type 'int64_t' {aka 'long long int'} [-Wformat=]
484 | LM_DBG("%2d. got int64 AVP %s (%u), value: %ld\n", i, dm_avp.avp_name, h->avp_code, h->avp_value->i64);
warning: format '%lu' expects argument of type 'long unsigned int', but argument 15
has type 'uint64_t' {aka 'long long unsigned int'} [-Wformat=]
494 | LM_DBG("%2d. got uint64 AVP %s (%u), value: %lu\n", i, dm_avp.avp_name, h->avp_code, h->avp_value->u64);
```
Type sizes differ between 32-bit and 64-bit architectures:
**On x86_64 (64-bit):**
- `size_t` = `unsigned long` (8 bytes)
- `int64_t` = `long int` (8 bytes)
**On i686 (32-bit):**
- `size_t` = `unsigned int` (4 bytes)
- `int64_t` = `long long int` (8 bytes)
- `uint64_t` = `unsigned long long int` (8 bytes)
Use portable C99 format specifiers that work correctly on all
architectures:
- `%zu` for `size_t` (modules/http2d/server.c line 638)
- `%" PRId64` for `int64_t` (modules/aaa_diameter/dm_impl.c line 484)
- `%" PRIu64` for `uint64_t` (modules/aaa_diameter/dm_impl.c line 494)
Assisted-by: Claude (Anthropic) <https://claude.ai>
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>1 parent 73ef9dd commit 672e4dd
2 files changed
Lines changed: 4 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
485 | 486 | | |
486 | 487 | | |
487 | 488 | | |
488 | | - | |
| 489 | + | |
489 | 490 | | |
490 | 491 | | |
491 | 492 | | |
| |||
495 | 496 | | |
496 | 497 | | |
497 | 498 | | |
498 | | - | |
| 499 | + | |
499 | 500 | | |
500 | 501 | | |
501 | 502 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
635 | 635 | | |
636 | 636 | | |
637 | 637 | | |
638 | | - | |
| 638 | + | |
639 | 639 | | |
640 | 640 | | |
641 | 641 | | |
| |||
0 commit comments