tech-userlevel archive

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

Re: swscanf() causing Memory Fault



Hubert Feyrer wrote:
> 
> On 2008年11月16日, James K. Lowden wrote:
> >> + (void)memset(WCIO_GET(&f), 0, sizeof(struct wchar_io_data));
> >
> > Why cast a discarded return code to void? That seems overly fussy to
> > me.
> 
> We've been doing this since ~forever: 
The tradition of discarding return codes is, I'm sure even older. ;-) 
> It's to tell lint(1) that we're 
> aware of the fact that menset() returns something, and that we ignore it
> 
> on purpose.
Is it considered a feature of NetBSD's source code or a defect in lint(1)?
 I dislike cluttering source that's perfectly clear (and safe) to the
human eye just to satisfy a tool. It's not NetBSD's fault that memset(3)
returns a useless pointer. (I can almost imagine passing memset's return
to, say, strcpy(3) back in the days when it returned a char*. Now that it
needs a cast, I think it's more likely to be discarded.)O
ISTM lint should have an ignore-discarded-return-codes option. Maybe
could be constricted to functions like memset that can't return an error. 
Other solutions obviously include a macro or just use bzero instead. 
Thanks for the answer anyway, Hubert. It looked both odd and deliberate,
and I appreciate knowing why. 
--jkl


Home | Main Index | Thread Index | Old Index

AltStyle によって変換されたページ (->オリジナル) /