Skip to content

8301197: Make sure use of printf is correct and actually needed #24415

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

Closed
wants to merge 5 commits into from

Conversation

magicus
Copy link
Member

@magicus magicus commented Apr 3, 2025

We have been sloppy in our use of printf in make code. Most of the time, we should really use echo instead. If we do need to use printf, we should never inline make or shell variables into the formatting string, since they may contain % which will be interpreted as formatting. Instead, we should always use %s and pass the variable as an argument to printf.

I've checked the entire code base for usages of $PRINTF, and converted most of them to $ECHO, and made sure the remaining ones are correct. I also discovered some additional ugly stuff in relation to this, which I fixed.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8301197: Make sure use of printf is correct and actually needed (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/24415/head:pull/24415
$ git checkout pull/24415

Update a local copy of the PR:
$ git checkout pull/24415
$ git pull https://git.openjdk.org/jdk.git pull/24415/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 24415

View PR using the GUI difftool:
$ git pr show -t 24415

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/24415.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 3, 2025

👋 Welcome back ihse! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Apr 3, 2025

@magicus This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8301197: Make sure use of printf is correct and actually needed

Reviewed-by: erikj

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 47 new commits pushed to the master branch:

  • 60fbf73: 8353709: Debug symbols bundle should contain full debug files when building --with-external-symbols-in-bundles=public
  • 77fff61: 8341095: Possible overflow in os::Posix::print_uptime_info
  • 9128ec6: 8352935: Launcher should not add $JDK/../lib to LD_LIBRARY_PATH
  • 27c8d9d: 8352686: Opensource JInternalFrame tests - series3
  • 66435c2: 8352684: Opensource JInternalFrame tests - series1
  • 353e173: 8219408: Tests should handle ${} in the view of jtreg "smart action"
  • 26bb183: 8352621: MatchException from backwards incompatible change to switch expressions
  • e8c9e5c: 8353231: Test com/sun/management/OperatingSystemMXBean/GetProcessCpuLoad still fails intermittently
  • 6ab1647: 8353637: ZGC: Discontiguous memory reservation is broken on Windows
  • c494a00: 8353559: Restructure CollectedHeap error printing
  • ... and 37 more: https://git.openjdk.org/jdk/compare/296d9d6f7a734cc2bab21c58f21a941150b4cf2a...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk
Copy link

openjdk bot commented Apr 3, 2025

@magicus The following labels will be automatically applied to this pull request:

  • build
  • core-libs

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added build build-dev@openjdk.org core-libs core-libs-dev@openjdk.org labels Apr 3, 2025
@magicus
Copy link
Member Author

magicus commented Apr 3, 2025

/label -core-libs

@openjdk openjdk bot removed the core-libs core-libs-dev@openjdk.org label Apr 3, 2025
@openjdk
Copy link

openjdk bot commented Apr 3, 2025

@magicus
The core-libs label was successfully removed.

@magicus magicus force-pushed the fix-printf-formatting branch from 2439738 to 08a7dc9 Compare April 3, 2025 13:47
@magicus magicus marked this pull request as ready for review April 3, 2025 13:48
@openjdk openjdk bot added the rfr Pull request is ready for review label Apr 3, 2025
@mlbridge
Copy link

mlbridge bot commented Apr 3, 2025

Webrevs

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

Overall looks good to me.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Apr 7, 2025
@magicus
Copy link
Member Author

magicus commented Apr 7, 2025

/integrate

@openjdk
Copy link

openjdk bot commented Apr 7, 2025

Going to push as commit 42dc99e.
Since your change was applied there have been 58 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Apr 7, 2025
@openjdk openjdk bot closed this Apr 7, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Apr 7, 2025
@openjdk
Copy link

openjdk bot commented Apr 7, 2025

@magicus Pushed as commit 42dc99e.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@magicus magicus deleted the fix-printf-formatting branch April 7, 2025 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build build-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

4 participants