Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-112301: Use literal format strings in unicode_fromformat_arg #124203

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

encukou
Copy link
Member

@encukou encukou commented Sep 18, 2024

This switches sprintf format strings in unicode_fromformat_arg to compile-time literals, avoiding -Wformat-nonliteral warnings and maybe even allowing optimizing the sprintf calls.

The macros aren't too readable so I'm generous with comments.

(Another option would be code generation, see the first commit.)

@rruuaanng
Copy link

Maybe you should add NEWS.

@vstinner
Copy link
Member

Maybe you should add NEWS.

This change doesn't impact end users. I don't think that a NEWS entry is needed.

sprintf(buffer, fmt, va_arg(*vargs, int)) :
sprintf(buffer, fmt, va_arg(*vargs, unsigned int));
break;
case F_LONG: DO_SPRINTS("l", long, unsigned long)
Copy link
Member

Choose a reason for hiding this comment

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

Can you put the break here? Something like:

Suggested change
case F_LONG: DO_SPRINTS("l", long, unsigned long)
case F_LONG: DO_SPRINTS("l", long, unsigned long); break;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants