Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1676266
| From | Kees Cook <keescook@chromium.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 8/9] clocksource/drivers/fttmr010: Drop unnecessary static |
| Date | 2017-06-28 01:50 +0200 |
| Message-ID | <tX8p3-7z8-9@gated-at.bofh.it> (permalink) |
| References | <tDvHz-8tt-5@gated-at.bofh.it> <tDvHz-8tt-19@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Thu, May 4, 2017 at 1:10 PM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
> Drop static on a local variable, when the variable is initialized before
> any use, on every possible execution path through the function. The static
> has no benefit, and dropping it reduces the code size.
>
> The semantic patch that fixes this problem is as follows:
> (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @bad exists@
> position p;
> identifier x;
> type T;
> @@
>
> static T x@p;
> ...
> x = <+...x...+>
>
> @@
> identifier x;
> expression e;
> type T;
> position p != bad.p;
> @@
>
> -static
> T x@p;
> ... when != x
> when strict
> ?x = e;
> // </smpl>
>
> The change in code size is indicates by the following output from the size
> command.
>
> before:
> text data bss dec hex filename
> 1777 4352 20 6149 1805 drivers/clocksource/timer-fttmr010.o
>
> after:
> text data bss dec hex filename
> 1770 4352 12 6134 17f6 drivers/clocksource/timer-fttmr010.o
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
>
> ---
> drivers/clocksource/timer-fttmr010.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/clocksource/timer-fttmr010.c b/drivers/clocksource/timer-fttmr010.c
> index b4a6f1e..055c65e 100644
> --- a/drivers/clocksource/timer-fttmr010.c
> +++ b/drivers/clocksource/timer-fttmr010.c
> @@ -263,7 +263,7 @@ static int __init fttmr010_timer_of_init(struct device_node *np)
>
> static int __init gemini_timer_of_init(struct device_node *np)
> {
> - static struct regmap *map;
> + struct regmap *map;
> int ret;
> u32 val;
>
>
Acked-by: Kees Cook <keescook@chromium.org>
Kernel janitors or Andrew, can you pick this up?
Thanks!
-Kees
--
Kees Cook
Pixel Security
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
Re: [PATCH 8/9] clocksource/drivers/fttmr010: Drop unnecessary static Kees Cook <keescook@chromium.org> - 2017-06-28 01:50 +0200
csiph-web