Skip to content
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ void logString(FILE *logfile, const char *msg, ...) {
va_start(argprt, msg);
vsnprintf(tmpbuf, sizeof(tmpbuf), msg, argprt);

fprintf(logfile, tmpbuf);
fprintf(logfile, "\n");
fprintf(logfile, "%s\n", tmpbuf);
Copy link
Member

Choose a reason for hiding this comment

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

Why can't we use fputs and avoid all the format string logic and ambiguity altogether?

Alternatively, use vfprintf directly instead of first formatting the arguments into a temporary buffer with vsnprintf and then sending the result to the output.

Copy link
Contributor

Choose a reason for hiding this comment

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

A similar pattern is used elsewhere in this file. And I don't want this fix to become a reworking of this code, because that isn't a goal here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After reading about fputs, I think this is best. Like you mentioned, no ambiguity since it does not use specifiers. Updated.

Copy link
Member

@aivanov-jdk aivanov-jdk Dec 23, 2025

Choose a reason for hiding this comment

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

A similar pattern is used elsewhere in this file. And I don't want this fix to become a reworking of this code, because that isn't a goal here.

Indeed, it is.

I agree it's better to keep the code consistent.

At the same time, I think it's worth submitting a bug to simplify usages like that, fputs works perfectly for strings that don't require formatting.

Copy link
Contributor

Choose a reason for hiding this comment

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

Since Damon already made the change and its just one line I'm fine to keep it but not go looking for more.

fflush(logfile);
}

Expand Down