please help with: warning: initialization makes integer from pointer

Dan Nelson dnelson at allantgroup.com
Fri Oct 8 08:29:06 PDT 2004


In the last episode (Oct 07), Andreas Klemm said:
> Dear FreeBSD hackers,
> 
> could somebody please help Jonathan, the dspam owner, how to code
> this best under FreeBSD ?
> 
> Please see his question below:
> 
> On Thu, Oct 07, 2004 at 01:16:17PM -0400, Jonathan A. Zdziarski wrote:
> > I'm a little concerned about these warnings:
> > 
> > pgsql_drv.c:873: warning: initialization makes integer from pointer without a cast
> > pgsql_drv.c:874: warning: initialization makes integer from pointer without a cast
> > 
> > This could cause some problems with dspam. Is there a freeBSDish way to 
> > do this:
> > 
> >   s->p_getpwnam = (struct passwd) { NULL, NULL, 0, 0, NULL, NULL, NULL };
> >   s->p_getpwuid = (struct passwd) { NULL, NULL, 0, 0, NULL, NULL, NULL };
> > 
> > Perhaps memset(s->p_getpwnam, 0, sizeof(struct passwd)) ?

Yes, memset would be much more portable.  I don't think there is any
standard that says how many fields struct passwd has, or if they must
be in any order.  POSIX names only 5 required fields and no order.

You could use designated initialization, but that's a C99 feature, and
since you're initializing everything to zero anyway, memset is still
better.

-- 
	Dan Nelson
	dnelson at allantgroup.com


More information about the freebsd-hackers mailing list