Messages in this thread | | | Date | Fri, 23 Jul 1999 22:14:43 +0200 | From | Andreas Bombe <> | Subject | Buggy vararg macros |
| |
GCC (more specifically its preprocessor) allows us to use vararg macros and there are a number of those used in the kernel sources. They work, but they rely on current behaviour of gcc because of missing whitespace.
Example of how it should be done: #define MY_PRINTK(fmt, args...) printk(KERN_INFO fmt , ## args)
Currently the '##' discards the characters up to a preceding macro argument, but it might change to a more clean behaviour of deleting the whole token preceding it. This would include the macro argument if there is no space between it and the comma.
Sure, there is no urgent need for a fix, but I stumbled across it looking at headers so I thought I just report it. Maybe a patch will follow soon (I realize that I volunteered anyway :-). It's some simple sed work, unless there are objections.
Problematic locations in 2.2.10:
[andreasb@storm linux-2.2]$ find -name '*.h' | xargs grep -n '[^[:space:]],[[:space:]]*##' ./drivers/net/tlan.h:48:#define TLAN_DBG(lvl, format, args...) if (debug&lvl) printk( format, ##args ); ./drivers/scsi/BusLogic.h:208: BusLogic_Message(BusLogic_AnnounceLevel, Format, ##Arguments) ./drivers/scsi/BusLogic.h:211: BusLogic_Message(BusLogic_InfoLevel, Format, ##Arguments) ./drivers/scsi/BusLogic.h:214: BusLogic_Message(BusLogic_NoticeLevel, Format, ##Arguments) ./drivers/scsi/BusLogic.h:217: BusLogic_Message(BusLogic_WarningLevel, Format, ##Arguments) ./drivers/scsi/BusLogic.h:220: BusLogic_Message(BusLogic_ErrorLevel, Format, ##Arguments) ./include/linux/kernel.h:60: printk(KERN_DEBUG fmt,##arg) ./include/linux/kernel.h:67: printk(KERN_INFO fmt,##arg) ./include/linux/ext2_fs.h:49: printk (f, ## a); \ ./include/linux/arcdevice.h:116:#define BUGMSG2(x,msg,args...) do { BUGLVL(x) printk(msg, ## args); } while (0) ./include/linux/sunrpc/debug.h:48:#define dprintk(args...) dfprintk(FACILITY, ## args) ./include/linux/coda_linux.h:101: printk(format, ## a); } \
[andreasb@storm linux-2.2]$ find -name '*.c' | xargs grep -n '[^[:space:]],[[:space:]]*##' ./arch/m68k/atari/stram.c:44:#define DPRINTK(fmt,args...) printk( fmt, ##args ) ./arch/m68k/atari/stram.c:1381:#define PRINT_PROC(fmt,args...) len += sprintf( buf+len, fmt, ##args ) ./drivers/char/nvram.c:385: *len += sprintf( buffer+*len, fmt, ##args ); \ ./drivers/scsi/aha152x.c:2971:#define SPRINTF(args...) pos += sprintf(pos, ## args) ./drivers/scsi/aha152x.c:3213:#define SPRINTF(args...) do { if(pos < buffer + length) pos += sprintf(pos, ## args); } while(0) ./drivers/scsi/NCR5380.c:884:#define SPRINTF(args...) do { if(pos < buffer + length-80) pos += sprintf(pos, ## args); } while(0) ./drivers/scsi/wd7000.c:1375:#define SPRINTF(args...) { if (pos < (buffer + length)) pos += sprintf (pos, ## args); } ./drivers/scsi/tmscsim.c:2416:#define SPRINTF(args...) pos += sprintf(pos, ## args) ./drivers/scsi/fcal.c:204:#define SPRINTF(args...) { if (pos < (buffer + length)) pos += sprintf (pos, ## args); } ./drivers/sound/wavfront.c:149: printk (KERN_DEBUG LOGNAME format, ## args); \ ./drivers/cdrom/mcdx.c:82:#define xwarn(fmt, args...) printk(KERN_WARNING MCDX " " fmt, ## args) ./drivers/cdrom/mcdx.c:85:#define xinfo(fmt, args...) printk(KERN_INFO MCDX " " fmt, ## args) ./drivers/cdrom/mcdx.c:93: { printk(KERN_DEBUG MCDX ":: " fmt, ## args); } } ./drivers/cdrom/mcdx.c:94:#define xdebug(fmt, args...) printk(KERN_DEBUG MCDX ":: " fmt, ## args) ./drivers/cdrom/cdrom.c:185: printk(KERN_INFO "cdrom: " fmt, ## args)
-- Andreas E. Bombe <andreas.bombe@munich.netsurf.de> http://home.pages.de/~andreas.bombe/ RSA 0x886663c9 30 EC 09 73 84 7B 55 83 C4 7A 91 D9 9D C5 4B B0 DSA 0x04880A44 72E5 7031 4414 2EB6 F6B4 4CBD 1181 7032 0488 0A44
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |