Repository navigation
Conversation
|
augment review |
🤖 Augment PR SummarySummary: This PR fixes printf-format mismatches where libcurl logs/infos print Changes:
Technical Notes: Addresses 🤖 Was this summary useful? React with 👍 or 👎 |
There was a problem hiding this comment.
Pull request overview
This PR fixes printf format specifier warnings when compiling with MS-DOS DJGPP gcc 12.2.0, where uint32_t is long unsigned int rather than unsigned int. The fix replaces hardcoded %u and %d format specifiers with the portable PRIu32 macro for all uint32_t variables, and adds support for PRIu32 by including <inttypes.h> (with a manual definition for VS2010/VS2012 which lack this header).
Key Changes
- Added
<inttypes.h>include tolib/curl_setup.hwith manualPRIu32definition for VS2010/VS2012 - Replaced
%uand%dformat specifiers with%" PRIu32for alluint32_tvariables across multiple files - Fixed one incorrect
%dtoPRIu32conversion (should have been unsigned)
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| lib/curl_setup.h | Added <inttypes.h> include with VS2010/VS2012 fallback definition for PRIu32 |
| lib/url.c | Updated format specifiers for conn->attached_xfers (uint32_t) |
| lib/multi_ntfy.c | Updated format specifiers for e->type, e->mid, and data->mid (all uint32_t), also fixed signedness issue |
| lib/multi_ev.c | Updated format specifiers for various uint32_t counters and transfer IDs |
| lib/multi.c | Updated format specifiers for mid, master_mid, attached_xfers, and various uint32_t table/set counts |
| lib/conncache.c | Updated format specifier for conn->attached_xfers (uint32_t) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
uint32_t typesuint32_t types, restore HAVE_STDINT_H
uint32_t types, restore HAVE_STDINT_Huint32_t types, restore HAVE_INTTYPES_H
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #if defined(HAVE_STDINT_H) || defined(USE_WOLFSSL) | ||
| #include <stdint.h> | ||
| #endif | ||
| #ifdef HAVE_INTTYPES_H | ||
| #include <inttypes.h> | ||
| #else | ||
| #define PRIu32 "u" | ||
| #endif | ||
|
|
||
| #include <limits.h> | ||
|
|
There was a problem hiding this comment.
The fallback definition assumes uint32_t is the same type as unsigned int, which may not be true on all platforms. On systems where uint32_t is unsigned long (such as systems with 16-bit int), this will cause printf format mismatches. Consider using a platform-specific fallback that checks SIZEOF_INT or use "lu" for platforms where int is not 32 bits.
| #if defined(HAVE_STDINT_H) || defined(USE_WOLFSSL) | |
| #include <stdint.h> | |
| #endif | |
| #ifdef HAVE_INTTYPES_H | |
| #include <inttypes.h> | |
| #else | |
| #define PRIu32 "u" | |
| #endif | |
| #include <limits.h> | |
| #include <limits.h> | |
| #if defined(HAVE_STDINT_H) || defined(USE_WOLFSSL) | |
| #include <stdint.h> | |
| #endif | |
| #ifdef HAVE_INTTYPES_H | |
| #include <inttypes.h> | |
| #else | |
| /* Fallback definition of PRIu32 when <inttypes.h> is unavailable. | |
| Select the correct format specifier based on the width of the | |
| standard unsigned integer types. */ | |
| # if defined(UINT_MAX) && (UINT_MAX == 0xFFFFFFFFU) | |
| # define PRIu32 "u" | |
| # elif defined(ULONG_MAX) && (ULONG_MAX == 0xFFFFFFFFUL) | |
| # define PRIu32 "lu" | |
| # else | |
| /* Conservative fallback: assume 32-bit type maps to unsigned long. */ | |
| # define PRIu32 "lu" | |
| # endif | |
| #endif |
There was a problem hiding this comment.
Sure, but, I'd rather leave that to someone else, who can double-check this.
Shorter version of the above:
#if UINT_MAX == 0xFFFFFFFFU /* or possibly compare to `ULONG_MAX`? */
#define PRIu32 "u"
#else
#define PRIu32 "lu"
#endifFTR on DJGPP UINT_MAX and ULONG_MAX are both 4294967295U[L], and PRIu32 is lu, not matching the logic above.
uint32_t types, restore HAVE_INTTYPES_Huint32_t types
Follow-up to e70436a curl#20200 Follow-up to 4701a6d curl#19695
In `!ssl` variant. It's useful to catch `uint32_t` mismatches with `unsigned int` or its printf mask. Also add Renovate version bump rule. It takes about 1m (autotools) + 30s (cmake) in CI. Bug: #20199 (comment) Follow-up to 8881a52 #20210 Follow-up to e70436a #20200 Follow-up to 0630e66 #18338 Closes #20204
Also adjust a printf mask for signedness.
Fixing with MS-DOS DJGPP gcc 12.2.0:
Bug: #20199 (comment)
Follow-up to 4c9e4e9 #20208
inttypes.hagain #20208