[LTP] [PATCH 1/1] syscalls, lib: Use SAFE_{BIND, LISTEN, SOCKET} macros

Richard Palethorpe rpalethorpe@suse.de
Mon Oct 2 16:51:52 CEST 2017


Hello,

Petr Vorel writes:

> Hi Richard, Cyril,
>
>> Hello Petr,
>
>> > Patch was made thanks to Coccinelle.
>> Very good. Also how about including the Coccinelle patch in the tools or
>> scripts folder?
>
> Cyril, do you like this idea?
>
> Well, I'm not much proud on that script, it's my first Coccinelle
> script :-)

It is more advanced than the one I created to do something similar.

>
> @test_h@
> @@
> #include "test.h"
>
> @tst_test_h@
> @@
> #include "tst_test.h"
>
> // test.h does not include safe_macros.h
> @safe_macros_h@
> @@
> #include "safe_macros.h"
>
> @is_safe_socket@
> @@
> int safe_socket(...) {...}
>
> // SAFE_BIND
> @old_safe_bind depends on test_h@
> expression sockfd, sockaddr, addrlen;
> identifier cleanup_fn;
> expression e, x;
> constant TFAIL;
> @@
> -if (bind(sockfd, sockaddr, addrlen) < 0) {
> -	tst_brkm(e, cleanup_fn, ...);
> (
> -	return -1;
> |
> )
> 	... when != x & TFAIL

What does the last line do? I am guessing it prevents the substitution
if it finds TFAIL anywhere in the above expression.

-- 
Thank you,
Richard.


More information about the ltp mailing list