All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cocci] how to find missing initializer
@ 2015-12-03 13:04 Peter Hurley
  2015-12-03 18:46 ` Lars-Peter Clausen
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Peter Hurley @ 2015-12-03 13:04 UTC (permalink / raw)
  To: cocci

Hi all,

I'm struggling with the grammar necessary to find struct definitions
missing an initializer.

The background is that many tty interfaces include a method/operations
table (named fields of function ptrs). For example, given a declaration
like,

    struct tty_operations {
            int (*install)( /* ... */ );
            int (*remove)( /* ... */ );
            void (*cleanup)( /* ... * );
    ...
    };

a tty driver might define its method table like,

    static const struct tty_operations ops = {
            .install = uart_install,
	    .remove = uart_remove,
            .cleanup = uart_cleanup,
    ...
    };


(actually, this is a common pattern throughout the kernel)

Many operations are optional; a NULL method is simply not executed.
For example,

    if (tty->ops->cleanup)
            tty->ops->cleanup(tty);

So trying to find those in-tree drivers which _do not_ define a cleanup
method with coccinelle, led to this fragment which has a parse error.

Apologies if my question is obvious or trivial; I'm still learning
coccinelle.

Regards,
Peter Hurley

--- >% ---
virtual context

@ depends on context @
identifier fops;
identifier fn;
@@
* struct tty_operations fops = {
  ... when != .cleanup = fn,
...
};

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2015-12-04 15:42 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-03 13:04 [Cocci] how to find missing initializer Peter Hurley
2015-12-03 18:46 ` Lars-Peter Clausen
2015-12-03 22:12   ` Julia Lawall
2015-12-03 23:48     ` Luis R. Rodriguez
2015-12-04 13:55       ` [Cocci] Searching with SmPL for missing clean-up settings in designated initialisers SF Markus Elfring
2015-12-04 14:44         ` Julia Lawall
2015-12-04 15:42           ` SF Markus Elfring
2015-12-04 11:31     ` [Cocci] how to find missing initializer SF Markus Elfring
2015-12-04 13:18       ` Julia Lawall
2015-12-04 11:54   ` Peter Hurley
2015-12-03 19:26 ` Luis R. Rodriguez
2015-12-04  8:55 ` SF Markus Elfring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.