Skip to content

fboss2: remove no-op lrint in splitFractionalSecondsFromTimer#1294

Open
atulya-singh wants to merge 1 commit into
facebook:mainfrom
atulya-singh:fix-remove-noop-lrint
Open

fboss2: remove no-op lrint in splitFractionalSecondsFromTimer#1294
atulya-singh wants to merge 1 commit into
facebook:mainfrom
atulya-singh:fix-remove-noop-lrint

Conversation

@atulya-singh

Copy link
Copy Markdown

Pre-submission checklist

  • I've ran the linters locally and fixed lint errors related to the files I modified in this PR. You can install the linters by running pip install -r requirements-dev.txt && pre-commit install
  • pre-commit run

Summary

In splitFractionalSecondsFromTimer (fboss/cli/fboss2/utils/CmdUtilsCommon.cpp):

tv.tv_usec = (timer % 1000); // get fractional seconds
tv.tv_usec = lrint(tv.tv_usec); // round fs to nearest decimal

tv.tv_usec is a long that was just assigned the integer result of timer % 1000. Calling lrint() on an already-integral value is a no-op, and the "round fs to nearest decimal" comment is misleading -- there is nothing fractional to round.

This change removes the dead line and corrects the comment to note the value is milliseconds (it is the timer % 1000 remainder, not microseconds despite the tv_usec field name).

Test Plan

Pure cleanup with no behavioral change.

  • pre-commit run --files fboss/cli/fboss2/utils/CmdUtilsCommon.cpp -> clang-format ... Passed, all hooks pass.
  • Behavior unchanged: timer = 6475 still yields {tv_sec = 6, tv_usec = 475}, which parseTimeToTimeStamp continues to render identically.
tv.tv_usec is a long that was just assigned an integer (timer % 1000),
so lrint() on it is a no-op and the "round fs to nearest decimal"
comment is misleading -- there is nothing fractional to round. Drop the
line and fix the comment to note the value is milliseconds.
@atulya-singh atulya-singh requested a review from a team as a code owner June 13, 2026 19:32
@meta-cla meta-cla Bot added the CLA Signed label Jun 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

1 participant