build: WITH_UDEV is only defined when enabled
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.
This commit is contained in:
+10
-10
@@ -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);
|
||||
|
||||
+10
-10
@@ -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
|
||||
|
||||
+2
-2
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user