[libvirt] [PATCH] node_device: Check return value for udev_new()

Martin Kletzander mkletzan at redhat.com
Wed Nov 30 15:25:58 UTC 2016


On Wed, Nov 30, 2016 at 01:45:32PM +0100, Marc Hartmayer wrote:
>The comment was actually wrong as
>https://www.freedesktop.org/software/systemd/man/udev_new.html
>mentions that on failure NULL is returned.
>
>Signed-off-by: Marc Hartmayer <mhartmay at linux.vnet.ibm.com>
>Reviewed-by: Bjoern Walk <bwalk at linux.vnet.ibm.com>
>Reviewed-by: Boris Fiuczynski <fiuczy at linux.vnet.ibm.com>
>---
> src/node_device/node_device_udev.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
>diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
>index 4b81312..4b0a875 100644
>--- a/src/node_device/node_device_udev.c
>+++ b/src/node_device/node_device_udev.c
>@@ -1491,13 +1491,11 @@ static int nodeStateInitialize(bool privileged,
>     if (udevPCITranslateInit(privileged) < 0)
>         goto cleanup;
>
>-    /*
>-     * http://www.kernel.org/pub/linux/utils/kernel/hotplug/libudev/libudev-udev.html#udev-new
>-     *
>-     * indicates no return value other than success, so we don't check
>-     * its return value.
>-     */
>     udev = udev_new();
>+    if (!udev) {
>+        virReportOOMError();
>+        goto cleanup;
>+    }

Is that true for other udevs and not just systemd-udev?  Does it really
mean just an OOM error?  Couldn't we add a proper error message?

> #if HAVE_UDEV_LOGGING
>     /* cast to get rid of missing-format-attribute warning */
>     udev_set_log_fn(udev, (udevLogFunctionPtr) udevLogFunction);
>--
>2.5.5
>
>--
>libvir-list mailing list
>libvir-list at redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20161130/555b7361/attachment-0001.sig>


More information about the libvir-list mailing list