From: Valdis.Kletnieks@vt.edu (Valdis.Kletnieks at vt.edu) Date: Tue, 26 Apr 2016 11:24:43 -0400 Subject: unable to find function definition In-Reply-To: <37971c0991ed34ec1d07ab6cc5851ff4@sillymon.ch> References: <20160420072625.GA27201@portege.ulakbim.gov.tr> <2cab8174b247724af07b444437ee423c@sillymon.ch> <37971c0991ed34ec1d07ab6cc5851ff4@sillymon.ch> Message-ID: <5613.1461684283@turing-police.cc.vt.edu> To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org On Tue, 26 Apr 2016 15:31:51 +0200, Silvan Jegen said: > A simple but naive approach would be a grep command like this. > > grep "function_pointer =" `find . -iname '*.c' -o -iname '*.h'` Two better ways: grep -r "function_pointer =' [A-Za-z]* find * -name '*.[ch]' | xargs grep 'function pointer =' Hint 1: Globbing * rather than . is a win at the top level of the kernel source, because * won't match .git, which is a gigabyte or so of stuff that you don't want to grep through Hint 2: You want -name rather than -iname because there shouldn't be any *.C or *.H files in the tree, and avoiding case-insensitive matches is a bit faster. And another winner if you have a git tree (which of course you should): git grep 'function_pointer =' One gotcha is that in some places, the kernel does evil pre-processor stuff like: #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i) #define ATOMIC_LONG_PFX(x) atomic ## x #endif #define ATOMIC_LONG_READ_OP(mo) static inline long atomic_long_read##mo(const atomic_long_t *l) { ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; return (long)ATOMIC_LONG_PFX(_read##mo)(v); } ATOMIC_LONG_READ_OP() ATOMIC_LONG_READ_OP(_acquire) (this example from include/asm-generic/atomic-long.h, but similar ## abuse happens elsewhere as well...) -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 848 bytes Desc: not available Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20160426/6af6fd75/attachment-0001.bin