[splint-discuss] Tell me more about @only@

Michael Wojcik Michael.Wojcik at microfocus.com
Thu Jan 14 14:18:56 PST 2010


> From: splint-discuss-bounces at cs.virginia.edu [mailto:splint-discuss-
> bounces at cs.virginia.edu] On Behalf Of Bill Pringlemeir
> Sent: Thursday, 14 January, 2010 13:06
> 
> On 14 Jan 2010, Michael.Wojcik at microfocus.com wrote:
> 
> > The best way to initialize a new dynamically-allocated structure is
> > with structure copy, from a static, const structure that's
implicitly
> > initialized correctly.
> 
> I doubt there is a 'best' way.  'best' always depend on your metrics.
> If you chose to explicitly initialize each element,
> 
>    p->a = 11;
>    p->c = 22;
>    /* etc... */
> 
> Then splint *will warn* if values are not initialized.

True enough. I should have written "a better way". As you say, explicit
field-by-field initialization has its advantages (and drawbacks).

Mostly I'd like to see C coders get away from memset (for initializing
arbitrary structures) and calloc, which are relics of a bygone era.

-- 
Michael Wojcik
Principal Software Systems Developer, Micro Focus




More information about the splint-discuss mailing list