Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1694242

Re: [PATCH] EDAC: remove unnecessary static in edac_fake_inject_write()

From "Gustavo A. R. Silva" <garsilva@embeddedor.com>
Newsgroups linux.kernel
Subject Re: [PATCH] EDAC: remove unnecessary static in edac_fake_inject_write()
Date 2017-07-23 04:40 +0200
Message-ID <u6eYi-1EY-9@gated-at.bofh.it> (permalink)
References <tZEb7-5V4-9@gated-at.bofh.it> <u49T4-2FF-21@gated-at.bofh.it> <u5Mpj-Qz-3@gated-at.bofh.it> <u5WeZ-6TP-1@gated-at.bofh.it> <u65rX-4aW-15@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hi Julia, Borislav,

On 07/22/2017 11:22 AM, Gustavo A. R. Silva wrote:
> Hi all,
>
> On 07/22/2017 01:36 AM, Borislav Petkov wrote:
>> On Fri, Jul 21, 2017 at 10:08:12PM +0200, Julia Lawall wrote:
>>> Someone pointed out that the rule is probably not OK when the address of
>>> the static variable is taken, because then it is likely being used as
>>> permanent storage.
>>
>> Makes sense to me.
>>
>>> An improved rule is:
>>
>> Do you think it is worth having it in scripts/coccinelle/ ?
>>
>> I don't think Gustavo would mind putting it there :)
>>
>
> Absolutely, I'd be glad to help out. :)
>

I've been working on this issue today and, in my opinion, this script is 
even better:

@bad exists@
position p;
identifier x;
expression e;
type T;
@@

static T x@p;
... when != x = e
x = <+...x...+>

@worse1 exists@
position p;
identifier x;
type T;
@@

static T x@p;
...
return &x;

@worse2 exists@
position p;
identifier x;
type T;
@@

static T *x@p;
...
return x;

@@
identifier x;
expression e;
type T;
position p != {bad.p,worse1.p,worse2.p};
@@

-static
   T x@p;
   ... when != x
       when strict
?x = e;

It ignores all the cases in which the address of the static variable is 
returned to the caller function.

Also, there are some cases in which the maintainer can argue something 
like the following:

https://lkml.org/lkml/2017/7/19/1381

but that depends on the particular conditions in which the code is 
intended to be executed.

What do you think?

Thank you
--
Gustavo A. R. Silva

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH] EDAC: remove unnecessary static in  edac_fake_inject_write() Julia Lawall <julia.lawall@lip6.fr> - 2017-07-21 22:10 +0200
  Re: [PATCH] EDAC: remove unnecessary static in  edac_fake_inject_write() Borislav Petkov <bp@alien8.de> - 2017-07-22 08:40 +0200
    Re: [PATCH] EDAC: remove unnecessary static in  edac_fake_inject_write() Julia Lawall <julia.lawall@lip6.fr> - 2017-07-22 08:40 +0200
    Re: [PATCH] EDAC: remove unnecessary static in  edac_fake_inject_write() "Gustavo A. R. Silva" <garsilva@embeddedor.com> - 2017-07-22 18:30 +0200
      Re: [PATCH] EDAC: remove unnecessary static in  edac_fake_inject_write() "Gustavo A. R. Silva" <garsilva@embeddedor.com> - 2017-07-23 04:40 +0200
        Re: [PATCH] EDAC: remove unnecessary static in  edac_fake_inject_write() Julia Lawall <julia.lawall@lip6.fr> - 2017-07-23 07:10 +0200
          Re: [PATCH] EDAC: remove unnecessary static in  edac_fake_inject_write() "Gustavo A. R. Silva" <gustavo@embeddedor.com> - 2017-07-23 07:50 +0200
            Re: [PATCH] EDAC: remove unnecessary static in  edac_fake_inject_write() Julia Lawall <julia.lawall@lip6.fr> - 2017-07-23 08:00 +0200
              Re: [PATCH] EDAC: remove unnecessary static in  edac_fake_inject_write() "Gustavo A. R. Silva" <gustavo@embeddedor.com> - 2017-07-23 08:30 +0200
                Re: [PATCH] EDAC: remove unnecessary static in  edac_fake_inject_write() Borislav Petkov <bp@alien8.de> - 2017-07-24 12:40 +0200

csiph-web