On Thu, 27 Sep 2007, Vegard Nossum wrote:If-blocks spanning macros are really dangerous! E.g. an Ethernet driver may want to do: kprint_block(&block, "MAC "); for (i = 0; i < 6; i++) { card->mac[i] = obtain_mac_byte_from_hw(i); kprint_block(&block, "%02x", card->mac[i]); } This looks (and should be) innocent, but the actual MAC addres retrieval would never be executed if loglevel <= CONFIG_KPRINT_LOGLEVEL_MAX. Can't you store the loglevel in the kprint_block and check it in all successive kprint_*() macros? If gcc knows it's constant, it can optimize the non-wanted code away. As other fields in struct kprint_block cannot be constant (they store internal state), you have to split it like: struct kprint_block { int loglevel; struct real_kprint_block real; /* internal state */ } and pass &block.real() instead of &block to all successive internal functions. I haven't tried this, so let's hope gcc is actually smart enough... Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds -
| Greg KH | [GIT PATCH] driver core patches against 2.6.24 |
| debian developer | Re: Dual-Licensing Linux Kernel with GPL V2 and GPL V3 |
| Vu Pham | Re: [Scst-devel] Integration of SCST in the mainstream Linux kernel |
| Adrian Bunk | Re: Linux 2.6.21 |
git: | |
| Gerrit Renker | [PATCH 15/37] dccp: Set per-connection CCIDs via socket options |
| Jarek Poplawski | [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| Radu Rendec | Endianness problem with u32 classifier hash masks |
| Benjamin Herrenschmidt | [PATCH 0/11] ibm_newemac: Candidate patches for 2.6.25 |
