Patchset to make __func__ more visible

Michael Adam obnox at samba.org
Tue Nov 5 02:43:48 MST 2013


On 2013-11-04 at 10:34 +0100, Volker Lendecke wrote:
> On Mon, Nov 04, 2013 at 10:30:02AM +0100, Volker Lendecke wrote:
> > On Mon, Nov 04, 2013 at 10:27:46AM +0100, Stefan (metze) Metzmacher wrote:
> > > Am 04.11.2013 10:23, schrieb Andrew Bartlett:
> > > > On Mon, 2013-11-04 at 09:47 +0100, Volker Lendecke wrote:
> > > >> On Mon, Nov 04, 2013 at 09:13:59PM +1300, Andrew Bartlett wrote:
> > > >>> On Fri, 2013-11-01 at 13:11 +0100, Volker Lendecke wrote:
> > > >>>> Hi!
> > > >>>>
> > > >>>> Attached find 2 patches that fix faulty DEBUG statements in
> > > >>>> one case by using __func__. I would like to see more use of
> > > >>>> this throughout our code, so I added another patch putting a
> > > >>>> hint into README.Coding.
> > > >>>
> > > >>> I thought we were going to just fix the debug macro?  Last I remember
> > > >>> Jeremy had a patch, which mysteriously failed autobuild in some way. 
> > > >>
> > > >> Ok. The fix would be to just remove all the function names
> > > >> in DEBUG statements, right? Or do you want me to just fix it
> > > >> and hard-code the now correct name again?
> > > > 
> > > > First, I do totally agree that incorrect function names in debug
> > > > statements are worse than useless, they are misleading and deceptive,
> > > > and we should fix them. 
> > > > 
> > > > The plan was, as I recall it:
> > > >  - sort out DEBUG() to just do the right thing.  I think what we agreed
> > > > was that was to always print the header, even in 'foreground' mode.  
> > > >  - stop typing in the function name into new code
> > > >  - clean up old code.
> > > 
> > > Yes, something like that.
> > > 
> > > > If for some reason we just can't get the first part of that plan to
> > > > work, then using __func__ is quite a reasonable fallback, but it's
> > > > probably best to use string pasting rather than %s eg: __func__ ": foo"
> > > 
> > > Shouldn't we use  __FUNCTION__ instead of __func__? That's what always
> > > provides
> > > it's __func__ or ("") as fallback.
> > 
> > __func__ is shorter :-)
> 
> Ah, and it's standard these days. I'd rather #define
> __func__ in lib/replace if it's not there. At one point we
> changed True/False to true/false for similar reasons if I
> remember correctly.

And what is more, __FUNCTION__ seems to have been a gcc-specific
addition, not standardized:

http://gcc.gnu.org/onlinedocs/gcc-4.8.1/gcc/Function-Names.html

So we should probably add __func__ to replace and replace use of
__FUNCTION__ by __func__.

So for the time being, can we push Volker's fix for the debug
statement? And possibly also the update to README.coding?
I think both are valuable additions and don't require fixing
all places or rewriting the debug system before they can be
applied. :-)

So if no-one vetoes, I would push them.

Cheers - Michael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 215 bytes
Desc: Digital signature
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20131105/2430107f/attachment.pgp>


More information about the samba-technical mailing list