tech-misc archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: __attribute__((warn_unused_result)) for NetBSD?




On Sep 15, 2008, at 4:56 PM, Aleksey Cheusov wrote:

but it may still be true that for the most part all common usages of
close don't need warnings about missing the return value.
It is not very convincing :-)

Common uses of close are typically in code that is not paranoid about
errors and doesn't really care enough to, for example, even check the
return values from fprintf.  As such, those programs don't need to
bother with the level of robustness you appear to be advocating.
In programming paranoia is "good thing" ;-)

When I wrote such a wrapper functions I know EXACTLY that they will
work fine on ALL platforms and in ANY environment.  Such functions are
even more important in libraries where nobody garantees that
non-portable SA_RESTART will be activated.

Yes, I'm paranoid, of course this is my decision and I don't teach YOU
how to program and what to do. My original proposal was much wider
than one exceptional close(2). In truth to tell, discussion about
close(2) is not very interesting for me. I already made my desicion
years ago - in programming paranoia is good.


That's kind of the point here though. You want to force your notions of "correct" code on folks. In general I'm ok with this as long as it's sane. Warning about things which almost no one writes tests against (like close) falls into that bucket. Educate or not, you can't do it by annoying people to the point they just turn them off.

James

The original question was... Do you like an idea of marking functions
(conditionally! e.g. if WARNS=4 etc.) with "warn_unused_result" IN
GENERAL?  And if yes, _what kind of functions_ you WILL mark with it.

Variants:
1) this mark is useless at all
2) only for functions with no side effects
3) for some functions that may fail (read, write etc.)
4) 2 + 3

--
Best regards, Aleksey Cheusov.



Home | Main Index | Thread Index | Old Index