Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 8 Oct 2004 10:29:05 -0500
From:      Dan Nelson <dnelson@allantgroup.com>
To:        Andreas Klemm <andreas@klemm.apsfilter.org>
Cc:        "Jonathan A. Zdziarski" <jonathan@nuclearelephant.com>
Subject:   Re: please help with: warning: initialization makes integer from pointer
Message-ID:  <20041008152905.GA3106@dan.emsphone.com>
In-Reply-To: <20041007174322.GB3414@titan.klemm.apsfilter.org>
References:  <20041005054213.GA11770@lesanti.hq.sinectis.com.ar> <416234B1.8020406@nuclearelephant.com> <20041005202816.GA14973@titan.klemm.apsfilter.org> <20041005205040.GH31397@lesanti.hq.sinectis.com.ar> <20041006060437.GA23364@titan.klemm.apsfilter.org> <20041006144220.GA29653@lesanti.hq.sinectis.com.ar> <20041007111139.GA16296@titan.klemm.apsfilter.org> <416579E1.8050308@nuclearelephant.com> <20041007174322.GB3414@titan.klemm.apsfilter.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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@allantgroup.com



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20041008152905.GA3106>