Fixing the many DEBUG statements that have confusing info ...

Martin Schwenke martin at meltin.net
Wed Oct 14 00:27:04 UTC 2015


On Mon, 12 Oct 2015 09:25:53 -0700, Jeremy Allison <jra at samba.org>
wrote:

> On Sun, Oct 11, 2015 at 08:05:39AM -0700, Richard Sharpe wrote:
> > On Sun, Oct 11, 2015 at 1:27 AM, Volker Lendecke
> > <Volker.Lendecke at sernet.de> wrote:
> > > On Sat, Oct 10, 2015 at 09:09:03PM -0700, Richard Sharpe wrote:
> > >> Hi folks,
> > >>
> > >> I thought I would spend some time fixing DEBUG statements using this idiom:
> > >>
> > >> @@ -705,8 +705,8 @@ static bool smbd_open_one_socket(struct smbd_parent_context
> > >> *parent,
> > >>         ifss,
> > >>         true);
> > >>   if (s->fd == -1) {
> > >> - DEBUG(0,("smbd_open_one_socket: open_socket_in: "
> > >> - "%s\n", strerror(errno)));
> > >> + DEBUG(0,("%s: open_socket_in: %s\n",
> > >> + __func__, strerror(errno)));
> > >>   TALLOC_FREE(s);
> > >>   /*
> > >>   * We ignore an error here, as we've done before
> > >>
> > >> where we use %s and __func__.
> > >>
> > >> However, then I looked at a log file, and saw the following:
> > >>
> > >> [2015/09/27 03:37:05.961482, 10, pid=13547, effective(0, 0), real(0,
> > >> 0)] ../source3/lib/messages_dgm.c:403(messaging_dgm_wipe)
> > >>   messaging_dgm_cleanup(12521) returned Resource temporarily unavailable
> > >>
> > >> That is, we already print the source file name, line number and the
> > >> function name. (And the debug message the produced that has gotten out
> > >> of sync with the actual location.)
> > >>
> > >> Why should we duplicate that info. Surely it is better to simply
> > >> eliminate the function names from DEBUG messages.
> > >
> > > Try smbd -d10 -i or any commandline tool.
> > 
> > Well, then we should fix the DEBUG macros so that they add __func__ in
> > all cases.
> 
> +1 on that.

Unless I'm misunderstanding something, that means going through a lot of
code and removing __func__ (or similar) in places where is has been
explicitly added.

I'd suggest a variation of DEBUG() to include the location... but there
are already a lot of variations.  :-)

peace & happiness,
martin



More information about the samba-technical mailing list