Re: [PATCH v3 6/7] make process_decl() aware of the presence of an initializer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Feb 28, 2017 at 6:04 PM, Luc Van Oostenryck
<luc.vanoostenryck@xxxxxxxxx> wrote:


> @@ -2896,7 +2896,9 @@ static struct token *external_decl(struct token *token, process_decl_t process_d
>         }
>
>         for (;;) {
> +               int has_init = 0;
>                 if (!is_typedef && match_op(token, '=')) {
> +                       has_init = 1;

This can be written as:

int has_init = !is_typedef && match_op(token, '=');
if (has_init) {
     ....

>                         if (decl->ctype.modifiers & MOD_EXTERN) {
>                                 warning(decl->pos, "symbol with external linkage has initializer");
>                                 decl->ctype.modifiers &= ~MOD_EXTERN;
> @@ -2904,7 +2906,7 @@ static struct token *external_decl(struct token *token, process_decl_t process_d
>                         token = initializer(&decl->initializer, token->next);
>                 }
>                 if (!is_typedef)
> -                       process_decl(list, decl);
> +                       process_decl(list, decl, has_init);

My comment regarding patch 5/7 still stands valid here. If you keep the common
logic here, move the code from "default_process_decl" body back to here.
You can avoid passing has_init into process_decl at all.

Passing the "has_init" into a call back function make the code hard to
read because the logic has separated into two function. At the same time
process_for_loop_decl does not issue this warning at all, I think it should.

I will apply this patch for sparse-next, I agree the warning is useful
behavior. I am also expecting a follow up patch.

Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux