Are code assertions considered harmful?

Cameron Paine cbp at null.net
Sat Nov 8 20:13:22 GMT 2003


On Sat, 2003-11-08, "Andrew Bartlett" <abartlet at samba.org> wrote:
> On Sat, 2003-11-08 at 16:34, Cameron Paine wrote:
> > I'm interested in opinions from a group of seasoned designers and
> > coders...
> >
> > I'm hunting some undocumented features in libsmbclient that are really
> > laying my project's financial and time lines to waste. I guess I should
> > have done a thorough code review before I committed to using the library
> > so I guess that after 25 years at this I'm still able to be ambushed.
;-)
>
> Are you using the exposed interfaces in libsmbclient.h, or actual
> internal Samba library calls?

Strictly published interfaces. This is production code that I hope
will be resiliant enough to sustain future upgrades to the (shared)
client library. FWIW, this project will be open sourced. My client
and I are jointly funding its development. I just didn't factor in
the time required to get the library working reliably. And that
overrun is at my cost.

> > Anyway, I'm trying to improve the worst excesses of the code and am
> > being hamstrung by the paucity of documentation. It seems that the
> > interface contracts for most of the functions in the library--both
> > internal and exported--are seldom written down...

> For the interfaces exposed in libsmbclient.h, there are some Doxygen
> comments.  But I certainly agree with your points on 'contracts' - we
> basicly don't have any.   But if you do violate the interface
> contracts, your behaviour is simply 'undefined...'

That reads like a Joseph Heller novel. :-)

> > To my question then: why are assertions considered unhelpful? ...

> There is SMB_ASSERT(), used in some places where we have
> tried to force
> a particular interface, or (more commonly) where we need to
> bail out in
> the case of internal logic errors.

Ahhh, a macro that's use is deprecated. Sorry--couldn't resist. ;-)

> For Samba4, Tridge is trying to document the code he is writing, and
> push a level of required documentation onto the whole team as we start
> coding on it.  I really do hope this works.

Heh, so do I. With good commentary it is feasible for an over-
committed person (such as myself) to make useful contributions
without needing to become a member of the development team. At
the moment, all I feel I can do is lamely hand-wave. See my
reply to Richard for evidence of this.

Thanks for your thoughts.

Cameron Paine





More information about the samba-technical mailing list