Re: [PATCH 2/6] parse: initial parsing of __attribute__((format))

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

 



On Thu, Apr 04, 2019 at 10:53:08AM +0100, Ben Dooks wrote:
> On 03/04/2019 21:46, Luc Van Oostenryck wrote:
> > On Wed, Apr 03, 2019 at 04:35:48PM +0100, Ben Dooks wrote:
> > > @@ -2981,8 +3071,18 @@ struct token *external_declaration(struct token *token, struct symbol_list **lis
> > >   		if (!(decl->ctype.modifiers & MOD_STATIC))
> > >   			decl->ctype.modifiers |= MOD_EXTERN;
> > > +
> > > +		base_type->ctype.printf_msg = decl->ctype.printf_msg;
> > > +		base_type->ctype.printf_va_start = decl->ctype.printf_va_start;
> > >   	} else if (base_type == &void_ctype && !(decl->ctype.modifiers & MOD_EXTERN)) {
> > >   		sparse_error(token->pos, "void declaration");
> > > +	} else if (base_type && base_type->type == SYM_PTR) {
> > > +		// think this is correct to do //
> > > +		struct symbol *ptr_base = get_base_type(base_type);
> > > +		if (ptr_base) {
> > > +			ptr_base->ctype.printf_msg = decl->ctype.printf_msg;
> > > +			ptr_base->ctype.printf_va_start = decl->ctype.printf_va_start;
> > > +		}
> > 
> > I'll need to check this.
> > What situation is this supposed to cover?
> 
> definition of pointers to functions, ie:
> 
> 	int (*ptr)(args..) __attribute__((format...));

But this is not the correct syntax as it applies the attribute
to the declared object 'ptr', a pointer type and not to the
underlying function type.

The syntax used in the kernel is (cfr. kdb_printf_t):
	__attribute__((...)) int (*ptr)(args...);
and GCC's manual also specifies:
	int (__attribute__((...)) *ptr)(args...);
(but I'm not sure this one is correctly supported by sparse).

It would be good to issue a warning if the 'format' attribute is
applied to anything that is not a function type.

-- Luc



[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