[cs631apue] getbsize(3) error checking
jschauma at stevens.edu
Fri Oct 12 21:53:45 EDT 2018
Ramana Nagasamudram <rnagasam at stevens.edu> wrote:
> How should we go about handling any errors from getbsize(3)? The
> man page says that when BLOCKSIZE isn't reasonable, a warning is
> written to stderr. Does this mean we don't have to worry about
> writing to stderr when using this function?
Think about what you'd expect for a tool: would you prefer two messages
basically saying the same thing?
In programming, this is known as the Principle of Least Astonishment
(POLA, also: least surprise). Do what the user would expect.
Since you have a handy reference implementation, you can also compare
what that tool does. Set BLOCKSIZE to something non-sensical and see
how that tool reports the error.
More information about the cs631apue