Skip to content

Pass integers to sprintf in the hms constructor - #735

Merged
moodymudskipper merged 1 commit into
mainfrom
b-hms-sprintf-integer
Oct 17, 2026
Merged

moodymudskipper merged 1 commit into
mainfrom
b-hms-sprintf-integer

Conversation

@moodymudskipper

Copy link
Copy Markdown
Collaborator

The valgrind job on #733 (R-hub) failed in test-s3-hms.R:

construct(hms::as_hms(c("12:34:56", "00:00:00", NA, "24:00:00")))
Caused by error in `sprintf()`:
! invalid format '%02d'; use format %f, %e, %g or %a for numeric objects

.cstr_construct.hms.as_hms() passed doubles computed with %/% to "%02d", which relies on sprintf() accepting whole doubles. They are now converted with as.integer() first. Output is unchanged, so the snapshot is unchanged.

Not reproduced locally (macOS, no valgrind); an R-hub valgrind run is dispatched on this branch to confirm. R/s3-ITime.R already passes integers, no other %d call on doubles of this kind.

🤖 Generated with Claude Code

The "as_hms" constructor formatted hours and minutes with "%02d" from
doubles computed with %/%. sprintf() only accepts whole doubles for "%d"
after its own check, and on the R-hub valgrind platform the hms test
failed with "invalid format '%02d'; use format %f, %e, %g or %a for
numeric objects". Converting to integer first makes the call
independent of the platform's floating point handling.
@codecov

codecov Bot commented Oct 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.52%. Comparing base (c64680d) to head (cc17bb6).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #735   +/-   ##
=======================================
  Coverage   82.52%   82.52%           
=======================================
  Files         230      230           
  Lines        8689     8689           
=======================================
  Hits         7171     7171           
  Misses       1518     1518           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@moodymudskipper
moodymudskipper merged commit 30b87f0 into main Oct 17, 2026
10 of 11 checks passed
@moodymudskipper
moodymudskipper deleted the b-hms-sprintf-integer branch October 17, 2026 00:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant