[CRIU] [PATCH] zdtm: fix compile errors of zdtm_ct

Ruslan Kuprieiev kupruser at gmail.com
Tue Aug 19 06:39:13 PDT 2014


19.08.2014 14:49, Andrey Vagin пишет:
> When "make test" is executed, CFLAGS is exported from the root Makefile.
> These flags define _GNU_SOURCE, so we don't need to define it in the
> souce file.
> 
> In addition unistd.h isn't included, so a few functions are shown as undeclared.
> 
> make zdtm_ns
> make[3]: Entering directory `/root/criu/test'
> gcc  -O2 -Wall -Werror -DCONFIG_X86_64 -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE    zdtm_ct.c   -o zdtm_ct
> zdtm_ct.c:1:0: error: "_GNU_SOURCE" redefined [-Werror]
>  #define _GNU_SOURCE
>  ^
> <command-line>:0:0: note: this is the location of the previous definition
> zdtm_ct.c: In function ‘main’:
> zdtm_ct.c:21:2: error: implicit declaration of function ‘fork’ [-Werror=implicit-function-declaration]
>   pid = fork();
>   ^
> zdtm_ct.c:23:3: error: implicit declaration of function ‘setsid’ [-Werror=implicit-function-declaration]
>    if (setsid() == -1) {
>    ^
> zdtm_ct.c:49:3: error: implicit declaration of function ‘execv’ [-Werror=implicit-function-declaration]
>    execv(argv[1], argv + 1);
>    ^
> zdtm_ct.c:62:3: error: implicit declaration of function ‘getpid’ [-Werror=implicit-function-declaration]
>    kill(getpid(), WTERMSIG(status));
>    ^
> cc1: all warnings being treated as errors
> 
> Signed-off-by: Andrey Vagin <avagin at openvz.org>
> ---
>  test/Makefile  | 1 +
>  test/zdtm_ct.c | 2 +-
>  2 files changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/test/Makefile b/test/Makefile
> index 9dcc523..ed8c34b 100644
> --- a/test/Makefile
> +++ b/test/Makefile
> @@ -28,6 +28,7 @@ fault-injection: .FORCE
>  zdtm_ns: $(shell echo "$(TST)" | tr ' ' '\n' | grep -P $(EXP))
>  zdtm_nons: $(shell echo "$(TST)" | tr ' ' '\n' | grep -vP $(EXP))
>  
> +override CFLAGS += -D_GNU_SOURCE

Why do we need this? 
It works perfectly to me without this line.
We allready have
DEFINES += -D_GNU_SOURCE
at Makefile.

>  zdtm_ct: zdtm_ct.c
>  
>  clean:
> diff --git a/test/zdtm_ct.c b/test/zdtm_ct.c
> index 1374f78..3471655 100644
> --- a/test/zdtm_ct.c
> +++ b/test/zdtm_ct.c
> @@ -1,10 +1,10 @@
> -#define _GNU_SOURCE
>  #include <sched.h>
>  #include <sys/types.h>
>  #include <sys/wait.h>
>  #include <stdlib.h>
>  #include <stdio.h>
>  #include <sys/mount.h>
> +#include <unistd.h>
>  
>  int main(int argc, char **argv)
>  {
> 



More information about the CRIU mailing list