[lxc-devel] [PATCH] Fix build error(ISO C90 specs violation) in lxc.c
Stéphane Graber
stgraber at ubuntu.com
Mon Sep 22 14:40:01 UTC 2014
On Mon, Sep 22, 2014 at 11:32:46PM +0900, Masami Ichikawa wrote:
> This patch fixes following build errors.
>
> running build_ext
> building '_lxc' extension
> creating build/temp.linux-x86_64-3.4
> gcc -pthread -Wno-unused-result -Werror=declaration-after-statement -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -fPIC -I../../src -I../../src -I/usr/include/python3.4m -c lxc.c -o ./build/temp.linux-x86_64-3.4/lxc.o
> lxc.c: In function ‘convert_tuple_to_char_pointer_array’:
> lxc.c:49:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
> char **result = (char**) calloc(argc + 1, sizeof(char*));
> ^
> lxc.c:60:9: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
> char *str = NULL;
> ^
> lxc.c: In function ‘Container_get_cgroup_item’:
> lxc.c:822:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
> char* value = (char*) malloc(sizeof(char)*len + 1);
> ^
> lxc.c: In function ‘Container_get_config_item’:
> lxc.c:861:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
> char* value = (char*) malloc(sizeof(char)*len + 1);
> ^
> lxc.c: In function ‘Container_get_keys’:
> lxc.c:903:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
> char* value = (char*) malloc(sizeof(char)*len + 1);
> ^
> cc1: some warnings being treated as errors
> error: command 'gcc' failed with exit status 1
> Makefile:472: recipe for target 'all' failed
> make[3]: *** [all] Error 1
> make[3]: Leaving directory '/home/masami/codes/lxc/src/python-lxc'
> Makefile:394: recipe for target 'all-recursive' failed
> make[2]: *** [all-recursive] Error 1
> make[2]: Leaving directory '/home/masami/codes/lxc/src'
> Makefile:338: recipe for target 'all' failed
> make[1]: *** [all] Error 2
> make[1]: Leaving directory '/home/masami/codes/lxc/src'
> Makefile:484: recipe for target 'all-recursive' failed
> make: *** [all-recursive] Error 1
>
> build env:
> distribution: Arch Linux
> gcc version 4.9.1 20140903 (prerelease) (GCC)
>
> Signed-off-by: Masami Ichikawa <masami256 at gmail.com>
Acked-by: Stéphane Graber <stgraber at ubuntu.com>
> ---
> src/python-lxc/lxc.c | 17 ++++++++++-------
> 1 file changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/src/python-lxc/lxc.c b/src/python-lxc/lxc.c
> index 91c199f..42b8448 100644
> --- a/src/python-lxc/lxc.c
> +++ b/src/python-lxc/lxc.c
> @@ -37,6 +37,7 @@ char**
> convert_tuple_to_char_pointer_array(PyObject *argv) {
> int argc;
> int i, j;
> + char **result;
>
> /* not a list or tuple */
> if (!PyList_Check(argv) && !PyTuple_Check(argv)) {
> @@ -46,7 +47,7 @@ convert_tuple_to_char_pointer_array(PyObject *argv) {
>
> argc = PySequence_Fast_GET_SIZE(argv);
>
> - char **result = (char**) calloc(argc + 1, sizeof(char*));
> + result = (char**) calloc(argc + 1, sizeof(char*));
>
> if (result == NULL) {
> PyErr_SetNone(PyExc_MemoryError);
> @@ -54,11 +55,10 @@ convert_tuple_to_char_pointer_array(PyObject *argv) {
> }
>
> for (i = 0; i < argc; i++) {
> - PyObject *pyobj = PySequence_Fast_GET_ITEM(argv, i);
> - assert(pyobj != NULL);
> -
> char *str = NULL;
> PyObject *pystr = NULL;
> + PyObject *pyobj = PySequence_Fast_GET_ITEM(argv, i);
> + assert(pyobj != NULL);
>
> if (!PyUnicode_Check(pyobj)) {
> PyErr_SetString(PyExc_ValueError, "Expected a string");
> @@ -806,6 +806,7 @@ Container_get_cgroup_item(Container *self, PyObject *args, PyObject *kwds)
> static char *kwlist[] = {"key", NULL};
> char* key = NULL;
> int len = 0;
> + char* value;
> PyObject *ret = NULL;
>
> if (! PyArg_ParseTupleAndKeywords(args, kwds, "s", kwlist,
> @@ -819,7 +820,7 @@ Container_get_cgroup_item(Container *self, PyObject *args, PyObject *kwds)
> return NULL;
> }
>
> - char* value = (char*) malloc(sizeof(char)*len + 1);
> + value = (char*) malloc(sizeof(char)*len + 1);
> if (value == NULL)
> return PyErr_NoMemory();
>
> @@ -841,6 +842,7 @@ Container_get_config_item(Container *self, PyObject *args, PyObject *kwds)
> static char *kwlist[] = {"key", NULL};
> char* key = NULL;
> int len = 0;
> + char* value;
> PyObject *ret = NULL;
>
> if (! PyArg_ParseTupleAndKeywords(args, kwds, "s|", kwlist,
> @@ -858,7 +860,7 @@ Container_get_config_item(Container *self, PyObject *args, PyObject *kwds)
> return PyUnicode_FromString("");
> }
>
> - char* value = (char*) malloc(sizeof(char)*len + 1);
> + value = (char*) malloc(sizeof(char)*len + 1);
> if (value == NULL)
> return PyErr_NoMemory();
>
> @@ -887,6 +889,7 @@ Container_get_keys(Container *self, PyObject *args, PyObject *kwds)
> static char *kwlist[] = {"key", NULL};
> char* key = NULL;
> int len = 0;
> + char* value;
> PyObject *ret = NULL;
>
> if (! PyArg_ParseTupleAndKeywords(args, kwds, "|s", kwlist,
> @@ -900,7 +903,7 @@ Container_get_keys(Container *self, PyObject *args, PyObject *kwds)
> return NULL;
> }
>
> - char* value = (char*) malloc(sizeof(char)*len + 1);
> + value = (char*) malloc(sizeof(char)*len + 1);
> if (value == NULL)
> return PyErr_NoMemory();
>
> --
> 2.1.0
>
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140922/9bd8e140/attachment.sig>
More information about the lxc-devel
mailing list