[libvirt] [PATCH] build: trivial fix error: implicit declaration of function 'malloc'

Daniel P. Berrange berrange at redhat.com
Thu Nov 22 13:36:14 UTC 2012


On Thu, Nov 22, 2012 at 01:28:08PM +0100, Natanael Copa wrote:
> Fixes this error when building with -Werror on Alpine Linux:
> 
> util/processinfo.c: In function 'virProcessInfoSetAffinity':
> util/processinfo.c:52:5: error: implicit declaration of function 'malloc' [-Werror=implicit-function-declaration]
> 
> Signed-off-by: Natanael Copa <ncopa at alpinelinux.org>
> ---
>  src/util/processinfo.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/src/util/processinfo.c b/src/util/processinfo.c
> index c3648d4..b8c60eb 100644
> --- a/src/util/processinfo.c
> +++ b/src/util/processinfo.c
> @@ -21,6 +21,7 @@
>  
>  #include <config.h>
>  
> +#include <stdlib.h>
>  #include <sched.h>
>  
>  #include "processinfo.h"

Let me guess, this is a failure seen with uclibc too ? The line
that warning corresponds to is

    mask = CPU_ALLOC(numcpus);

On glibc this is defined to a function _sched_cpualloc(), hence
we don't see a warning.

If your headers are defining this in terms of malloc(), then IMHO,
the sched.h should be including stdlib.h on our behalf. IOW, I
think this is a bug in the c library headers

That all said, I'm not against adding this workaround in libvirt,
provided the c library bug is reported upstream.

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list