[Openswan dev] warning? (fwd)
Paul Wouters
paul at xelerance.com
Mon Jan 25 14:48:00 EST 2010
From: D. Hugh Redelmeier <hugh at mimosa.com>
> | From: Paul Wouters <paul at xelerance.com>
>
> | void *
> | pluto_helper_thread(void *w) {
> | struct pluto_crypto_worker *helper;
> | helper=(struct pluto_crypto_worker *)w;
> | pluto_crypto_helper(helper->pcw_helper_pipe, helper->pcw_helpernum);
> | + return NULL;
> | }
> |
> |
> | Does that make any sense? Isn't not returning a value the same as void?
>
> Yes, it makes sense.
>
> "void" is nothing (informally).
>
> "void *" is literally a pointer to nothing. But a C convention, wired
> into the standard, is that void * is the type of a pointer to any
> object (i.e. anything but a function).
>
> I don't know the code. But it begs the question: what should be
> returned. NULL is of the right type. Was anything in particular
> expected of the the result?
>
> Summary: yes, this should fix a warning. The warning might be a
> symptom: you didn't return what was needed/expected. NULL may or may
> not be what was needed/expected.
It seems that pthread_create() wants a (void *)
int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
void *(*start_routine) (void *), void *arg);
Since pluto_helper_thread() is used as the 3rd arg in pthread_create(), I guess
we are stuck with (void *) and the somewhat ugly "return NULL" ?
Paul
More information about the Dev
mailing list