Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

extract and use FILE_LINE macro

Extract nifty FILE_LINE useful for printk style debugging:

printk("%s\n", FILE_LINE);

It should not be used en mass probably because __FILE__ string literals
can be merged while FILE_LINE's won't. But for debugging it is what
the doctor ordered.

Don't add leading and trailing underscores, they're painful to type.
Trust me, I've tried both versions.

Link: https://lkml.kernel.org/r/ebf12ac4-5a61-4b12-b8b0-1253eb371332@p183
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Takashi Iwai <tiwai@suse.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Alexey Dobriyan and committed by
Andrew Morton
5097a69d c37e56ca

+8 -8
+1 -1
include/linux/fortify-string.h
··· 643 643 __q_size_field, #op), \ 644 644 #op ": detected field-spanning write (size %zu) of single %s (size %zu)\n", \ 645 645 __fortify_size, \ 646 - "field \"" #p "\" at " __FILE__ ":" __stringify(__LINE__), \ 646 + "field \"" #p "\" at " FILE_LINE, \ 647 647 __p_size_field); \ 648 648 __underlying_##op(p, q, __fortify_size); \ 649 649 })
+2
include/linux/stringify.h
··· 9 9 #define __stringify_1(x...) #x 10 10 #define __stringify(x...) __stringify_1(x) 11 11 12 + #define FILE_LINE __FILE__ ":" __stringify(__LINE__) 13 + 12 14 #endif /* !__LINUX_STRINGIFY_H */
+1 -2
include/linux/timer.h
··· 77 77 .entry = { .next = TIMER_ENTRY_STATIC }, \ 78 78 .function = (_function), \ 79 79 .flags = (_flags), \ 80 - __TIMER_LOCKDEP_MAP_INITIALIZER( \ 81 - __FILE__ ":" __stringify(__LINE__)) \ 80 + __TIMER_LOCKDEP_MAP_INITIALIZER(FILE_LINE) \ 82 81 } 83 82 84 83 #define DEFINE_TIMER(_name, _function) \
+4 -5
sound/pci/asihpi/hpidebug.h
··· 29 29 the start of each message, eg see linux kernel hpios.h */ 30 30 31 31 #ifdef SOURCEFILE_NAME 32 + #undef FILE_LINE 32 33 #define FILE_LINE SOURCEFILE_NAME ":" __stringify(__LINE__) " " 33 - #else 34 - #define FILE_LINE __FILE__ ":" __stringify(__LINE__) " " 35 34 #endif 36 35 37 36 #define HPI_DEBUG_ASSERT(expression) \ 38 37 do { \ 39 38 if (!(expression)) { \ 40 39 printk(KERN_ERR FILE_LINE \ 41 - "ASSERT " __stringify(expression)); \ 40 + " ASSERT " __stringify(expression)); \ 42 41 } \ 43 42 } while (0) 44 43 ··· 45 46 do { \ 46 47 if (hpi_debug_level >= HPI_DEBUG_LEVEL_##level) { \ 47 48 printk(HPI_DEBUG_FLAG_##level \ 48 - FILE_LINE __VA_ARGS__); \ 49 + FILE_LINE " " __VA_ARGS__); \ 49 50 } \ 50 51 } while (0) 51 52 ··· 69 70 do { \ 70 71 if (hpi_debug_level >= HPI_DEBUG_LEVEL_##level) { \ 71 72 hpi_debug_message(phm, HPI_DEBUG_FLAG_##level \ 72 - FILE_LINE __stringify(level)); \ 73 + FILE_LINE " " __stringify(level)); \ 73 74 } \ 74 75 } while (0) 75 76