[systemd-commits] 2 commits - .mailmap src/locale src/shared

Zbigniew Jędrzejewski-Szmek zbyszek at kemper.freedesktop.org
Mon Jan 7 08:44:25 PST 2013


 .mailmap               |    9 ++++++++-
 src/locale/localectl.c |   41 +++++++++++++----------------------------
 src/shared/macro.h     |    1 +
 src/shared/set.c       |    8 ++++++++
 src/shared/set.h       |    1 +
 5 files changed, 31 insertions(+), 29 deletions(-)

New commits:
commit bac3c8eefe23a820caac930d41629cebafbfc7b2
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Mon Jan 7 11:43:41 2013 -0500

    localectl: use automatic cleanup
    
    set_freep() is added to automatize set_free().

diff --git a/src/locale/localectl.c b/src/locale/localectl.c
index b3acb3e..290edcc 100644
--- a/src/locale/localectl.c
+++ b/src/locale/localectl.c
@@ -384,15 +384,14 @@ static int add_locales_from_archive(Set *locales) {
 }
 
 static int add_locales_from_libdir (Set *locales) {
-        DIR *dir;
+        DIR _cleanup_closedir_ *dir;
         struct dirent *entry;
         int r;
 
         dir = opendir("/usr/lib/locale");
         if (!dir) {
                 log_error("Failed to open locale directory: %m");
-                r = -errno;
-                goto finish;
+                return -errno;
         }
 
         errno = 0;
@@ -406,10 +405,8 @@ static int add_locales_from_libdir (Set *locales) {
                         continue;
 
                 z = strdup(entry->d_name);
-                if (!z) {
-                        r = log_oom();
-                        goto finish;
-                }
+                if (!z)
+                        return log_oom();
 
                 r = set_put(locales, z);
                 if (r < 0) {
@@ -417,7 +414,7 @@ static int add_locales_from_libdir (Set *locales) {
 
                         if (r != -EEXIST) {
                                 log_error("Failed to add locale: %s", strerror(-r));
-                                goto finish;
+                                return r;
                         }
                 }
 
@@ -426,19 +423,14 @@ static int add_locales_from_libdir (Set *locales) {
 
         if (errno != 0) {
                 log_error("Failed to read locale directory: %m");
-                r = -errno;
-                goto finish;
+                return -errno;
         }
 
-        r = 0;
-
- finish:
-        closedir(dir);
-        return r;
+        return 0;
 }
 
 static int list_locales(DBusConnection *bus, char **args, unsigned n) {
-        Set *locales;
+        _cleanup_set_free_ Set *locales;
         _cleanup_strv_free_ char **l = NULL;
         char **j;
         int r;
@@ -449,17 +441,15 @@ static int list_locales(DBusConnection *bus, char **args, unsigned n) {
 
         r = add_locales_from_archive(locales);
         if (r < 0 && r != -ENOENT)
-                goto finish;
+                return r;
 
         r = add_locales_from_libdir(locales);
         if (r < 0)
-                goto finish;
+                return r;
 
         l = set_get_strv(locales);
-        if (!l) {
-                r = log_oom();
-                goto finish;
-        }
+        if (!l)
+                return log_oom();
 
         strv_sort(l);
 
@@ -468,12 +458,7 @@ static int list_locales(DBusConnection *bus, char **args, unsigned n) {
         STRV_FOREACH(j, l)
                 puts(*j);
 
-        r = 0;
-
-finish:
-        set_free(locales);
-
-        return r;
+        return 0;
 }
 
 static int set_vconsole_keymap(DBusConnection *bus, char **args, unsigned n) {
diff --git a/src/shared/macro.h b/src/shared/macro.h
index 700171b..29d9139 100644
--- a/src/shared/macro.h
+++ b/src/shared/macro.h
@@ -199,6 +199,7 @@ static inline size_t IOVEC_INCREMENT(struct iovec *i, unsigned n, size_t k) {
 #define _cleanup_close_ __attribute__((cleanup(closep)))
 #define _cleanup_closedir_ __attribute__((cleanup(closedirp)))
 #define _cleanup_umask_ __attribute__((cleanup(umaskp)))
+#define _cleanup_set_free_ __attribute__((cleanup(set_freep)))
 #define _cleanup_strv_free_ __attribute__((cleanup(strv_freep)))
 
 #define VA_FORMAT_ADVANCE(format, ap)                                   \
diff --git a/src/shared/set.c b/src/shared/set.c
index 5f83c50..53399b6 100644
--- a/src/shared/set.c
+++ b/src/shared/set.c
@@ -37,6 +37,14 @@ void set_free(Set* s) {
         hashmap_free(MAKE_HASHMAP(s));
 }
 
+void set_freep(Set **s) {
+        if (!s)
+                return;
+
+        set_free(*s);
+        *s = NULL;
+}
+
 void set_free_free(Set *s) {
         hashmap_free_free(MAKE_HASHMAP(s));
 }
diff --git a/src/shared/set.h b/src/shared/set.h
index 9162e2a..ed5b5a4 100644
--- a/src/shared/set.h
+++ b/src/shared/set.h
@@ -33,6 +33,7 @@ typedef struct Set Set;
 
 Set *set_new(hash_func_t hash_func, compare_func_t compare_func);
 void set_free(Set* s);
+void set_freep(Set **s);
 void set_free_free(Set *s);
 Set* set_copy(Set *s);
 int set_ensure_allocated(Set **s, hash_func_t hash_func, compare_func_t compare_func);

commit 89db26a263480ccacfdad039063151ecb9a74f41
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Mon Jan 7 11:20:05 2013 -0500

    Update .mailmap

diff --git a/.mailmap b/.mailmap
index da8ca84..12fb2c8 100644
--- a/.mailmap
+++ b/.mailmap
@@ -7,6 +7,7 @@ Greg KH <greg at kroah.com>
 Greg KH <greg at kroah.com> <greg at kroah.com>
 Greg KH <greg at kroah.com> <greg at press.(none)>
 Greg KH <greg at kroah.com> <gregkh at suse.de>
+Greg KH <greg at kroah.com> <greg at bucket.kroah.org>
 Harald Hoyer <harald at redhat.com>
 David Zeuthen <david at fubar.dk>
 David Zeuthen <david at fubar.dk> <davidz at redhat.com>
@@ -18,7 +19,6 @@ Alan Jenkins <alan.christopher.jenkins at googlemail.com>
 Alan Jenkins <alan.christopher.jenkins at googlemail.com> <alan-jenkins at tuffmail.co.uk>
 Marco d'Itri <md at linux.it> <md at Linux.IT>
 Robert Gerus <ar at bash.org.pl> Robert "arachnist" Gerus <ar at bash.org.pl>
-Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl> Zbyszek Szmek <zbyszek at in.waw.pl>
 Fabiano Fidêncio <fabianofidencio at gmail.com> Fabiano Fidencio <fidencio at profusion.mobi>
 Martin Pitt <martinpitt at gnome.org>
 Martin Pitt <martinpitt at gnome.org> <martin.pitt at ubuntu.com>
@@ -43,3 +43,10 @@ Miklos Vajna <vmiklos at frugalware.org> <vmiklos at gmail.com>
 William Jon McCann <jmccann at redhat.com> <william.jon.mccann at gmail.com>
 Yin Kangkai <kangkai.yin at intel.com> <kangkai.yin at linux.intel.com>
 Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
+Lennart Poettering <lennart at poettering.net> <lennart at bf9bc1cc-28ce-0310-abfb-9041aa761afb>
+Ananth N Mavinakayanahalli <ananth at in.ibm.com>
+Ananth N Mavinakayanahalli <ananth at in.ibm.com> <ananthmg at rediffmail.com>
+Ted Ts'o <tytso at mit.edu>
+Tobias Klauser <tklauser at access.unizh.ch>
+Tobias Klauser <tklauser at access.unizh.ch> <tklauser at access.unizh.chbk>
+Tobias Klauser <tklauser at access.unizh.ch> <klauser at access.unizh.ch>



More information about the systemd-commits mailing list