Page MenuHomeFreeBSD

df: ceil() the percentage value
Needs ReviewPublic

Authored by jlduran on Wed, Dec 17, 4:51 AM.
Tags
None
Referenced Files
F142068917: D54264.id168247.diff
Thu, Jan 15, 5:47 PM
Unknown Object (File)
Wed, Jan 14, 8:01 AM
Unknown Object (File)
Tue, Jan 13, 4:05 AM
Unknown Object (File)
Mon, Jan 12, 7:47 PM
Unknown Object (File)
Mon, Jan 12, 6:47 PM
Unknown Object (File)
Mon, Jan 12, 6:25 AM
Unknown Object (File)
Mon, Jan 12, 6:16 AM
Unknown Object (File)
Sun, Jan 11, 5:35 PM
Subscribers

Details

Reviewers
emaste
imp
des
Summary

"The percentage value shall be expressed as a positive integer, with any
fractional result causing it to be rounded [up] to the next highest
integer."

Use a hand-rolled ceil() equivalent (as long as it doesn't overflow), to
avoid using math.h in our percent() function.

Fix the tests accordingly, they now match the percentage values on
NetBSD.

Also, use the same percent() function for the calculation of used
inodes.

Update the percentage values in the manual page as well.

Test Plan
$ kyua test
t_df:hflag  ->  passed  [0.009s]
t_df:normal  ->  passed  [0.008s]

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

jlduran edited the test plan for this revision. (Show Details)
  • Round up the used inodes percentage as well. Although not required by POSIX, it would be odd to just have one percentage rounded up.
bin/df/df.c
541

Why pass a double if the value is an integer?

544

This is a direct quote from the standard; please add quotation marks and a citation.

560–561

Why pass a double if the value is an integer?

bin/df/df.c
544

(or replace the quote with a paraphrase)

jlduran edited the summary of this revision. (Show Details)
jlduran marked 4 inline comments as done.

Address suggestions:

  • Quote and cite the text from POSIX.
  • Use an unsigned decimal number to express the percentage. Keep the current width of the field to avoid changing the spacing between columns.
jlduran edited the summary of this revision. (Show Details)

Update the manual page percentages as well.

jlduran edited the summary of this revision. (Show Details)
  • Reduce duplication by abstracting the percent() function.