Re: [efi:next 2/3] arch/x86/boot/compressed/eboot.c:26:16: sparse: incorrect type in return expression (different modifiers)

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

 



On Wed, Nov 19, 2014 at 12:38 AM, Ard Biesheuvel
<ard.biesheuvel@xxxxxxxxxx> wrote:
> Well, that is how sparse currently treats it, and I think that is correct.
> If an extern declaration in a .h file specifies  __pure, then GCC may
> legally emit fewer calls to that function than appear in the source.
> So if the actual implementation in the .c file is not __pure, then you
> have an error.

OK. I just want to figure out what is the right thing to do here.
It is ambiguous when the second time function declare without pure attribute,
weather it should follow the incremental declare rule or conflicting error.

If follow the C incremental declare rule, there is no error there.
It just an incomplete declare, compiler will internally merge all the
declare in the same scope and apply that to the final function.

e.g.
static __attribute__((noreturn)) void deadloop(void);

static void deadloop(void)
{
}

gcc will treat the second deadloop() function has noreturn attribute,
even though it does not have one in the second time declare.
That is why Gcc warns the function does return:
 /tmp/noreturn.c: In function 'deadloop':
/tmp/noreturn.c:6:1: warning: 'noreturn' function does return [enabled
by default]
 }

I try it on gcc, gcc does not emit error for the pure attribute conflicting.
That seems indicate gcc follow the incremental declare rule rather than
conflicting error.

Sparse has the symbol->same_symbol chain for that reason as well.
It can be used for merging different declare of the same function.
Some declare provide more detail specification, some did not.

> """
> static __attribute__((__pure__)) int pure2(void)
> {
> int i = 0;
> return i;
> }
> static int pure2(void); // error here
> """

See above. I am not sure that is an error here if we follow
the incremental declare rule.

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