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.
Signature · 4 lines
----------------------------------------------------------------------- Bob Tracy WTO + WIPO = DMCA? http://www.anti-dmca.org [email protected] -----------------------------------------------------------------------
Hi,
Quoted 7 lines · Bob_Tracy
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
Signature · 4 lines
--./../...-/. -.--/---/..-/.-./..././.-../..-. .---/..-/.../- .- --/../-./..-/-/./--..-- ../.----./.-../.-.. --./../...-/. -.--/---/..- .- -/---/--/---/.-./.-./---/.--/.-.-.- --./.-/-.../.-./.././.-../.-.-.-
Quoted 1 line · Thunder from the hill
(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 :-).
Signature · 4 lines
----------------------------------------------------------------------- Bob Tracy WTO + WIPO = DMCA? http://www.anti-dmca.org [email protected] -----------------------------------------------------------------------
Quoted 15 lines · Thunder from the hill
Hi,
Quoted 7 lines · Bob_Tracy
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
Quoted 8 lines
#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.
Signature · 2 lines
Andreas Steinmetz D.O.M. Datenverarbeitung GmbH
Hi,
Quoted 8 lines · Andreas Steinmetz
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
Signature · 4 lines
--./../...-/. -.--/---/..-/.-./..././.-../..-. .---/..-/.../- .- --/../-./..-/-/./--..-- ../.----./.-../.-.. --./../...-/. -.--/---/..- .- -/---/--/---/.-./.-./---/.--/.-.-.- --./.-/-.../.-./.././.-../.-.-.-
Quoted 11 lines · Thunder from the hill
Hi,
Quoted 7 lines · Andreas Steinmetz
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)
([email protected] removed from cc list as his mta treats (not only) my mails as spam...)
Quoted 13 lines · Ahmed Masud
Quoted 11 lines · Thunder from the hill
Hi,
Quoted 7 lines · Andreas Steinmetz
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)
Quoted 10 lines
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.
Signature · 2 lines
Andreas Steinmetz D.O.M. Datenverarbeitung GmbH
Hi,
Quoted 6 lines · Ahmed Masud
#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
Signature · 4 lines
--./../...-/. -.--/---/..-/.-./..././.-../..-. .---/..-/.../- .- --/../-./..-/-/./--..-- ../.----./.-../.-.. --./../...-/. -.--/---/..- .- -/---/--/---/.-./.-./---/.--/.-.-.- --./.-/-.../.-./.././.-../.-.-.-
Andreas Steinmetz wrote:-
Quoted 8 lines
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.
Quoted 10 lines · Neil Booth
Andreas Steinmetz wrote:-
Quoted 7 lines
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)
Quoted 8 lines
Quoted 1 line
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.
Signature · 2 lines
Andreas Steinmetz D.O.M. Datenverarbeitung GmbH
Hi,
Quoted 4 lines · Andreas Steinmetz
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
Signature · 4 lines
--./../...-/. -.--/---/..-/.-./..././.-../..-. .---/..-/.../- .- --/../-./..-/-/./--..-- ../.----./.-../.-.. --./../...-/. -.--/---/..- .- -/---/--/---/.-./.-./---/.--/.-.-.- --./.-/-.../.-./.././.-../.-.-.-