linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* 2.5.34: IR __FUNCTION__ breakage
@ 2002-09-12 19:54 Bob_Tracy
  2002-09-12 20:16 ` Thunder from the hill
  0 siblings, 1 reply; 11+ messages in thread
From: Bob_Tracy @ 2002-09-12 19:54 UTC (permalink / raw)
  To: dag; +Cc: linux-kernel

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
rct@frus.com
-----------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: 2.5.34: IR __FUNCTION__ breakage
  2002-09-12 19:54 2.5.34: IR __FUNCTION__ breakage Bob_Tracy
@ 2002-09-12 20:16 ` Thunder from the hill
  2002-09-12 21:09   ` Bob_Tracy
  2002-09-13 16:01   ` Andreas Steinmetz
  0 siblings, 2 replies; 11+ messages in thread
From: Thunder from the hill @ 2002-09-12 20:16 UTC (permalink / raw)
  To: Bob_Tracy; +Cc: dag, linux-kernel

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
-- 
--./../...-/. -.--/---/..-/.-./..././.-../..-. .---/..-/.../- .-
--/../-./..-/-/./--..-- ../.----./.-../.-.. --./../...-/. -.--/---/..-
.- -/---/--/---/.-./.-./---/.--/.-.-.-
--./.-/-.../.-./.././.-../.-.-.-


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: 2.5.34: IR __FUNCTION__ breakage
  2002-09-12 20:16 ` Thunder from the hill
@ 2002-09-12 21:09   ` Bob_Tracy
  2002-09-13 16:01   ` Andreas Steinmetz
  1 sibling, 0 replies; 11+ messages in thread
From: Bob_Tracy @ 2002-09-12 21:09 UTC (permalink / raw)
  To: Thunder from the hill; +Cc: dag, linux-kernel

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
rct@frus.com
-----------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: 2.5.34: IR __FUNCTION__ breakage
  2002-09-12 20:16 ` Thunder from the hill
  2002-09-12 21:09   ` Bob_Tracy
@ 2002-09-13 16:01   ` Andreas Steinmetz
  2002-09-13 16:14     ` Thunder from the hill
  2002-09-13 20:12     ` Neil Booth
  1 sibling, 2 replies; 11+ messages in thread
From: Andreas Steinmetz @ 2002-09-13 16:01 UTC (permalink / raw)
  To: Thunder from the hill; +Cc: Bob_Tracy, dag, linux-kernel



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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: 2.5.34: IR __FUNCTION__ breakage
  2002-09-13 16:01   ` Andreas Steinmetz
@ 2002-09-13 16:14     ` Thunder from the hill
  2002-09-13 17:46       ` Ahmed Masud
  2002-09-13 20:12     ` Neil Booth
  1 sibling, 1 reply; 11+ messages in thread
From: Thunder from the hill @ 2002-09-13 16:14 UTC (permalink / raw)
  To: Andreas Steinmetz; +Cc: Thunder from the hill, Bob_Tracy, dag, linux-kernel

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
-- 
--./../...-/. -.--/---/..-/.-./..././.-../..-. .---/..-/.../- .-
--/../-./..-/-/./--..-- ../.----./.-../.-.. --./../...-/. -.--/---/..-
.- -/---/--/---/.-./.-./---/.--/.-.-.-
--./.-/-.../.-./.././.-../.-.-.-


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: 2.5.34: IR __FUNCTION__ breakage
  2002-09-13 16:14     ` Thunder from the hill
@ 2002-09-13 17:46       ` Ahmed Masud
  2002-09-13 18:01         ` Andreas Steinmetz
  2002-09-13 20:11         ` Thunder from the hill
  0 siblings, 2 replies; 11+ messages in thread
From: Ahmed Masud @ 2002-09-13 17:46 UTC (permalink / raw)
  To: Thunder from the hill; +Cc: Andreas Steinmetz, Bob_Tracy, dag, linux-kernel

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)


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: 2.5.34: IR __FUNCTION__ breakage
  2002-09-13 17:46       ` Ahmed Masud
@ 2002-09-13 18:01         ` Andreas Steinmetz
  2002-09-13 20:11         ` Thunder from the hill
  1 sibling, 0 replies; 11+ messages in thread
From: Andreas Steinmetz @ 2002-09-13 18:01 UTC (permalink / raw)
  To: Ahmed Masud; +Cc: Thunder from the hill, dag, linux-kernel

(rct@gherkin.frus.com 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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: 2.5.34: IR __FUNCTION__ breakage
  2002-09-13 17:46       ` Ahmed Masud
  2002-09-13 18:01         ` Andreas Steinmetz
@ 2002-09-13 20:11         ` Thunder from the hill
  1 sibling, 0 replies; 11+ messages in thread
From: Thunder from the hill @ 2002-09-13 20:11 UTC (permalink / raw)
  To: Ahmed Masud
  Cc: Thunder from the hill, Andreas Steinmetz, Bob_Tracy, dag, linux-kernel

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
-- 
--./../...-/. -.--/---/..-/.-./..././.-../..-. .---/..-/.../- .-
--/../-./..-/-/./--..-- ../.----./.-../.-.. --./../...-/. -.--/---/..-
.- -/---/--/---/.-./.-./---/.--/.-.-.-
--./.-/-.../.-./.././.-../.-.-.-


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: 2.5.34: IR __FUNCTION__ breakage
  2002-09-13 16:01   ` Andreas Steinmetz
  2002-09-13 16:14     ` Thunder from the hill
@ 2002-09-13 20:12     ` Neil Booth
  2002-09-13 20:30       ` Andreas Steinmetz
  1 sibling, 1 reply; 11+ messages in thread
From: Neil Booth @ 2002-09-13 20:12 UTC (permalink / raw)
  To: Andreas Steinmetz; +Cc: Thunder from the hill, Bob_Tracy, dag, linux-kernel

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.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: 2.5.34: IR __FUNCTION__ breakage
  2002-09-13 20:12     ` Neil Booth
@ 2002-09-13 20:30       ` Andreas Steinmetz
  2002-09-13 20:53         ` Thunder from the hill
  0 siblings, 1 reply; 11+ messages in thread
From: Andreas Steinmetz @ 2002-09-13 20:30 UTC (permalink / raw)
  To: Neil Booth; +Cc: Thunder from the hill, dag, linux-kernel

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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: 2.5.34: IR __FUNCTION__ breakage
  2002-09-13 20:30       ` Andreas Steinmetz
@ 2002-09-13 20:53         ` Thunder from the hill
  0 siblings, 0 replies; 11+ messages in thread
From: Thunder from the hill @ 2002-09-13 20:53 UTC (permalink / raw)
  To: Andreas Steinmetz; +Cc: Neil Booth, Thunder from the hill, dag, linux-kernel

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
-- 
--./../...-/. -.--/---/..-/.-./..././.-../..-. .---/..-/.../- .-
--/../-./..-/-/./--..-- ../.----./.-../.-.. --./../...-/. -.--/---/..-
.- -/---/--/---/.-./.-./---/.--/.-.-.-
--./.-/-.../.-./.././.-../.-.-.-


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2002-09-13 20:48 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-12 19:54 2.5.34: IR __FUNCTION__ breakage Bob_Tracy
2002-09-12 20:16 ` Thunder from the hill
2002-09-12 21:09   ` Bob_Tracy
2002-09-13 16:01   ` Andreas Steinmetz
2002-09-13 16:14     ` Thunder from the hill
2002-09-13 17:46       ` Ahmed Masud
2002-09-13 18:01         ` Andreas Steinmetz
2002-09-13 20:11         ` Thunder from the hill
2002-09-13 20:12     ` Neil Booth
2002-09-13 20:30       ` Andreas Steinmetz
2002-09-13 20:53         ` Thunder from the hill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).