unable to find function definition
Silvan Jegen
me at sillymon.ch
Tue Apr 26 11:33:43 EDT 2016
On Tue, Apr 26, 2016 at 11:24:43AM -0400, Valdis.Kletnieks at vt.edu wrote:
> 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
Good idea!
There may also be cases where there is no space before the assignment so
using a regexp like this may be better.
grep 'function_pointer ?='
> 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.
True, this was mostly muscle memory.
> And another winner if you have a git tree (which of course you should):
>
> git grep 'function_pointer ='
Looks useful but I hope they did not implement their own version of
grep...
> 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...)
Yeah, I don't think there is much you can do about these cases...
Cheers,
Silvan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20160426/ba81f255/attachment.bin
More information about the Kernelnewbies
mailing list