On 09/22/10 12:13, Julia Lawall wrote:
> ... If you transform the definition, it will
> automatically make an extra rule for transforming the prototype.
This behavior is not what I observed. A defn-xform alone didn't handle
the decls and I needed to add explicit decl-xform rules to catch all cases.
Even then, some matches mysteriously failed.
$ spatch -sp_file ioctl.cocci include/linux/fs.h
init_defs_builtins: /usr/share/coccinelle/standard.h
HANDLING: include/linux/fs.h
diff =
--- include/linux/fs.h 2010-09-22 08:09:25.796824300 -0700
+++ /var/tmp/cocci-output-12082-b6c304-fs.h 2010-09-22 12:23:41.320949192
-0700
@@ -1990,9 +1990,9 @@ extern const struct file_operations def_
extern const struct file_operations bad_sock_fops;
extern const struct file_operations def_fifo_fops;
#ifdef CONFIG_BLOCK
-extern int ioctl_by_bdev(struct block_device *, unsigned, unsigned long);
-extern int blkdev_ioctl(struct block_device *, fmode_t, unsigned, unsigned
long);
-extern long compat_blkdev_ioctl(struct file *, unsigned, unsigned long);
+extern int ioctl_by_bdev(struct block_device *, unsigned, uintptr_t);
+extern int blkdev_ioctl(struct block_device *, fmode_t, unsigned, uintptr_t);
+extern int compat_blkdev_ioctl(struct file *, unsigned, uintptr_t);
extern int blkdev_get(struct block_device *, fmode_t);
extern int blkdev_put(struct block_device *, fmode_t);
extern int bd_claim(struct block_device *, void *);
These all look good, but are incomplete. This one didn't match:
$ egrep -1 do_vfs_ioctl include/linux/fs.h
extern int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd,
unsigned long arg);
Why no match for do_vfs_ioctl ??
---------------- ioctl.cocci ----------------
@ioctl_decl_type@
identifier ioctl ~= ".*ioctl.*";
type T;
@@
- T
+ int
ioctl (...);
@ioctl_defn_type@
identifier ioctl ~= ".*ioctl.*";
type T;
@@
- T
+ int
ioctl (...) { ... }
@ioctl_decl_arg@
identifier ioctl ~= ".*ioctl.*";
type T;
identifier arg;
@@
T
ioctl (...,
- unsigned long
+ uintptr_t
arg) { ... }
@ioctl_decl_anon@
identifier ioctl ~= ".*ioctl.*";
type T;
@@
T
ioctl (...,
- unsigned long
+ uintptr_t
);
---------------- snip snip ----------------
Another thing. How do I change the decls that appear as function-pointer
members in structs?
struct file_operations {
...
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
...
};
One final thing:
Is there a way to do name substitution? I need to do s/unlocked_ioctl/ioctl/
on both the function-pointer-member decls and on any function named
foo_unlocked_ioctl.
Thanks a ton!
G
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)