Skip to contentSkip to conversation

Q: does spatch understand g_autoptr/g_autofree?

Cocci Pan Nengyuan 2 participants 3 messages Feb 7, 2020

lore
Share & tools
lore
#0 lore raw

Hello,

I have an example:

@@ expression d,p; @@

- g_autoptr(d) p;
+ g_autoptr(d) p = NULL;

C source code:

    void f(void)
    {
        g_autoptr(Test) *p1;
    }

Then I got this error:
minus: parse error:
File "test.cocci", line 3, column 15, charpos = 38 around = 'p',
whole content = - g_autoptr(d) p;

is it correct?
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

#1 lore raw
Quoted 16 lines · Pan Nengyuan

Hello,

I have an example:

@@ expression d,p; @@

- g_autoptr(d) p;
+ g_autoptr(d) p = NULL;

C source code:

    void f(void)
    {
        g_autoptr(Test) *p1;
    }
Quoted 8 lines

Then I got this error:
minus: parse error:
File "test.cocci", line 3, column 15, charpos = 38 around = 'p',
whole content = - g_autoptr(d) p;

is it correct?

No, Coccinelle knows nothing about these things. If you don't care about the types of these variables, you can extend standard.h to say

#define g_autoptr(x) int

julia
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

#2 lore raw
Quoted 27 lines · Julia Lawall
Quoted 23 lines · Pan Nengyuan

Hello,

I have an example:

@@ expression d,p; @@

- g_autoptr(d) p;
+ g_autoptr(d) p = NULL;

C source code:

    void f(void)
    {
        g_autoptr(Test) *p1;
    }

Then I got this error:
minus: parse error:
File "test.cocci", line 3, column 15, charpos = 38 around = 'p',
whole content = - g_autoptr(d) p;

Quoted 6 lines
Quoted 1 line

is it correct?

No, Coccinelle knows nothing about these things. If you don't care about the types of these variables, you can extend standard.h to say

#define g_autoptr(x) int

OK, thanks. I will try it.

Quoted 4 lines

julia
.

_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci