Skip to contentSkip to conversation

prinkt specifiers

Cocci Tobin C. Harding 2 participants 3 messages Oct 11, 2017 – Oct 12, 2017

lore
Share & tools
lore
#0 lore raw

Hi,

Is it possible to craft a coccinelle script to find and replace calls (in the kernel) that are printing pointers using %x.

Perhaps we could easily catch the calls that are casting the pointer within argument list, for example

	pr_info("x: %llx\n", (unsigned long long int)ptr);

I'm happy to try and work out how to do it, just chasing a 'yes that is exactly the type of thing cocci is good at' or a 'no, you are dreaming, perhaps <this tool> can do that'

thanks,
Tobin.

#1 lore raw
Quoted 11 lines · Tobin C. Harding

Hi,

Is it possible to craft a coccinelle script to find and replace calls (in the kernel) that are printing pointers using %x.

Perhaps we could easily catch the calls that are casting the pointer within argument list, for example

	pr_info("x: %llx\n", (unsigned long long int)ptr);

I'm happy to try and work out how to do it, just chasing a 'yes that is exactly the type of thing cocci is good at' or a 'no, you are dreaming, perhaps <this tool> can do that'

It's possible. Look at coccinelle/demos/format.cocci

This may not be the most well tested part of Coccinelle, so if it is not doing what you expect, please feel free to complain.

julia

#2 lore raw
Quoted 16 lines · Julia Lawall
Quoted 11 lines · Tobin C. Harding

Hi,

Is it possible to craft a coccinelle script to find and replace calls (in the kernel) that are printing pointers using %x.

Perhaps we could easily catch the calls that are casting the pointer within argument list, for example

	pr_info("x: %llx\n", (unsigned long long int)ptr);

I'm happy to try and work out how to do it, just chasing a 'yes that is exactly the type of thing cocci is good at' or a 'no, you are dreaming, perhaps <this tool> can do that'

Quoted 6 lines

It's possible. Look at coccinelle/demos/format.cocci

This may not be the most well tested part of Coccinelle, so if it is not doing what you expect, please feel free to complain.

julia

Thanks Julia