The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/6325
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com>
From 21bb74017ad164233897022e8e286da5e8b722d0 Mon Sep 17 00:00:00 2001 From: Christian Brauner <christian.brau...@ubuntu.com> Date: Mon, 21 Oct 2019 18:35:19 +0200 Subject: [PATCH] tree-wide: handle _GNU_SOURCE ifdefs correctly Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com> --- lxd-p2c/setns.go | 4 +++- lxd/include/compiler.h | 2 -- lxd/main_checkfeature.go | 4 +++- lxd/main_forkdns.go | 4 +++- lxd/main_forkfile.go | 4 +++- lxd/main_forkmount.go | 4 +++- lxd/main_forknet.go | 4 +++- lxd/main_forkproxy.go | 4 +++- lxd/main_forkuevent.go | 5 +++-- lxd/main_nsexec.go | 7 +++++-- lxd/storage/storage_cgo.go | 4 +++- lxd/ucred/ucred_gccgo.go | 4 +++- shared/idmap/shift_linux.go | 4 +++- shared/util_linux_cgo.go | 2 ++ 14 files changed, 40 insertions(+), 16 deletions(-) diff --git a/lxd-p2c/setns.go b/lxd-p2c/setns.go index 7d82162574..8d24b1a85f 100644 --- a/lxd-p2c/setns.go +++ b/lxd-p2c/setns.go @@ -1,7 +1,9 @@ package main /* -#define _GNU_SOURCE +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif #include <errno.h> #include <sched.h> #include <stdio.h> diff --git a/lxd/include/compiler.h b/lxd/include/compiler.h index 2be62d6eb3..3ed8222caf 100644 --- a/lxd/include/compiler.h +++ b/lxd/include/compiler.h @@ -25,8 +25,6 @@ #define _GNU_SOURCE 1 #endif -#include "config.h" - #ifndef thread_local #if __STDC_VERSION__ >= 201112L && \ !(defined(__STDC_NO_THREADS__) || \ diff --git a/lxd/main_checkfeature.go b/lxd/main_checkfeature.go index 65797c9477..f797290b93 100644 --- a/lxd/main_checkfeature.go +++ b/lxd/main_checkfeature.go @@ -7,7 +7,9 @@ import ( /* #cgo CFLAGS: -std=gnu11 -Wvla -I ./include -I ../shared/netutils -#define _GNU_SOURCE +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif #include <errno.h> #include <fcntl.h> #include <linux/kcmp.h> diff --git a/lxd/main_forkdns.go b/lxd/main_forkdns.go index 7a6833a174..6ab83c4ea4 100644 --- a/lxd/main_forkdns.go +++ b/lxd/main_forkdns.go @@ -21,7 +21,9 @@ import ( ) /* -#define _GNU_SOURCE +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif #include <errno.h> #include <fcntl.h> #include <stdbool.h> diff --git a/lxd/main_forkfile.go b/lxd/main_forkfile.go index e9f74e1bbf..16dfd0f2c9 100644 --- a/lxd/main_forkfile.go +++ b/lxd/main_forkfile.go @@ -7,7 +7,9 @@ import ( ) /* -#define _GNU_SOURCE +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif #include <dirent.h> #include <errno.h> #include <fcntl.h> diff --git a/lxd/main_forkmount.go b/lxd/main_forkmount.go index c861a725ca..813183b4f4 100644 --- a/lxd/main_forkmount.go +++ b/lxd/main_forkmount.go @@ -7,7 +7,9 @@ import ( ) /* -#define _GNU_SOURCE +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif #include <ctype.h> #include <errno.h> #include <fcntl.h> diff --git a/lxd/main_forknet.go b/lxd/main_forknet.go index 26fc37dbdf..903ca3c6fd 100644 --- a/lxd/main_forknet.go +++ b/lxd/main_forknet.go @@ -10,7 +10,9 @@ import ( ) /* -#define _GNU_SOURCE +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif #include <errno.h> #include <stdbool.h> #include <stdio.h> diff --git a/lxd/main_forkproxy.go b/lxd/main_forkproxy.go index 1801182d73..43454174d7 100644 --- a/lxd/main_forkproxy.go +++ b/lxd/main_forkproxy.go @@ -21,7 +21,9 @@ import ( ) /* -#define _GNU_SOURCE +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif #include <errno.h> #include <fcntl.h> #include <stdbool.h> diff --git a/lxd/main_forkuevent.go b/lxd/main_forkuevent.go index 1926ba9e3a..94087deb9d 100644 --- a/lxd/main_forkuevent.go +++ b/lxd/main_forkuevent.go @@ -5,8 +5,9 @@ import ( ) /* - -#define _GNU_SOURCE +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif #include <asm/types.h> #include <errno.h> #include <fcntl.h> diff --git a/lxd/main_nsexec.go b/lxd/main_nsexec.go index 21e25d7cf3..9bcc05b8e1 100644 --- a/lxd/main_nsexec.go +++ b/lxd/main_nsexec.go @@ -1,4 +1,6 @@ /** +#cgo CFLAGS: -std=gnu11 -Wvla -fvisibility=hidden + * This file is a bit funny. The goal here is to use setns() to manipulate * files inside the container, so we don't have to reason about the paths to * make sure they don't escape (we can simply rely on the kernel for @@ -19,7 +21,9 @@ package main /* -#define _GNU_SOURCE +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif #include <errno.h> #include <fcntl.h> #include <grp.h> @@ -300,5 +304,4 @@ __attribute__((constructor)) void init(void) { checkfeature(); } */ -// #cgo CFLAGS: -std=gnu11 -Wvla import "C" diff --git a/lxd/storage/storage_cgo.go b/lxd/storage/storage_cgo.go index 437e67ef1b..9973224f1a 100644 --- a/lxd/storage/storage_cgo.go +++ b/lxd/storage/storage_cgo.go @@ -4,7 +4,9 @@ package storage /* -#define _GNU_SOURCE +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif #define _FILE_OFFSET_BITS 64 #include <dirent.h> #include <errno.h> diff --git a/lxd/ucred/ucred_gccgo.go b/lxd/ucred/ucred_gccgo.go index 15a58532c0..44b22dddac 100644 --- a/lxd/ucred/ucred_gccgo.go +++ b/lxd/ucred/ucred_gccgo.go @@ -8,7 +8,9 @@ import ( ) /* -#define _GNU_SOURCE +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif #include <sys/socket.h> #include <sys/types.h> #include <errno.h> diff --git a/shared/idmap/shift_linux.go b/shared/idmap/shift_linux.go index 06c6aa5066..0c4de8cceb 100644 --- a/shared/idmap/shift_linux.go +++ b/shared/idmap/shift_linux.go @@ -17,7 +17,9 @@ import ( // #cgo LDFLAGS: -lacl /* -#define _GNU_SOURCE +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif #include <byteswap.h> #include <errno.h> #include <fcntl.h> diff --git a/shared/util_linux_cgo.go b/shared/util_linux_cgo.go index 36e11163c7..41663374c7 100644 --- a/shared/util_linux_cgo.go +++ b/shared/util_linux_cgo.go @@ -19,7 +19,9 @@ import ( // #cgo LDFLAGS: -lutil -lpthread /* +#ifndef _GNU_SOURCE #define _GNU_SOURCE +#endif #include <errno.h> #include <fcntl.h> #include <grp.h>
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel