Page MenuHomeFreeBSD

df: Make warning failures fatal
Needs ReviewPublic

Authored by jlduran on Sun, Mar 1, 9:51 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Mar 25, 7:14 AM
Unknown Object (File)
Wed, Mar 25, 3:06 AM
Unknown Object (File)
Sun, Mar 22, 7:25 AM
Unknown Object (File)
Fri, Mar 20, 6:54 AM
Unknown Object (File)
Fri, Mar 20, 2:36 AM
Unknown Object (File)
Thu, Mar 19, 8:49 AM
Unknown Object (File)
Sun, Mar 15, 10:35 PM
Unknown Object (File)
Sun, Mar 15, 7:02 AM
Subscribers
None

Details

Reviewers
des
Summary

Replace xo_warn() and xo_warnx() calls with xo_err() and xo_errx()
throughout the df command to ensure consistent error reporting and
proper exit codes when memory allocation or a system call fails.
This improves the reliability and behavior of the command in error
conditions.

Suggested by: des

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

jlduran created this revision.

Note that we want to keep the current behavior in makenetvfslist().

Note that we want to keep the current behavior in makenetvfslist().

Why?

In D55610#1272421, @des wrote:

Note that we want to keep the current behavior in makenetvfslist().

Why?

Actually my original statement should have been a question.
I see the code comes from a25695c3a433cd76b68427ef324efc1f109f36ed, as a result of the bug report:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=27240
It is not clear why warnx() was preferred.
I'll update shortly.

jlduran retitled this revision from df: Make malloc() failure fatal to df: Make warning failures fatal.
jlduran edited the summary of this revision. (Show Details)
bin/df/df.c
658

I'm not a fan of this chunk of code.

bin/df/df.c
658

Well then refactor it. It was written this way to avoid duplicating the cleanup, but since you are now existing on allocation failure, that problem no longer exists.

jlduran marked an inline comment as done.

Refactor chunk of code:

  • Prefer clear, separate if statements
  • sizeof(char) is always 1
bin/df/df.c
658

s/existing/exiting/

bin/df/df.c
641–642

This is not needed.

645–646

This is not needed.

651–652

This is not needed.

665–666

This is not needed.

jlduran marked 5 inline comments as done.

Address suggestions:

  • Do not manually reclaim memory