[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Void functions returning NULL
From: |
Tim Auckland |
Subject: |
RE: Void functions returning NULL |
Date: |
Thu, 12 Sep 2002 12:51:11 -0700 |
An example of mixing char and unsigned char is the use of the first
argument of ChecksumChanged()
prototypes.h:
int ChecksumChanged ARGLIST((char *filename, unsigned char
digest [EVP_MAX_MD_SIZE+1], int warnlevel, int refresh, char type));
cfservd.c, CompareLocalChecksum()
{ unsigned char digest[EVP_MAX_MD_SIZE+1],filename[bufsize];
...
if (ChecksumChanged(filename,digest,cfverbose,true,'m'))
...
An example of mixing void and void* is in cfservd.c:
void ExitCleanly ARGLIST((int signum));
...
signal(SIGINT,(void*)ExitCleanly);
...
Returning void and returning NULL are not the same thing. NULL is
defined in many places, but they usually boil down to '0', '0L', or
(void *)0L. None of these can legally be returned by a function
declared void.
Tim
> -----Original Message-----
> From: address@hidden [mailto:address@hidden
> Sent: Thursday, September 12, 2002 11:47 AM
> To: Tim Auckland
> Cc: address@hidden
> Subject: Re: Void functions returning NULL
>
>
>
> The HPUX compiler is especially tough on these messages. Many
> of them are caused by inconsistencies in datatypes between
> platforms. The return values were a cut and paste error that
> have no effect on the program, since the function is void.
> Mixing void and void* is potentially more serious - can you
> be specific?
>
> M
>
> On 12 Sep, Tim Auckland wrote:
> > FYI,
> >
> > I just tried to compile cfengine 2.0.4 on HP-UX 11 with HP's C
> > compiler.
> >
> > The compile failed in cfservd.c where several functions have been
> > declared "void" but contain one of more "return NULL" instructions.
> > HP's C compiler doesn't let you get away with this (and I'm not
> > surprised!).
> >
> > Commenting out the NULLs fixes the problem.
> >
> > (It still complains a lot about incorrect types where "char" and
> > "unsigned char" have been freely mixed and also "void" and "void*",
> > but those at least don't prevent compilation).
> >
> > Tim
> >
> >
> > _______________________________________________
> > Bug-cfengine mailing list
> > address@hidden
> http://mail.gnu.org/mailman/listinfo/bug-> cfengine
>
>
>
>
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Work: +47 22453272 Email: address@hidden
> Fax : +47 22453205 WWW : http://www.iu.hio.no/~mark
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
>
- RE: Void functions returning NULL,
Tim Auckland <=