C idioms

Matthias Andree matthias.andree at gmx.de
Tue Dec 17 15:57:09 CET 2002


David Relson <relson at osagesoftware.com> writes:

> It's one of several idioms that C allows that I think a bit odd.  Given
> that outfname is an array, it seems more appropriate to subscript it
> than treate it as a pointer.  Similarly, I'll use abc[3] rather than
> 3[abc], though the compiler considers them the same.  I'm a bit
> surprised that flawfinder and RATS don't consider it a style violation
> or something.

flawfinder/RATS are not style checkers, but security scanners. Dumb
though as they may be, they are useful. Still, I wonder how the
unlink(*outfname) could escape my sight. The warning is there:

main.c: In function `cleanup_exit':
main.c:114: warning: passing arg 1 of `unlink' makes pointer from integer without a cast

Probably the warning was buried under tons of gcc dependency lines and
stuff. make -s should be my friend. Or -Werror...

I wasn't aware that B[C] is commutative and thus equivalent to C[B]. I
knew it's equivalent to *((B) + (C)) though. You could also mention
*(abc + 3) if you wanted to. (Which is BTW necessary on some compilers
that do not allow for abc[-1] but take *(abc - 1) -- makes sense if abc
was incremented or sometimes in memory management). Learnt something
today...

-- 
Matthias Andree




More information about the bogofilter-dev mailing list