RFR: 8373474: 2 Unintentional format string defect groups in jabswitch.cpp [v2]
Alexey Ivanov
aivanov at openjdk.org
Tue Dec 23 20:35:59 UTC 2025
On Tue, 23 Dec 2025 17:15:22 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:
>> OK fair enough.
>
> Why can't we use [`fputs`](https://en.cppreference.com/w/c/io/fputs.html)?
>
>
> fputs("assistive_technologies=com.sun.java.accessibility.AccessBridge\n"
> "screen_magnifier_present=true\n",
> origFile);
>
> No format strings avoid any possible ambiguity and it's much faster as the string is output verbatim without any additional logic to parse a format string and to process the arguments.
I guess [the same comment](https://github.com/openjdk/jdk/pull/28950#discussion_r2644143842) applies here:
> 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.
Thus, `fprintf` is fine.
Similarly, it could be worth cleaning up the code to simplify the logic by not using *formatted output* where it's not needed.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28949#discussion_r2644209140
More information about the client-libs-dev
mailing list