discover/udev: Don't call udev_set_log_fn()
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>
Fri, 8 Apr 2016 06:31:36 +0000 (16:31 +1000)
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>
Wed, 13 Apr 2016 06:21:14 +0000 (16:21 +1000)
As of libudev 218 udev_set_log_fn() is deprecated, causing a
-Wdeprecated-declarations warning when building, and is otherwise a
noop.
Add a configure check for libudev, and only call udev_set_log_fn() if
using a version older than 218.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
configure.ac
discover/udev.c

index 1b9b980920d16ba9876dc2ec3b79ae3ac5f4810f..00a61135cfe340d8938f7b131f18585b96561181 100644 (file)
@@ -57,6 +57,11 @@ AC_CHECK_LIB([udev], [udev_new],
        [AC_MSG_FAILURE([The libudev development library is required by petitboot.  Try installing the package libudev-dev or libudev-devel.])]
 )
 
+PKG_CHECK_EXISTS(libudev >= 218, [old_udev=no], [old_udev=yes])
+if test "$old_udev" = "yes" ; then
+      AC_DEFINE(UDEV_LOGGING, 1, [Support old udev logging interface])],
+fi
+
 AC_CHECK_LIB([devmapper], [dm_task_create],
        [DEVMAPPER_LIBS=-ldevmapper],
        [AC_MSG_FAILURE([The libdevmapper development library is required by petitboot.  Try installing the package libdevmapper-dev or libdevmapper-devel.])]
index 23057bfcfdca0cd7f885e7299f4f2ede48d6d1fb..f4cefabffa22cde360a1c0ed1ebe0ba76c4a7122 100644 (file)
@@ -448,6 +448,7 @@ static int udev_process(void *arg)
        return 0;
 }
 
+#ifdef UDEV_LOGGING
 static void udev_log_fn(struct udev __attribute__((unused)) *udev,
        int __attribute__((unused)) priority, const char *file, int line,
        const char *fn, const char *format, va_list args)
@@ -455,6 +456,7 @@ static void udev_log_fn(struct udev __attribute__((unused)) *udev,
       pb_log("libudev: %s %s:%d: ", fn, file, line);
       vfprintf(pb_log_get_stream(), format, args);
 }
+#endif
 
 struct pb_udev *udev_init(struct device_handler *handler,
                struct waitset *waitset)
@@ -475,7 +477,9 @@ struct pb_udev *udev_init(struct device_handler *handler,
 
        udev_set_userdata(udev->udev, udev);
 
+#ifdef UDEV_LOGGING
        udev_set_log_fn(udev->udev, udev_log_fn);
+#endif
 
        result = udev_setup_monitor(udev->udev, &udev->monitor);
        if (result)