[PATCH 5/7] fwts_pm_method.h: move _cleanup_free_ here and share it with s3 and s4
Alberto Milone
alberto.milone at canonical.com
Fri Aug 1 10:20:38 UTC 2014
Signed-off-by: Alberto Milone <alberto.milone at canonical.com>
---
src/acpi/s3/s3.c | 9 ---------
src/acpi/s4/s4.c | 9 ---------
src/lib/include/fwts_pm_method.h | 7 +++++++
3 files changed, 7 insertions(+), 18 deletions(-)
diff --git a/src/acpi/s3/s3.c b/src/acpi/s3/s3.c
index 4bd7651..70ebaae 100644
--- a/src/acpi/s3/s3.c
+++ b/src/acpi/s3/s3.c
@@ -29,10 +29,6 @@
#include <sys/stat.h>
#include <unistd.h>
-static inline void freep(void *);
-
-#define _cleanup_free_ __attribute__((cleanup(freep)))
-
#define PM_SUSPEND_PMUTILS "pm-suspend"
#define PM_SUSPEND_HYBRID_PMUTILS "pm-suspend-hybrid"
@@ -49,11 +45,6 @@ static float s3_suspend_time = 15.0; /* Maximum allowed suspend time */
static float s3_resume_time = 15.0; /* Maximum allowed resume time */
static bool s3_hybrid = false;
-static inline void freep(void *p)
-{
- free(*(void**) p);
-}
-
static int s3_init(fwts_framework *fw)
{
/* Pre-init - make sure wakealarm works so that we can wake up after suspend */
diff --git a/src/acpi/s4/s4.c b/src/acpi/s4/s4.c
index 2ce8b3d..8400538 100644
--- a/src/acpi/s4/s4.c
+++ b/src/acpi/s4/s4.c
@@ -27,10 +27,6 @@
#include <sys/stat.h>
#include <unistd.h>
-static inline void freep(void *);
-
-#define _cleanup_free_ __attribute__((cleanup(freep)))
-
#define PM_HIBERNATE "pm-hibernate"
#define FWTS_TRACING_BUFFER_SIZE "/sys/kernel/debug/tracing/buffer_size_kb"
@@ -45,11 +41,6 @@ static char *s4_quirks = NULL; /* Quirks to be passed to pm-hibernate */
static int s4_device_check_delay = 15; /* Time to sleep after waking up and then running device check */
static bool s4_min_max_delay = false;
-static inline void freep(void *p)
-{
- free(*(void**) p);
-}
-
static int s4_init(fwts_framework *fw)
{
fwts_list* swap_devs;
diff --git a/src/lib/include/fwts_pm_method.h b/src/lib/include/fwts_pm_method.h
index f2dade5..75c9c84 100644
--- a/src/lib/include/fwts_pm_method.h
+++ b/src/lib/include/fwts_pm_method.h
@@ -40,8 +40,10 @@ typedef struct
} fwts_pm_method_vars;
static inline void free_pm_method_vars(void *);
+static inline void freep(void *);
#define _cleanup_free_pm_vars_ __attribute__((cleanup(free_pm_method_vars)))
+#define _cleanup_free_ __attribute__((cleanup(freep)))
#define PM_SUSPEND_LOGIND "Suspend"
#define PM_SUSPEND_HYBRID_LOGIND "HybridSleep"
@@ -78,6 +80,11 @@ static inline void free_pm_method_vars(void *vars)
var = NULL;
}
+static inline void freep(void *p)
+{
+ free(*(void**) p);
+}
+
int fwts_logind_init_proxy(fwts_pm_method_vars *fwts_settings);
int fwts_logind_wait_for_resume_from_action(fwts_pm_method_vars *fwts_settings, const char *action, int minimum_delay);
bool fwts_logind_can_suspend(fwts_pm_method_vars *fwts_settings);
--
1.9.1
More information about the fwts-devel
mailing list