[systemd-commits] 2 commits - src/login src/shared

David Herrmann dvdhrm at kemper.freedesktop.org
Sun Dec 1 03:18:51 PST 2013


 src/login/logind-seat-dbus.c |    2 +-
 src/shared/util.c            |   14 ++++++++++++++
 src/shared/util.h            |    3 +++
 3 files changed, 18 insertions(+), 1 deletion(-)

New commits:
commit 4545a231fcccc2ef670ef70f7b38f4e0a04f86ae
Author: David Herrmann <dh.herrmann at gmail.com>
Date:   Sat Nov 30 11:31:59 2013 +0100

    util: add greedy_realloc0()
    
    Compared to greedy_realloc(), this sets all newly allocated memory to 0.
    As the old variant has been used a lot for string-handling, we avoid
    changing it as clearing memory is not needed there.

diff --git a/src/shared/util.c b/src/shared/util.c
index 305a6c2..b4ed2c4 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -5806,6 +5806,20 @@ void* greedy_realloc(void **p, size_t *allocated, size_t need) {
         return q;
 }
 
+void* greedy_realloc0(void **p, size_t *allocated, size_t need) {
+        size_t prev = *allocated;
+        uint8_t *q;
+
+        q = greedy_realloc(p, allocated, need);
+        if (!q)
+                return NULL;
+
+        if (*allocated > prev)
+                memset(&q[prev], 0, *allocated - prev);
+
+        return q;
+}
+
 bool id128_is_valid(const char *s) {
         size_t i, l;
 
diff --git a/src/shared/util.h b/src/shared/util.h
index 1662bd4..504f63a 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -669,8 +669,11 @@ char *strextend(char **x, ...) _sentinel_;
 char *strrep(const char *s, unsigned n);
 
 void* greedy_realloc(void **p, size_t *allocated, size_t need);
+void* greedy_realloc0(void **p, size_t *allocated, size_t need);
 #define GREEDY_REALLOC(array, allocated, need) \
         greedy_realloc((void**) &(array), &(allocated), sizeof((array)[0]) * (need))
+#define GREEDY_REALLOC0(array, allocated, need) \
+        greedy_realloc0((void**) &(array), &(allocated), sizeof((array)[0]) * (need))
 
 static inline void _reset_errno_(int *saved_errno) {
         errno = *saved_errno;

commit a0a6be9f6ab55ea76215c7fa4a5eab2235687348
Author: David Herrmann <dh.herrmann at gmail.com>
Date:   Sat Nov 30 11:37:32 2013 +0100

    logind: fix "CanGraphical" attribute to return correct value
    
    We should return seat_can_graphical() instead of seat_can_tty() for the
    public dbus CanGraphical attribute. This used to work, but the
    dbus -> sd-bus conversion introduced this regression.

diff --git a/src/login/logind-seat-dbus.c b/src/login/logind-seat-dbus.c
index 76158e5..23f975b 100644
--- a/src/login/logind-seat-dbus.c
+++ b/src/login/logind-seat-dbus.c
@@ -103,7 +103,7 @@ static int property_get_can_graphical(
         assert(reply);
         assert(s);
 
-        return sd_bus_message_append(reply, "b", seat_can_tty(s));
+        return sd_bus_message_append(reply, "b", seat_can_graphical(s));
 }
 
 static int property_get_sessions(



More information about the systemd-commits mailing list