Re: [PATCH] dissect: use built_in_ident() instead of MK_IDENT()

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

 



On Tue, Jun 20, 2017 at 01:17:41PM +0200, Oleg Nesterov wrote:
> On 06/19, Luc Van Oostenryck wrote:
> >
> > The motivation for this patch was to allow sparse to be
> > compiled with clang which doesn't like what is done
> > on VLAs in the MK_IDENT() macro.
> 
> could you spell please? I don't understand why clang can't compile this
> code and I am just curious.

Sure, I should have added in the commit message. Here it is:
	test-dissect.c:50:16: warning: field 'ident' with variable sized type 'struct ident' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
	                sym->ident = MK_IDENT("__asm__");
	                             ^
	./dissect.h:31:16: note: expanded from macro 'MK_IDENT'
	                struct ident ident;                     \
	                             ^
	test-dissect.c:50:25: error: initialization of flexible array member is not allowed
	                sym->ident = MK_IDENT("__asm__");
	                                      ^~~~~~~~~
	./dissect.h:35:11: note: expanded from macro 'MK_IDENT'
	                .name = s,                              \
	                        ^
	./token.h:77:7: note: initialized flexible array member 'name' is here
	        char name[];            /* Actual identifier */
	             ^
	test-dissect.c:50:14: error: assigning to 'struct ident *' from incompatible type 'void'
	                sym->ident = MK_IDENT("__asm__");
	                           ^ ~~~~~~~~~~~~~~~~~~~

I quickly looked at it and I didn't seem to be something with MK_IDENT,
just that clang doesn't like initialization of flexible array member
(I said 'VLA' in the patch but there is no VLA here).
 
> > But also, I can't see any justification for not using the
> > real thing to create identifiers: built_in_ident().
> 
> Simply because MK_IDENT() is faster and simpler to use.

I find this very weak. For the simplicity of use, in both cases
there is just a single call with the same argument, for the speed,
I really really doubt there is any measurable difference.
But what annoys me is that the macro is doing another kind
of ident (other init code, not being hashed, different lifetime),
not that it matters here though but ...

> > CC: Oleg Nesterov <oleg@xxxxxxxxxx>
> > Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
> > ---
> >  dissect.h      | 13 -------------
> >  test-dissect.c |  6 +++---
> 
> iirc there should be another MK_IDENT user in dissect.c?

No, it doesn't seem to, and the history tell that there it
never had been the case, just the three in test-dissect.c

-- Luc
--
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