Skip to content

Replace Bsnprintf() implementation and add format attributes#1697

Merged
BareosBot merged 23 commits intobareos:masterfrom
arogge:dev/arogge/master/replace-bsnprintf
Jun 3, 2025
Merged

Replace Bsnprintf() implementation and add format attributes#1697
BareosBot merged 23 commits intobareos:masterfrom
arogge:dev/arogge/master/replace-bsnprintf

Conversation

@arogge
Copy link
Member

@arogge arogge commented Feb 5, 2024

This PR replaces the implementation of Bvsnprintf() by the plain library functions.
We also add the attributes to all printf()-like functions to be able to detect problems at compile-time instead of crashing at runtime. As this produced a lot of problems, -Werror was disabled for format-related things (but should be re-enabled before this PR is merged).

Please check

  • Short description and the purpose of this PR is present above this paragraph
  • Your name is present in the AUTHORS file (optional)

If you have any questions or problems, please give a comment in the PR.

Helpful documentation and best practices

Checklist for the reviewer of the PR (will be processed by the Bareos team)

Make sure you check/merge the PR using devtools/pr-tool to have some simple automated checks run and a proper changelog record added.

General
  • Is the PR title usable as CHANGELOG entry?
  • Purpose of the PR is understood
  • Commit descriptions are understandable and well formatted
Source code quality
  • Source code changes are understandable
  • Variable and function names are meaningful
  • Code comments are correct (logically and spelling)
  • Required documentation changes are present and part of the PR
  • the temporary commit disabling format errors has been removed

@bruno-at-bareos bruno-at-bareos marked this pull request as draft February 6, 2024 10:58
@sebsura sebsura added the nobuild label Feb 9, 2024
@sebsura
Copy link
Contributor

sebsura commented Feb 9, 2024

I set this to no build to reduce the strain on jenkins. As soon as we get it to build locally this should be changed back.

@sebsura sebsura force-pushed the dev/arogge/master/replace-bsnprintf branch 2 times, most recently from dba59d4 to 5fb5295 Compare February 9, 2024 12:55
@sebsura sebsura removed the nobuild label Feb 20, 2024
@sebsura sebsura force-pushed the dev/arogge/master/replace-bsnprintf branch 8 times, most recently from 6774b89 to bb5cb43 Compare February 22, 2024 09:52
@arogge arogge added this to the 24.0.0 milestone Jun 25, 2024
@sebsura sebsura marked this pull request as ready for review July 12, 2024 05:47
@sebsura sebsura marked this pull request as draft July 12, 2024 05:47
@sebsura sebsura force-pushed the dev/arogge/master/replace-bsnprintf branch from 3eeb351 to 210e60b Compare July 15, 2024 13:20
@sebsura sebsura force-pushed the dev/arogge/master/replace-bsnprintf branch from 4c5391b to 23e9cee Compare July 17, 2024 12:15
@sebsura sebsura marked this pull request as ready for review August 5, 2024 09:40
@sebsura sebsura force-pushed the dev/arogge/master/replace-bsnprintf branch 2 times, most recently from 076cdb2 to f8669ce Compare August 13, 2024 08:30
@sebsura sebsura self-requested a review August 14, 2024 06:46
@sebsura sebsura force-pushed the dev/arogge/master/replace-bsnprintf branch from b309df4 to 8c3ec2f Compare May 23, 2025 09:21
Copy link
Member Author

@arogge arogge left a comment

Choose a reason for hiding this comment

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

I looked at it and am mostly happy. I have a few concerns that we may want to address (or maybe not)

  • Bareos own type names usually use PascalCase
  • quite a few newly introduced casts use C-style casts (ES.49)
  • we now have a lot of format("%s", string), maybe we can find a way to have a safe format(string) that just skips formatting
  • I'm not sure I fully grasp why integral constants are inline constexpr and string constants are constexpr const char[] (i.e. without the inline

Copy link
Contributor

@sebsura sebsura left a comment

Choose a reason for hiding this comment

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

Looks good to me! We just need to update the copyright information and squash the fixup commits.

@sebsura sebsura force-pushed the dev/arogge/master/replace-bsnprintf branch from 98ac610 to ae52417 Compare June 2, 2025 08:09
arogge and others added 23 commits June 3, 2025 12:23
Replace the existing code with a simple wrapper around the standard
library.
The changes to printf lead to slight differences in some output. This
patch adapts the existing test to the new outputs.
We use a macro for this to (possibly) support multiple compliers.
Currently only gcc and clang support this feature.  On msvc the macro
currently just expands to nothing.
@BareosBot BareosBot force-pushed the dev/arogge/master/replace-bsnprintf branch from 5c5f58b to d5eca98 Compare June 3, 2025 12:24
@BareosBot BareosBot merged commit 8c8d823 into bareos:master Jun 3, 2025
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.

4 participants