[lxc-devel] [lxd/master] tree-wide: pass -std=gnu11 -Wvla

brauner on Github lxc-bot at linuxcontainers.org
Tue Sep 25 06:31:50 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 727 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180925/04fe846e/attachment.bin>
-------------- next part --------------
From cc6455459ff6f173b30c185ba359e2792b3e5da9 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Tue, 25 Sep 2018 08:23:33 +0200
Subject: [PATCH] tree-wide: pass -std=gnu11 -Wvla

In LXC I've introduced the policy that the minimum supported compiler
version will be the same as for the kernel. This is currently gcc 4.8.
As such we can support the niceties that the C11 standard provides and
also disable the crazyness that are VLAs that have been marked optional
from C11 onwards. So always pass -std=gnu11 and -Wvla.

Closes #5066.

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 lxd-p2c/setns.go               | 1 +
 lxd/devlxd_gccgo.go            | 1 +
 lxd/main_checkfeature.go       | 1 +
 lxd/main_forkfile.go           | 1 +
 lxd/main_forkmount.go          | 1 +
 lxd/main_forknet.go            | 1 +
 lxd/main_forkproxy.go          | 1 +
 lxd/main_nsexec.go             | 1 +
 lxd/storage_cgo.go             | 1 +
 shared/idmap/shift_linux.go    | 1 +
 shared/network_linux.go        | 1 +
 shared/termios/termios_unix.go | 1 +
 shared/util_linux.go           | 1 +
 13 files changed, 13 insertions(+)

diff --git a/lxd-p2c/setns.go b/lxd-p2c/setns.go
index cd9ef1dc0a..7d82162574 100644
--- a/lxd-p2c/setns.go
+++ b/lxd-p2c/setns.go
@@ -30,4 +30,5 @@ __attribute__((constructor)) void init(void) {
 	// We're done, jump back to Go
 }
 */
+// #cgo CFLAGS: -std=gnu11 -Wvla
 import "C"
diff --git a/lxd/devlxd_gccgo.go b/lxd/devlxd_gccgo.go
index 11b86f6203..abf22d521f 100644
--- a/lxd/devlxd_gccgo.go
+++ b/lxd/devlxd_gccgo.go
@@ -33,6 +33,7 @@ void getucred(int sock, uint *uid, uint *gid, int *pid) {
 	return;
 }
 */
+// #cgo CFLAGS: -std=gnu11 -Wvla
 import "C"
 
 func getUcred(fd int) (uint32, uint32, int32, error) {
diff --git a/lxd/main_checkfeature.go b/lxd/main_checkfeature.go
index d60ce6d394..9b7b3d443b 100644
--- a/lxd/main_checkfeature.go
+++ b/lxd/main_checkfeature.go
@@ -123,6 +123,7 @@ static bool is_empty_string(char *s)
 	return (errbuf[0] == '\0');
 }
 */
+// #cgo CFLAGS: -std=gnu11 -Wvla
 import "C"
 
 func CanUseNetnsGetifaddrs() bool {
diff --git a/lxd/main_forkfile.go b/lxd/main_forkfile.go
index b433e07cf6..38030e2ae0 100644
--- a/lxd/main_forkfile.go
+++ b/lxd/main_forkfile.go
@@ -440,6 +440,7 @@ void forkfile() {
 	}
 }
 */
+// #cgo CFLAGS: -std=gnu11 -Wvla
 import "C"
 
 type cmdForkfile struct {
diff --git a/lxd/main_forkmount.go b/lxd/main_forkmount.go
index 80bb216ba6..4279414200 100644
--- a/lxd/main_forkmount.go
+++ b/lxd/main_forkmount.go
@@ -215,6 +215,7 @@ void forkmount() {
 	}
 }
 */
+// #cgo CFLAGS: -std=gnu11 -Wvla
 import "C"
 
 type cmdForkmount struct {
diff --git a/lxd/main_forknet.go b/lxd/main_forknet.go
index 6b71ecfe19..e7ef06e664 100644
--- a/lxd/main_forknet.go
+++ b/lxd/main_forknet.go
@@ -62,6 +62,7 @@ void forknet() {
 	}
 }
 */
+// #cgo CFLAGS: -std=gnu11 -Wvla
 import "C"
 
 type cmdForknet struct {
diff --git a/lxd/main_forkproxy.go b/lxd/main_forkproxy.go
index 5a41fdfe02..914c44bad2 100644
--- a/lxd/main_forkproxy.go
+++ b/lxd/main_forkproxy.go
@@ -282,6 +282,7 @@ void forkproxy()
 	}
 }
 */
+// #cgo CFLAGS: -std=gnu11 -Wvla
 import "C"
 
 const forkproxyUDSSockFDNum int = C.FORKPROXY_UDS_SOCK_FD_NUM
diff --git a/lxd/main_nsexec.go b/lxd/main_nsexec.go
index b27af6cf27..56fbf2fd46 100644
--- a/lxd/main_nsexec.go
+++ b/lxd/main_nsexec.go
@@ -250,4 +250,5 @@ __attribute__((constructor)) void init(void) {
 		checkfeature();
 }
 */
+// #cgo CFLAGS: -std=gnu11 -Wvla
 import "C"
diff --git a/lxd/storage_cgo.go b/lxd/storage_cgo.go
index 95c39d21e0..2a3a017491 100644
--- a/lxd/storage_cgo.go
+++ b/lxd/storage_cgo.go
@@ -268,6 +268,7 @@ int unset_autoclear_loop_device(int fd_loop)
 	return ioctl(fd_loop, LOOP_SET_STATUS64, &lo64);
 }
 */
+// #cgo CFLAGS: -std=gnu11 -Wvla
 import "C"
 
 import (
diff --git a/shared/idmap/shift_linux.go b/shared/idmap/shift_linux.go
index 9045fe3952..c729064d29 100644
--- a/shared/idmap/shift_linux.go
+++ b/shared/idmap/shift_linux.go
@@ -153,6 +153,7 @@ int shiftowner(char *basepath, char *path, int uid, int gid)
 	return 0;
 }
 */
+// #cgo CFLAGS: -std=gnu11 -Wvla
 import "C"
 
 // ShiftOwner updates uid and gid for a file when entering/exiting a namespace
diff --git a/shared/network_linux.go b/shared/network_linux.go
index 90656a09ba..07cfbad64b 100644
--- a/shared/network_linux.go
+++ b/shared/network_linux.go
@@ -18,6 +18,7 @@ import (
 /*
 #include "../shared/netns_getifaddrs.c"
 */
+// #cgo CFLAGS: -std=gnu11 -Wvla
 import "C"
 
 func NetnsGetifaddrs(initPID int32) (map[string]api.ContainerStateNetwork, error) {
diff --git a/shared/termios/termios_unix.go b/shared/termios/termios_unix.go
index 1b841c7228..153d826909 100644
--- a/shared/termios/termios_unix.go
+++ b/shared/termios/termios_unix.go
@@ -10,6 +10,7 @@ import (
 )
 
 // #include <termios.h>
+// #cgo CFLAGS: -std=gnu11 -Wvla
 import "C"
 
 // State contains the state of a terminal.
diff --git a/shared/util_linux.go b/shared/util_linux.go
index e16b91b5a3..043a408faf 100644
--- a/shared/util_linux.go
+++ b/shared/util_linux.go
@@ -238,6 +238,7 @@ out:
 	return ret;
 }
 */
+// #cgo CFLAGS: -std=gnu11 -Wvla
 import "C"
 
 const ABSTRACT_UNIX_SOCK_LEN int = C.ABSTRACT_UNIX_SOCK_LEN


More information about the lxc-devel mailing list