[Nut-upsdev] Re: [Nut-upsuser] Problem after reboot

Arjen de Korte nut+devel at de-korte.org
Fri Mar 3 13:28:44 UTC 2006

I'm taking this thread to nut-devel, since it really doesn't belong in
nut-users anymore.

> I propose to rename the function fatal() as fatal_with_errno(), and
> similarly upslog() as upslog_with_errno(). Reason: this is
> self-documenting, and will help to avoid accidentally calling fatal()
> in a situation where errno is not set. fatalx() and upslogx() would
> remain as before.

I'm not sure whether the call to fatal() was an accident here (and should
have been fatalx() instead) or intentional. Assuming it was an accident,
we might have solved this also by just changing the calls to fatal() into
fatalx(), without modifying get_user_pwent() at all. Short of this, your
suggestion fails to address the case for upsdebug() and upsdebugx(), where
a similar situation exists.

Changing these functions in all drivers (and documentation) would mean a
massive amount of changes (although this could be automated) to maintain
consistency. In that case, I would also like to see fatalx(), upslogx()
and upsdebugx() changed to fatal_without_errno(), upslog_without_errno()
and upsdebug_without_errno(). Personally, I don't think changing all these
names (and additional typing needed for new ones) is worth the effort and
we should mainly focus on preventing the fatal() function to print
obviously wrong information.

> Any objections?

It seems that our posts crossed. I just proposed to keep the names as they
are and just let fatal() behave as fatalx() when errno is zero, to prevent
printing "success" where the action taken (aborting the program) clearly
means something is very wrong. As far as I'm concerned, that should be
enough. A different effort (and more important one) would be to be
somewhat more verbose in telling the user what's wrong before bailing out
with a call to fatal() or fatalx(). Displaying/logging 'getpwnam(nut)'
just isn't very informative, even without calling it a success.


More information about the Nut-upsdev mailing list