libsystem-sd: use g_auto(), g_autoptr() or g_autofree
authorWaLyong Cho <walyong.cho@samsung.com>
Tue, 8 Nov 2016 07:28:17 +0000 (16:28 +0900)
committerWaLyong Cho <walyong.cho@samsung.com>
Tue, 8 Nov 2016 07:31:07 +0000 (16:31 +0900)
To use g_auto(), g_autoptr() and g_autofree,
add version dependency glib >= 2.44.

Change-Id: I13c8fccb89078bd1c49b9e9e37f8945dd1226578
Signed-off-by: WaLyong Cho <walyong.cho@samsung.com>
packaging/libsystem.spec
src/libsystem-sd/systemd.c

index c4308f968590e9caa06d334d62e11d9a882ad47f..d52cbc5c227053714fead3f0ca7cdb81c4d4985b 100644 (file)
@@ -11,8 +11,8 @@ BuildRequires:  autoconf
 BuildRequires:  automake
 BuildRequires:  libtool
 BuildRequires:  pkgconfig(dbus-1)
-BuildRequires:  pkgconfig(glib-2.0)
-BuildRequires:  pkgconfig(gio-2.0)
+BuildRequires:  pkgconfig(glib-2.0) >= 2.44
+BuildRequires:  pkgconfig(gio-2.0) >= 2.44
 
 Requires:       /bin/cp
 
index ec53b9017fc3a64ca59ed30944d7165091a72e8e..cfcd5d6c794d35f3eba4736373e4a19e68b1f280 100644 (file)
@@ -87,7 +87,7 @@ static int systemd_call_sync(GDBusConnection *connection,
                                                    NULL,
                                                    &err);
         else {
-                _cleanup_g_object_unref_ GDBusProxy *proxy = NULL;
+                g_autofree GDBusProxy *proxy = NULL;
 
                 proxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM,
                                                       G_DBUS_PROXY_FLAGS_NONE,
@@ -125,8 +125,8 @@ static int systemd_call_sync(GDBusConnection *connection,
 }
 
 int systemd_subscribe(GDBusConnection *connection, char **err_msg) {
-        _cleanup_g_variant_unref_ GVariant *reply = NULL;
-        _cleanup_g_error_free_ GError *error = NULL;
+        g_autofree GVariant *reply = NULL;
+        g_autofree GError *error = NULL;
         int r;
 
         r = systemd_call_sync(connection,
@@ -148,8 +148,8 @@ int systemd_subscribe(GDBusConnection *connection, char **err_msg) {
 }
 
 int systemd_unsubscribe(GDBusConnection *connection, char **err_msg) {
-        _cleanup_g_variant_unref_ GVariant *reply = NULL;
-        _cleanup_g_error_free_ GError *error = NULL;
+        g_autofree GVariant *reply = NULL;
+        g_autofree GError *error = NULL;
         int r;
 
         r = systemd_call_sync(connection,
@@ -175,8 +175,8 @@ int systemd_get_unit(GDBusConnection *connection,
                      char **unit,
                      char **err_msg) {
 
-        _cleanup_g_variant_unref_ GVariant *reply = NULL;
-        _cleanup_g_error_free_ GError *error = NULL;
+        g_autofree GVariant *reply = NULL;
+        g_autofree GError *error = NULL;
         char *obj = NULL;
         int r;
 
@@ -219,8 +219,8 @@ int systemd_control_unit(GDBusConnection *connection,
                          char **job,
                          char **err_msg) {
 
-        _cleanup_g_variant_unref_ GVariant *reply = NULL;
-        _cleanup_g_error_free_ GError *error = NULL;
+        g_autofree GVariant *reply = NULL;
+        g_autofree GError *error = NULL;
         char *obj = NULL;
         int r;
 
@@ -347,7 +347,7 @@ static int systemd_get_property(GDBusConnection *connection,
                                 GVariant **variant,
                                 char **err_msg) {
 
-        _cleanup_g_error_free_ GError *error = NULL;
+        g_autofree GError *error = NULL;
         int r;
 
         assert(name);
@@ -471,7 +471,7 @@ static int systemd_get_service_property(GDBusConnection *connection,
                         value* result,                                  \
                         char** err_msg) {                               \
                                                                         \
-                _cleanup_g_variant_unref_ GVariant *var = NULL, *inner = NULL; \
+                g_autofree GVariant *var = NULL, *inner = NULL;         \
                 int r;                                                  \
                                                                         \
                 assert(target);                                         \
@@ -606,7 +606,7 @@ void systemd_unit_status_list_free_full(GList *status_list) {
 static int systemd_parse_list_units_result(GVariant *result, GList **unit_list) {
         char *name, *description, *load_state, *active_state, *sub_state;
         char *followed, *obj_path, *job_type, *job_obj_path;
-        _cleanup_g_variant_iter_free_ GVariantIter *iter;
+        g_autofree GVariantIter *iter;
         unsigned int job_id;
         GList *list = NULL;
         int r;
@@ -728,8 +728,8 @@ on_error:
 }
 
 int systemd_get_units_list(GDBusConnection *conn, GList **unit_list, char **err_msg) {
-        _cleanup_g_variant_unref_ GVariant *reply = NULL;
-        _cleanup_g_error_free_ GError *error = NULL;
+        g_autofree GVariant *reply = NULL;
+        g_autofree GError *error = NULL;
         int r;
 
         assert(unit_list);
@@ -786,7 +786,7 @@ void systemd_unit_file_status_list_free_full(GList *status_list) {
 }
 
 static int systemd_parse_list_unit_files_result(GVariant *result, GList **unit_files_list) {
-        _cleanup_g_variant_iter_free_ GVariantIter *iter;
+        g_autofree GVariantIter *iter;
         GList *list = NULL;
         char *name, *status;
         int r;
@@ -843,8 +843,8 @@ on_error:
 }
 
 int systemd_get_unit_files_list(GDBusConnection *conn, GList **unit_files_list, char **err_msg) {
-        _cleanup_g_variant_unref_ GVariant *reply = NULL;
-        _cleanup_g_error_free_ GError *error = NULL;
+        g_autofree GVariant *reply = NULL;
+        g_autofree GError *error = NULL;
         int r;
 
         assert(conn);