Skip to content

lib: remove uses of PRIu32 for *printf() - #20215

Closed
bagder wants to merge 1 commit into
masterfrom
bagder/priu32-test
Closed

bagder wants to merge 1 commit into
masterfrom
bagder/priu32-test

Conversation

@bagder

@bagder bagder commented Jan 7, 2026 •

Copy link
Copy Markdown
Member

Avoid using PRIu32 and PRId32 in product source code. We don't need it.
It reduces readability. It is also inconsistent since unsigned int has
the same size and does not require the define.

DJGPP warns about using %u for uint32_t by default because it seems to
typedef it to unsigned long instead of unsigned int. Which even that is
annoying since long and int are both 32 bit on this platform.

We use our own *printf() implementation and we know this is safe.

This work-around defines uint32_t for DJGPP into unsigned int to avoid
the warnings and thus the need to use PRIu32 and PRId32.

@bagder bagder changed the title conncache: back to using %u for uint32_t lib: remove uses of PRIu32 for *printf() Jan 7, 2026
@github-actions github-actions Bot added the tests label Jan 7, 2026
@vszakats

vszakats commented Jan 7, 2026 •

Copy link
Copy Markdown
Member

Sorry to be blunt, but this makes absolutely zero sense to me.

Stefan just started using these masks today, which made me commit
these to prepare for it:
https://github.com/curl/curl/pull/20207/files

I might be taking a break from curl.

@bagder

bagder commented Jan 7, 2026

Copy link
Copy Markdown
Member Author

Sorry to be blunt, but this makes absolutely zero sense to me.

I don't understand. What in my reasoning is unclear?

I think we can increase code readability by avoiding these (unnecessary) defines. It is not a critique of you nor your work, it is me looking at the code and thinking we can make it read better.

@bagder
bagder force-pushed the bagder/priu32-test branch from 5c3ebfc to 02e07ff Compare January 8, 2026 07:08
@icing

icing commented Jan 8, 2026 via email

Copy link
Copy Markdown
Contributor

@bagder

bagder commented Jan 8, 2026

Copy link
Copy Markdown
Member Author

I glimpsed your use of them. Maybe I jumped too soon?If there is no downside to the simpler %u, then lets stick to it.

The only downside I can think of is that we need some kind of adjustment/hack to make it not cause warnings with DJGPP. I'm trying that out in this PR.

Avoid using PRIu32 and PRId32 in product source code. We don't need it.
It reduces readability. It is also inconsistent since unsigned int has
the same size and does not require the define.

DJGPP warns about using %u for uint32_t by default because it seems to
typedef it to unsigned long instead of unsigned int. Which even that is
annoying since long and int are both 32 bit on this platform.

We use our own *printf() implementation and we know this is safe.

This work-around defines uint32_t for DJGPP into unsigned int to avoid
the warnings and thus the need to use PRIu32 and PRId32.

Closes #20215
@bagder
bagder force-pushed the bagder/priu32-test branch from 02e07ff to 19f9654 Compare January 8, 2026 09:07
@bagder
bagder marked this pull request as ready for review January 8, 2026 09:07
@bagder

bagder commented Jan 8, 2026

Copy link
Copy Markdown
Member Author

augment review

@augmentcode

augmentcode Bot commented Jan 8, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: This PR simplifies several internal log/trace *printf() format strings by dropping PRIu32/PRId32 usage in favor of plain %u.

Changes:

  • Updated trace/info output in connection pool and multi/URL code to print 32-bit IDs/counters with %u.
  • Adjusted unit tests to match the new formatting.
  • Added a DJGPP-specific uint32_t override to avoid format warnings where DJGPP typedefs it as unsigned long.

Technical Notes: Assumes curl’s internal curl_mprintf-style formatting and the project’s expectations around 32-bit integer argument types.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 1 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread lib/curl_setup.h Resolved
@bagder bagder closed this in 13c1a93 Jan 8, 2026
@bagder
bagder deleted the bagder/priu32-test branch January 8, 2026 13:16
vszakats added a commit to vszakats/curl that referenced this pull request Jan 9, 2026
Since not using `PRI*` macros, this isn't needed.

Follow-up to 13c1a93 curl#20215
Revert 4c9e4e9 curl#20208
vszakats added a commit to vszakats/curl that referenced this pull request Jan 9, 2026
Since not using `PRI*` macros, this isn't needed.

Follow-up to 13c1a93 curl#20215
Revert 4c9e4e9 curl#20208
vszakats added a commit that referenced this pull request Jan 9, 2026
Since not using `PRI*` macros, it isn't needed.

Follow-up to 13c1a93 #20215
Revert 4c9e4e9 #20208

Closes #20225
vszakats added a commit that referenced this pull request Apr 7, 2026
outcast36 pushed a commit to greearb/curl that referenced this pull request Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants