[systemd-commits] 2 commits - src/fstab-generator src/journal src/login src/machine

Zbigniew Jędrzejewski-Szmek zbyszek at kemper.freedesktop.org
Tue Sep 17 16:09:27 PDT 2013


 src/fstab-generator/fstab-generator.c   |    4 ++--
 src/journal/test-journal-interleaving.c |    2 +-
 src/login/logind-dbus.c                 |    1 -
 src/login/logind-session-dbus.c         |   12 +++++++-----
 src/login/logind-session-device.c       |    8 +++-----
 src/login/logind-session.c              |   18 ++++++++++++++++--
 src/machine/machined-dbus.c             |    2 --
 7 files changed, 29 insertions(+), 18 deletions(-)

New commits:
commit 1dc2ced4646a78b3dee9e3ea44130f938d6425bc
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Tue Sep 17 17:30:47 2013 -0500

    Remove six unused variables and add annotation
    
    clang FTW!

diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
index b73dfa4..9efccb9 100644
--- a/src/fstab-generator/fstab-generator.c
+++ b/src/fstab-generator/fstab-generator.c
@@ -64,7 +64,7 @@ static int mount_find_pri(struct mntent *me, int *ret) {
 }
 
 static int add_swap(const char *what, struct mntent *me) {
-        _cleanup_free_ char *name = NULL, *unit = NULL, *lnk = NULL, *device = NULL;
+        _cleanup_free_ char *name = NULL, *unit = NULL, *lnk = NULL;
         _cleanup_fclose_ FILE *f = NULL;
         bool noauto;
         int r, pri = -1;
@@ -159,7 +159,7 @@ static int add_mount(
                 const char *post,
                 const char *source) {
         _cleanup_free_ char
-                *name = NULL, *unit = NULL, *lnk = NULL, *device = NULL,
+                *name = NULL, *unit = NULL, *lnk = NULL,
                 *automount_name = NULL, *automount_unit = NULL;
         _cleanup_fclose_ FILE *f = NULL;
 
diff --git a/src/journal/test-journal-interleaving.c b/src/journal/test-journal-interleaving.c
index 2b21523..1a058ea 100644
--- a/src/journal/test-journal-interleaving.c
+++ b/src/journal/test-journal-interleaving.c
@@ -36,7 +36,7 @@
 
 static bool arg_keep = false;
 
-static void log_assert_errno(const char *text, int eno, const char *file, int line, const char *func) {
+_noreturn_ static void log_assert_errno(const char *text, int eno, const char *file, int line, const char *func) {
         log_meta(LOG_CRIT, file, line, func,
                  "'%s' failed at %s:%u (%s): %s.",
                  text, file, line, func, strerror(eno));
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index fd8ee1b..ec590c0 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -2395,7 +2395,6 @@ DBusHandlerResult bus_message_filter(
 
         } else if (dbus_message_is_signal(message, "org.freedesktop.DBus.Properties", "PropertiesChanged")) {
 
-                _cleanup_dbus_message_unref_ DBusMessage *reply = NULL;
                 _cleanup_free_ char *unit = NULL;
                 const char *path;
 
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
index ce982ef..27aa335 100644
--- a/src/login/logind-session.c
+++ b/src/login/logind-session.c
@@ -259,7 +259,6 @@ int session_load(Session *s) {
                 *seat = NULL,
                 *vtnr = NULL,
                 *leader = NULL,
-                *audit_id = NULL,
                 *type = NULL,
                 *class = NULL,
                 *uid = NULL,
diff --git a/src/machine/machined-dbus.c b/src/machine/machined-dbus.c
index 5a016e7..a526a52 100644
--- a/src/machine/machined-dbus.c
+++ b/src/machine/machined-dbus.c
@@ -117,7 +117,6 @@ static bool valid_machine_name(const char *p) {
 static int bus_manager_create_machine(Manager *manager, DBusMessage *message) {
 
         const char *name, *service, *class, *root_directory;
-        _cleanup_free_ char *p = NULL;
         DBusMessageIter iter, sub;
         MachineClass c;
         uint32_t leader;
@@ -560,7 +559,6 @@ DBusHandlerResult bus_message_filter(
 
         } else if (dbus_message_is_signal(message, "org.freedesktop.DBus.Properties", "PropertiesChanged")) {
 
-                _cleanup_dbus_message_unref_ DBusMessage *reply = NULL;
                 _cleanup_free_ char *unit = NULL;
                 const char *path;
 

commit 831dedef66dbf2650a9dc41263e624fe08f3bb7a
Author: David Herrmann <dh.herrmann at gmail.com>
Date:   Wed Sep 18 01:00:02 2013 +0200

    logind: fix build for ARM with sizeof(dev_t) > sizeof(void*)
    
    Unfortunately on ARM-32 systems dev_t can be 64bit and thus we cannot
    store it easily in void* keys for hashtables. Fix that by passing a
    pointer to the dev_t variable instead.

diff --git a/src/login/logind-session-dbus.c b/src/login/logind-session-dbus.c
index f793f99..5f6bafb 100644
--- a/src/login/logind-session-dbus.c
+++ b/src/login/logind-session-dbus.c
@@ -452,9 +452,7 @@ static DBusHandlerResult session_message_dispatch(
                         return bus_send_error_reply(connection, message, &error, -EINVAL);
 
                 dev = makedev(major, minor);
-                assert_cc(sizeof(unsigned long) >= sizeof(dev_t));
-
-                sd = hashmap_get(s->devices, ULONG_TO_PTR((unsigned long)dev));
+                sd = hashmap_get(s->devices, &dev);
                 if (sd) {
                         /* We don't allow retrieving a device multiple times.
                          * The related ReleaseDevice call is not ref-counted.
@@ -487,6 +485,7 @@ static DBusHandlerResult session_message_dispatch(
         } else if (dbus_message_is_method_call(message, "org.freedesktop.login1.Session", "ReleaseDevice")) {
                 SessionDevice *sd;
                 uint32_t major, minor;
+                dev_t dev;
 
                 if (!session_is_controller(s, bus_message_get_sender_with_fallback(message)))
                         return bus_send_error_reply(connection, message, NULL, -EPERM);
@@ -499,7 +498,8 @@ static DBusHandlerResult session_message_dispatch(
                                     DBUS_TYPE_INVALID))
                         return bus_send_error_reply(connection, message, &error, -EINVAL);
 
-                sd = hashmap_get(s->devices, ULONG_TO_PTR((unsigned long)makedev(major, minor)));
+                dev = makedev(major, minor);
+                sd = hashmap_get(s->devices, &dev);
                 if (!sd)
                         return bus_send_error_reply(connection, message, NULL, -ENODEV);
 
@@ -512,6 +512,7 @@ static DBusHandlerResult session_message_dispatch(
         } else if (dbus_message_is_method_call(message, "org.freedesktop.login1.Session", "PauseDeviceComplete")) {
                 SessionDevice *sd;
                 uint32_t major, minor;
+                dev_t dev;
 
                 if (!session_is_controller(s, bus_message_get_sender_with_fallback(message)))
                         return bus_send_error_reply(connection, message, NULL, -EPERM);
@@ -524,7 +525,8 @@ static DBusHandlerResult session_message_dispatch(
                                     DBUS_TYPE_INVALID))
                         return bus_send_error_reply(connection, message, &error, -EINVAL);
 
-                sd = hashmap_get(s->devices, ULONG_TO_PTR((unsigned long)makedev(major, minor)));
+                dev = makedev(major, minor);
+                sd = hashmap_get(s->devices, &dev);
                 if (!sd)
                         return bus_send_error_reply(connection, message, NULL, -ENODEV);
 
diff --git a/src/login/logind-session-device.c b/src/login/logind-session-device.c
index e92bb54..b45f9eb 100644
--- a/src/login/logind-session-device.c
+++ b/src/login/logind-session-device.c
@@ -369,9 +369,7 @@ int session_device_new(Session *s, dev_t dev, SessionDevice **out) {
         if (r < 0)
                 goto error;
 
-        assert_cc(sizeof(unsigned long) >= sizeof(dev_t));
-
-        r = hashmap_put(s->devices, ULONG_TO_PTR((unsigned long)sd->dev), sd);
+        r = hashmap_put(s->devices, &sd->dev, sd);
         if (r < 0) {
                 r = -ENOMEM;
                 goto error;
@@ -392,7 +390,7 @@ int session_device_new(Session *s, dev_t dev, SessionDevice **out) {
         return 0;
 
 error:
-        hashmap_remove(s->devices, ULONG_TO_PTR((unsigned long)sd->dev));
+        hashmap_remove(s->devices, &sd->dev);
         free(sd->node);
         free(sd);
         return r;
@@ -407,7 +405,7 @@ void session_device_free(SessionDevice *sd) {
 
         LIST_REMOVE(SessionDevice, sd_by_device, sd->device->session_devices, sd);
 
-        hashmap_remove(sd->session->devices, ULONG_TO_PTR((unsigned long)sd->dev));
+        hashmap_remove(sd->session->devices, &sd->dev);
 
         free(sd->node);
         free(sd);
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
index eea0bfb..ce982ef 100644
--- a/src/login/logind-session.c
+++ b/src/login/logind-session.c
@@ -36,6 +36,21 @@
 #include "dbus-common.h"
 #include "logind-session.h"
 
+static unsigned devt_hash_func(const void *p) {
+        uint64_t u = *(const dev_t*)p;
+
+        return uint64_hash_func(&u);
+}
+
+static int devt_compare_func(const void *_a, const void *_b) {
+        dev_t a, b;
+
+        a = *(const dev_t*) _a;
+        b = *(const dev_t*) _b;
+
+        return a < b ? -1 : (a > b ? 1 : 0);
+}
+
 Session* session_new(Manager *m, const char *id) {
         Session *s;
 
@@ -53,7 +68,7 @@ Session* session_new(Manager *m, const char *id) {
                 return NULL;
         }
 
-        s->devices = hashmap_new(trivial_hash_func, trivial_compare_func);
+        s->devices = hashmap_new(devt_hash_func, devt_compare_func);
         if (!s->devices) {
                 free(s->state_file);
                 free(s);



More information about the systemd-commits mailing list