[PATCH 3/4] build: WITH_UDEV is only defined when enabled

Aleksander Morgado aleksander at aleksander.es
Thu Jun 22 08:59:26 UTC 2017


Looks like the preprocessor doesn't choke when using #if WITH_UDEV and
it isn't defined to any value, but anyway, better explicitly say that
we're checking if it's defined or not.
---
 cli/mmcli-manager.c   | 20 ++++++++++----------
 src/mm-base-manager.c | 20 ++++++++++----------
 src/mm-context.c      |  4 ++--
 3 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/cli/mmcli-manager.c b/cli/mmcli-manager.c
index 5e5e60b6..ed8a9926 100644
--- a/cli/mmcli-manager.c
+++ b/cli/mmcli-manager.c
@@ -29,7 +29,7 @@
 #include <glib.h>
 #include <gio/gio.h>
 
-#if WITH_UDEV
+#if defined WITH_UDEV
 # include <gudev/gudev.h>
 #endif
 
@@ -43,7 +43,7 @@
 typedef struct {
     MMManager *manager;
     GCancellable *cancellable;
-#if WITH_UDEV
+#if defined WITH_UDEV
     GUdevClient *udev;
 #endif
 } Context;
@@ -56,7 +56,7 @@ static gboolean scan_modems_flag;
 static gchar *set_logging_str;
 static gchar *report_kernel_event_str;
 
-#if WITH_UDEV
+#if defined WITH_UDEV
 static gboolean report_kernel_event_auto_scan;
 #endif
 
@@ -81,7 +81,7 @@ static GOptionEntry entries[] = {
       "Report kernel event",
       "[\"key=value,...\"]"
     },
-#if WITH_UDEV
+#if defined WITH_UDEV
     { "report-kernel-event-auto-scan", 0, 0, G_OPTION_ARG_NONE, &report_kernel_event_auto_scan,
       "Automatically report kernel events based on udev notifications",
       NULL
@@ -121,7 +121,7 @@ mmcli_manager_options_enabled (void)
                  !!set_logging_str +
                  !!report_kernel_event_str);
 
-#if WITH_UDEV
+#if defined WITH_UDEV
     n_actions += report_kernel_event_auto_scan;
 #endif
 
@@ -133,7 +133,7 @@ mmcli_manager_options_enabled (void)
     if (monitor_modems_flag)
         mmcli_force_async_operation ();
 
-#if WITH_UDEV
+#if defined WITH_UDEV
     if (report_kernel_event_auto_scan)
         mmcli_force_async_operation ();
 #endif
@@ -148,7 +148,7 @@ context_free (Context *ctx)
     if (!ctx)
         return;
 
-#if WITH_UDEV
+#if defined WITH_UDEV
     if (ctx->udev)
         g_object_unref (ctx->udev);
 #endif
@@ -325,7 +325,7 @@ cancelled (GCancellable *cancellable)
     mmcli_async_operation_done ();
 }
 
-#if WITH_UDEV
+#if defined WITH_UDEV
 
 static void
 handle_uevent (GUdevClient *client,
@@ -388,7 +388,7 @@ get_manager_ready (GObject      *source,
         return;
     }
 
-#if WITH_UDEV
+#if defined WITH_UDEV
     if (report_kernel_event_auto_scan) {
         const gchar *subsys[] = { "tty", "usbmisc", "net", NULL };
         guint i;
@@ -480,7 +480,7 @@ mmcli_manager_run_synchronous (GDBusConnection *connection)
         exit (EXIT_FAILURE);
     }
 
-#if WITH_UDEV
+#if defined WITH_UDEV
     if (report_kernel_event_auto_scan) {
         g_printerr ("error: monitoring udev events cannot be done synchronously\n");
         exit (EXIT_FAILURE);
diff --git a/src/mm-base-manager.c b/src/mm-base-manager.c
index 58cea119..0c76fd2c 100644
--- a/src/mm-base-manager.c
+++ b/src/mm-base-manager.c
@@ -24,7 +24,7 @@
 
 #include <gmodule.h>
 
-#if WITH_UDEV
+#if defined WITH_UDEV
 # include "mm-kernel-device-udev.h"
 #endif
 #include "mm-kernel-device-generic.h"
@@ -81,7 +81,7 @@ struct _MMBaseManagerPrivate {
     /* The Test interface support */
     MmGdbusTest *test_skeleton;
 
-#if WITH_UDEV
+#if defined WITH_UDEV
     /* The UDev client */
     GUdevClient *udev;
 #endif
@@ -373,7 +373,7 @@ handle_kernel_event (MMBaseManager            *self,
     mm_dbg ("  name:      %s", name);
     mm_dbg ("  uid:       %s", uid ? uid : "n/a");
 
-#if WITH_UDEV
+#if defined WITH_UDEV
     kernel_device = mm_kernel_device_udev_new_from_properties (properties, error);
 #else
     kernel_device = mm_kernel_device_generic_new (properties, error);
@@ -393,7 +393,7 @@ handle_kernel_event (MMBaseManager            *self,
     return TRUE;
 }
 
-#if WITH_UDEV
+#if defined WITH_UDEV
 
 static void
 handle_uevent (GUdevClient *client,
@@ -569,7 +569,7 @@ mm_base_manager_start (MMBaseManager *self,
         return;
     }
 
-#if WITH_UDEV
+#if defined WITH_UDEV
     mm_dbg ("Starting %s device scan...", manual_scan ? "manual" : "automatic");
     process_scan (self, manual_scan);
     mm_dbg ("Finished device scan...");
@@ -753,7 +753,7 @@ scan_devices_auth_ready (MMAuthProvider *authp,
     if (!mm_auth_provider_authorize_finish (authp, res, &error))
         g_dbus_method_invocation_take_error (ctx->invocation, error);
     else {
-#if WITH_UDEV
+#if defined WITH_UDEV
         /* Otherwise relaunch device scan */
         mm_base_manager_start (MM_BASE_MANAGER (ctx->self), TRUE);
         mm_gdbus_org_freedesktop_modem_manager1_complete_scan_devices (
@@ -816,7 +816,7 @@ report_kernel_event_auth_ready (MMAuthProvider           *authp,
     if (!mm_auth_provider_authorize_finish (authp, res, &error))
         goto out;
 
-#if WITH_UDEV
+#if defined WITH_UDEV
     if (ctx->self->priv->auto_scan) {
         error = g_error_new_literal (MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED,
                                      "Cannot report kernel event: "
@@ -1050,7 +1050,7 @@ mm_base_manager_init (MMBaseManager *manager)
     /* Setup internal lists of device objects */
     priv->devices = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
 
-#if WITH_UDEV
+#if defined WITH_UDEV
     {
         const gchar *subsys[5] = { "tty", "net", "usb", "usbmisc", NULL };
 
@@ -1090,7 +1090,7 @@ initable_init (GInitable *initable,
 {
     MMBaseManagerPrivate *priv = MM_BASE_MANAGER (initable)->priv;
 
-#if WITH_UDEV
+#if defined WITH_UDEV
     /* If autoscan enabled, list for udev events */
     if (priv->auto_scan)
         g_signal_connect (priv->udev, "uevent", G_CALLBACK (handle_uevent), initable);
@@ -1140,7 +1140,7 @@ finalize (GObject *object)
 
     g_hash_table_destroy (priv->devices);
 
-#if WITH_UDEV
+#if defined WITH_UDEV
     if (priv->udev)
         g_object_unref (priv->udev);
 #endif
diff --git a/src/mm-context.c b/src/mm-context.c
index 370fe28c..b7d2a281 100644
--- a/src/mm-context.c
+++ b/src/mm-context.c
@@ -21,7 +21,7 @@
 /*****************************************************************************/
 /* Application context */
 
-#if WITH_UDEV
+#if defined WITH_UDEV
 # define NO_AUTO_SCAN_OPTION_FLAG 0
 # define NO_AUTO_SCAN_DEFAULT     FALSE
 #else
@@ -293,7 +293,7 @@ mm_context_init (gint argc,
     }
 
     /* Initial kernel events processing may only be used if autoscan is disabled */
-#if WITH_UDEV
+#if defined WITH_UDEV
     if (!no_auto_scan && initial_kernel_events) {
         g_warning ("error: --initial-kernel-events must be used only if --no-auto-scan is also used");
         exit (1);
-- 
2.13.1



More information about the ModemManager-devel mailing list