[Cocci] Why some changes are not done ?

Francois-Xavier Le Bail devel.fx.lebail at orange.fr
Sat Nov 25 08:45:52 CET 2017


On 24/11/2017 19:29, Julia Lawall wrote:
> 
> 
> On Fri, 24 Nov 2017, Francois-Xavier Le Bail wrote:
> 
>> On 24/11/2017 12:35, Julia Lawall wrote:
>>>
>>>
>>> On Fri, 24 Nov 2017, Francois-Xavier Le Bail wrote:
>>>
>>>> On 24/11/2017 12:00, Julia Lawall wrote:
>>>>>
>>>>>
>>>>> On Fri, 24 Nov 2017, Francois-Xavier Le Bail wrote:
>>>>>
>>>>>> On 24/11/2017 11:23, Julia Lawall wrote:
>>>>>>> On Fri, 24 Nov 2017, Francois-Xavier Le Bail wrote:
>>>>>>>> I use the following Coccinelle script to rename some macros:
>>>>>>>> @@
>>>>>>>> expression E;
>>>>>>>> @@
>>>>>>>> (
>>>>>>>> -EXTRACT_16BITS(E)
>>>>>>>> +EXTRACT_BE_16BITS(E)
>>>>>>>> |
>>>>>>>> -EXTRACT_32BITS(E)
>>>>>>>> +EXTRACT_BE_32BITS(E)
>>>>>>>> )
>>>> The reason for this source is that the macro is defined in a function body.
>>>> Why not applying change in that case?
>>>
>>> Macros defined in function bodies are ignored.  Coccinelle works on a
>>> control-flow graph, and the #define is not part of the control-flow of the
>>> function.  Since it's not clear what to do with it, it is just skipped.
>>
>> Ok, it is clear.
>>
>> I have another macro definition case with no change, outside of all functions.
>> I got "FLOW: cant jump to trunc: because we can't find this label"
>>
>> Code:
>> #define VECOUT(MAX) { u_char *sp; \
>>                         u_char s[AFSNAMEMAX]; \
>>                         int k; \
>>                         if ((MAX) + 1 > sizeof(s)) \
>>                                 goto trunc; \
>>                         ND_TCHECK2(bp[0], (MAX) * sizeof(int32_t)); \
>>                         sp = s; \
>>                         for (k = 0; k < (MAX); k++) { \
>>                                 *sp++ = (u_char) EXTRACT_32BITS(bp); \
>>                                 bp += sizeof(int32_t); \
>>                         } \
>>                         s[(MAX)] = '\0'; \
>>                         ND_PRINT((ndo, " \"")); \
>>                         fn_print(ndo, s, NULL); \
>>                         ND_PRINT((ndo, "\"")); \
>>                 }
>>
>> Is there a solution for similar cases?
> 
> No.  It can't create a control-flow graph for the code if the goto
> destination is missing.

OK, thanks.

-- 
Francois-Xavier


More information about the Cocci mailing list