[PATCH 0/3] Build fixes for gcc 4.5
Various build fixes for gcc 4.5. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://et.redhat.com/~rjones/libguestfs/ See what it can do: http://et.redhat.com/~rjones/libguestfs/recipes.html
-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into Xen guests. http://et.redhat.com/~rjones/virt-p2v
On 16/07/10 13:05, Richard W.M. Jones wrote:
From 694912816850377dd545e83902940ed48a47b3d9 Mon Sep 17 00:00:00 2001 From: Richard Jones<rjones@redhat.com> Date: Fri, 16 Jul 2010 12:55:17 +0100 Subject: [PATCH 1/3] build: Don't warn about 'long long'.
Various language bindings simply need this, so we have to allow it even though it's a GCC extension.
ACK. Matt -- Matthew Booth, RHCA, RHCSS Red Hat Engineering, Virtualisation Team GPG ID: D33C3490 GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490
-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top
On 16/07/10 13:05, Richard W.M. Jones wrote:
From d77d63c56c03b367df5b6757e8f356e40ca5f386 Mon Sep 17 00:00:00 2001 From: Richard Jones<rjones@redhat.com> Date: Fri, 16 Jul 2010 12:57:24 +0100 Subject: [PATCH 2/3] generator: Don't hard-code name in DeviceList check.
Only one function currently uses DeviceList. The generated code unfortunately hard-coded the argument name from that function.
These look equivalent. ACK. Matt -- Matthew Booth, RHCA, RHCSS Red Hat Engineering, Virtualisation Team GPG ID: D33C3490 GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490
-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into Xen guests. http://et.redhat.com/~rjones/virt-p2v
On 16/07/10 13:05, Richard W.M. Jones wrote:
From 460031c9f9bcabd5e132aab22ab0d001ab14d33d Mon Sep 17 00:00:00 2001 From: Richard Jones<rjones@redhat.com> Date: Fri, 16 Jul 2010 12:58:54 +0100 Subject: [PATCH 3/3] Use an unsigned type (size_t) for all loop iterators.
This resolves a warning from gcc 4.5: assuming signed overflow does not occur when simplifying conditional to constant
This page explains the issues in some detail: http://www.airs.com/blog/archives/120 --- configure.ac | 1 - src/generator.ml | 42 +++++++++++++++++++++--------------------- 2 files changed, 21 insertions(+), 22 deletions(-)
diff --git a/configure.ac b/configure.ac index caf25ee..671fbb0 100644 --- a/configure.ac +++ b/configure.ac @@ -110,7 +110,6 @@ if test "$gl_gcc_warnings" = yes; then nw="$nw -Wmissing-format-attribute" # daemon.h's asprintf_nowarn nw="$nw -Winline" # daemon.h's asprintf_nowarn nw="$nw -Wshadow" # numerous, plus we're not unanimous - # ?? -Wstrict-overflow nw="$nw -Wunsafe-loop-optimizations" # just a warning that an optimization # was not possible, safe to ignore nw="$nw -Wpacked" # Allow attribute((packed)) on structs diff --git a/src/generator.ml b/src/generator.ml index cb3f773..8fc619f 100755 --- a/src/generator.ml +++ b/src/generator.ml
...
@@ -9354,7 +9354,7 @@ put_handle (guestfs_h *g) static char ** get_string_list (PyObject *obj) { - int i, len; + size_t i, len; char **r;
assert (obj);
This isn't safe. len is assigned later: len = PyList_Size (obj); PyList_Size returns Py_ssize_t, which is a signed type. This may also mean that the later code may also need a second look, as it doesn't check for a negative return value. The rest all look fine, though. Matt -- Matthew Booth, RHCA, RHCSS Red Hat Engineering, Virtualisation Team GPG ID: D33C3490 GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490
On Fri, Jul 16, 2010 at 02:27:12PM +0100, Matthew Booth wrote:
On 16/07/10 13:05, Richard W.M. Jones wrote:
@@ -9354,7 +9354,7 @@ put_handle (guestfs_h *g) static char ** get_string_list (PyObject *obj) { - int i, len; + size_t i, len; char **r;
assert (obj);
This isn't safe. len is assigned later:
len = PyList_Size (obj);
PyList_Size returns Py_ssize_t, which is a signed type. This may also mean that the later code may also need a second look, as it doesn't check for a negative return value.
I checked in the Python source and PyList_Size does do some sort of runtime check of the obj parameter and could return -1. No wonder it's slow. In the updated patch attached the hunk now looks like this: @@ -9354,7 +9354,7 @@ put_handle (guestfs_h *g) static char ** get_string_list (PyObject *obj) { - int i, len; + size_t i, len; char **r; assert (obj); @@ -9364,7 +9364,12 @@ get_string_list (PyObject *obj) return NULL; } - len = PyList_Size (obj); + Py_ssize_t slen = PyList_Size (obj); + if (slen == -1) { + PyErr_SetString (PyExc_RuntimeError, \"get_string_list: PyList_Size failure\"); + return NULL; + } + len = (size_t) slen; r = malloc (sizeof (char *) * (len+1)); if (r == NULL) { PyErr_SetString (PyExc_RuntimeError, \"get_string_list: out of memory\"); Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones New in Fedora 11: Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 70 libraries supprt'd http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
On 16/07/10 15:26, Richard W.M. Jones wrote:
On Fri, Jul 16, 2010 at 02:27:12PM +0100, Matthew Booth wrote:
On 16/07/10 13:05, Richard W.M. Jones wrote:
@@ -9354,7 +9354,7 @@ put_handle (guestfs_h *g) static char ** get_string_list (PyObject *obj) { - int i, len; + size_t i, len; char **r;
assert (obj);
This isn't safe. len is assigned later:
len = PyList_Size (obj);
PyList_Size returns Py_ssize_t, which is a signed type. This may also mean that the later code may also need a second look, as it doesn't check for a negative return value.
I checked in the Python source and PyList_Size does do some sort of runtime check of the obj parameter and could return -1. No wonder it's slow.
In the updated patch attached the hunk now looks like this:
@@ -9354,7 +9354,7 @@ put_handle (guestfs_h *g) static char ** get_string_list (PyObject *obj) { - int i, len; + size_t i, len; char **r;
assert (obj); @@ -9364,7 +9364,12 @@ get_string_list (PyObject *obj) return NULL; }
- len = PyList_Size (obj); + Py_ssize_t slen = PyList_Size (obj); + if (slen == -1) { + PyErr_SetString (PyExc_RuntimeError, \"get_string_list: PyList_Size failure\"); + return NULL; + } + len = (size_t) slen; r = malloc (sizeof (char *) * (len+1)); if (r == NULL) { PyErr_SetString (PyExc_RuntimeError, \"get_string_list: out of memory\");
Looks good. ACK. Matt -- Matthew Booth, RHCA, RHCSS Red Hat Engineering, Virtualisation Team GPG ID: D33C3490 GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490
participants (2)
-
Matthew Booth -
Richard W.M. Jones