2002-09-12 19:49:30

by Bob Tracy

[permalink] [raw]
Subject: 2.5.34: IR __FUNCTION__ breakage

I've been painstakingly going through all the IR code and fixing up
the __FUNCTION__ breakage. One of the not obvious patches is for
linux/net/irda/irnet/irnet.h, where string concatenation was fully
taken advantage of :-).

The problem lies in statements such as

#define DERROR(dbg, args...) \
{if(DEBUG_##dbg) \
printk(KERN_INFO "irnet: " __FUNCTION__ "(): " args);}

where you really want to avoid having any format strings because
"args" could legally have one (and probably will). Under the
circumstances, one option might be something like

define DERROR(dbg, args...) \
{if(DEBUG_##dbg){\
printk(KERN_INFO "irnet: %s(): ", __FUNCTION__);\
printk(KERN_INFO args);}}

which strikes me as not quite what the author intended, although it
should work. Better ideas are welcome, and if a consensus is reached,
I'll be happy to submit the full IR __FUNCTION__ patch set against
2.5.34 for inclusion in a later kernel version.

--
-----------------------------------------------------------------------
Bob Tracy WTO + WIPO = DMCA? http://www.anti-dmca.org
[email protected]
-----------------------------------------------------------------------


2002-09-12 20:13:07

by Thunder from the hill

[permalink] [raw]
Subject: Re: 2.5.34: IR __FUNCTION__ breakage

Hi,

On Thu, 12 Sep 2002, Bob_Tracy wrote:
> define DERROR(dbg, args...) \
> {if(DEBUG_##dbg){\
> printk(KERN_INFO "irnet: %s(): ", __FUNCTION__);\
> printk(KERN_INFO args);}}
>
> which strikes me as not quite what the author intended, although it
> should work.

Why not

#define DERROR(dbg, fmt, args...) \
do { if (DEBUG_##dbg) \
printk(KERN_INFO "irnet: %s(): " fmt, __FUNCTION, args); \
} while(0)

?

Thunder
--
--./../...-/. -.--/---/..-/.-./..././.-../..-. .---/..-/.../- .-
--/../-./..-/-/./--..-- ../.----./.-../.-.. --./../...-/. -.--/---/..-
.- -/---/--/---/.-./.-./---/.--/.-.-.-
--./.-/-.../.-./.././.-../.-.-.-

2002-09-12 21:05:23

by Bob Tracy

[permalink] [raw]
Subject: Re: 2.5.34: IR __FUNCTION__ breakage

Thunder from the hill wrote:
> (good suggestion)

so the revised definition expands from two+ to three+ arguments and
becomes

#define DERROR(dbg, fmt, args...) \
{if(DEBUG_##dbg) \
printk(KERN_INFO "irnet: %s(): " fmt, __FUNCTION__, args);}

in the style of the original code. There aren't all that many source
files that depend on irnet.h, so this shouldn't be too painful.

TO DO: under linux/net/irda, there's a *lot* of cli(), restore_flags(),
save_flags() cleanup work, which I'll happily leave to Jean and/or
Dag :-).

--
-----------------------------------------------------------------------
Bob Tracy WTO + WIPO = DMCA? http://www.anti-dmca.org
[email protected]
-----------------------------------------------------------------------

2002-09-13 16:10:03

by Thunder from the hill

[permalink] [raw]
Subject: Re: 2.5.34: IR __FUNCTION__ breakage

Hi,

On Fri, 13 Sep 2002, Andreas Steinmetz wrote:
> At least for gcc 3.2 this would be better:
>
> #define DERROR(dbg, fmt, args...) \
> do { if (DEBUG_##dbg) \
> printk(KERN_INFO "irnet: %s(): " fmt, __FUNCTION__, ##args); \
> } while(0)
>
> Unfortunately this doesn't work with gcc 2.95.3.

Yepp. As usual, I've forgot the half of it. The second underscores of
__FUNCTION__ were victims, just like the double hash before args.

Thunder
--
--./../...-/. -.--/---/..-/.-./..././.-../..-. .---/..-/.../- .-
--/../-./..-/-/./--..-- ../.----./.-../.-.. --./../...-/. -.--/---/..-
.- -/---/--/---/.-./.-./---/.--/.-.-.-
--./.-/-.../.-./.././.-../.-.-.-

2002-09-13 15:56:13

by Andreas Steinmetz

[permalink] [raw]
Subject: Re: 2.5.34: IR __FUNCTION__ breakage



Thunder from the hill wrote:
> Hi,
>
> On Thu, 12 Sep 2002, Bob_Tracy wrote:
>
>>define DERROR(dbg, args...) \
>> {if(DEBUG_##dbg){\
>> printk(KERN_INFO "irnet: %s(): ", __FUNCTION__);\
>> printk(KERN_INFO args);}}
>>
>>which strikes me as not quite what the author intended, although it
>>should work.
>
>
> Why not
>
> #define DERROR(dbg, fmt, args...) \
> do { if (DEBUG_##dbg) \
> printk(KERN_INFO "irnet: %s(): " fmt, __FUNCTION, args); \
> } while(0)
>
> ?
>
> Thunder

At least for gcc 3.2 this would be better:

#define DERROR(dbg, fmt, args...) \
do { if (DEBUG_##dbg) \
printk(KERN_INFO "irnet: %s(): " fmt, __FUNCTION__, ##args); \
} while(0)

Unfortunately this doesn't work with gcc 2.95.3.

--
Andreas Steinmetz
D.O.M. Datenverarbeitung GmbH

2002-09-13 17:41:43

by Ahmed Masud

[permalink] [raw]
Subject: Re: 2.5.34: IR __FUNCTION__ breakage

Thunder from the hill wrote:

>Hi,
>
>On Fri, 13 Sep 2002, Andreas Steinmetz wrote:
>
>>At least for gcc 3.2 this would be better:
>>
>>#define DERROR(dbg, fmt, args...) \
>> do { if (DEBUG_##dbg) \
>> printk(KERN_INFO "irnet: %s(): " fmt, __FUNCTION__, ##args); \
>> } while(0)
>>
Perhaps a hybrid of the two? :

#define DERROR(dbg, fmt, args...) \
do { if (DEBUG_##dbg) { \
printk(KERN_INFO "irnet: %s() : ", __FUNCTION__); \
printk(fmt, ## args); \
} \
} while (0)

2002-09-13 17:55:05

by Andreas Steinmetz

[permalink] [raw]
Subject: Re: 2.5.34: IR __FUNCTION__ breakage

([email protected] removed from cc list as his mta treats (not only)
my mails as spam...)

Ahmed Masud wrote:
> Thunder from the hill wrote:
>
>> Hi,
>>
>> On Fri, 13 Sep 2002, Andreas Steinmetz wrote:
>>
>>> At least for gcc 3.2 this would be better:
>>>
>>> #define DERROR(dbg, fmt, args...) \
>>> do { if (DEBUG_##dbg) \
>>> printk(KERN_INFO "irnet: %s(): " fmt, __FUNCTION__, ##args); \
>>> } while(0)
>>>
> Perhaps a hybrid of the two? :
>
> #define DERROR(dbg, fmt,
> args...) \
> do { if (DEBUG_##dbg) { \
> printk(KERN_INFO "irnet: %s() : ", __FUNCTION__); \
> printk(fmt, ## args); \
> } \
> } while (0)
>
>
How about what I did just suggest for smbfs?

#if __GNUC__>=3
#define DERROR(dbg, fmt, args...) \
do { if (DEBUG_##dbg) \
printk(KERN_INFO "irnet: %s(): " fmt, __FUNCTION__, ##args); \
} while(0)
#else
#define DERROR(dbg, args...) \
{if(DEBUG_##dbg) \
printk(KERN_INFO "irnet: " __FUNCTION__ "(): " args);}
#endif

gcc 2 versions will be deprecated eventually some time in the future and
in between the macro selection by gcc major version should be fair enough.
--
Andreas Steinmetz
D.O.M. Datenverarbeitung GmbH

2002-09-13 20:10:58

by Thunder from the hill

[permalink] [raw]
Subject: Re: 2.5.34: IR __FUNCTION__ breakage

Hi,

On Fri, 13 Sep 2002, Ahmed Masud wrote:
> #define DERROR(dbg, fmt, args...) \
> do { if (DEBUG_##dbg) { \
> printk(KERN_INFO "irnet: %s() : ", __FUNCTION__); \
> printk(fmt, ## args); \
> } \
> } while (0)

That's 100% senseless. It gains you nothing, it takes you nothing...

Thunder
--
--./../...-/. -.--/---/..-/.-./..././.-../..-. .---/..-/.../- .-
--/../-./..-/-/./--..-- ../.----./.-../.-.. --./../...-/. -.--/---/..-
.- -/---/--/---/.-./.-./---/.--/.-.-.-
--./.-/-.../.-./.././.-../.-.-.-

2002-09-13 20:11:18

by Neil Booth

[permalink] [raw]
Subject: Re: 2.5.34: IR __FUNCTION__ breakage

Andreas Steinmetz wrote:-

> At least for gcc 3.2 this would be better:
>
> #define DERROR(dbg, fmt, args...) \
> do { if (DEBUG_##dbg) \
> printk(KERN_INFO "irnet: %s(): " fmt, __FUNCTION__, ##args); \
> } while(0)
>
> Unfortunately this doesn't work with gcc 2.95.3.

I think it might if you put a space after __FUNCTION__ and before the
comma.

Neil.

2002-09-13 20:27:02

by Andreas Steinmetz

[permalink] [raw]
Subject: Re: 2.5.34: IR __FUNCTION__ breakage

Neil Booth wrote:
> Andreas Steinmetz wrote:-
>
>
>>At least for gcc 3.2 this would be better:
>>
>>#define DERROR(dbg, fmt, args...) \
>> do { if (DEBUG_##dbg) \
>> printk(KERN_INFO "irnet: %s(): " fmt, __FUNCTION__, ##args); \
>> } while(0)
>>
>>Unfortunately this doesn't work with gcc 2.95.3.
>
>
> I think it might if you put a space after __FUNCTION__ and before the
> comma.
>
> Neil.
>

Yes, I just verified it does work this way on gcc 2.95.3 though in my
opinion it is very prone to errors (typos, ...). Furthermore I don't
have any older compilers around for testing this which might still be in
use.

--
Andreas Steinmetz
D.O.M. Datenverarbeitung GmbH

2002-09-13 20:48:45

by Thunder from the hill

[permalink] [raw]
Subject: Re: 2.5.34: IR __FUNCTION__ breakage

Hi,

On Fri, 13 Sep 2002, Andreas Steinmetz wrote:
> Yes, I just verified it does work this way on gcc 2.95.3 though in my
> opinion it is very prone to errors (typos, ...). Furthermore I don't
> have any older compilers around for testing this which might still be in
> use.

gcc 2.92 accepts it.

Thunder
--
--./../...-/. -.--/---/..-/.-./..././.-../..-. .---/..-/.../- .-
--/../-./..-/-/./--..-- ../.----./.-../.-.. --./../...-/. -.--/---/..-
.- -/---/--/---/.-./.-./---/.--/.-.-.-
--./.-/-.../.-./.././.-../.-.-.-