ACK: [PATCH] fwts_pm_method.h: constify some function args, don't inline free_pm_method_vars

Alex Hung alex.hung at canonical.com
Sun Apr 11 20:53:20 UTC 2021


On 2021-04-10 5:39 p.m., Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
> 
> Make sone read only function arguments const. Fix some formatting and
> don't inline free_pm_method_vars as this leads some some object code bloat.
> 
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
>  src/lib/include/fwts_pm_method.h | 28 +++++++---------------------
>  src/lib/src/fwts_pm_method.c     | 18 +++++++++++++++++-
>  2 files changed, 24 insertions(+), 22 deletions(-)
> 
> diff --git a/src/lib/include/fwts_pm_method.h b/src/lib/include/fwts_pm_method.h
> index f2175849..e5566b11 100644
> --- a/src/lib/include/fwts_pm_method.h
> +++ b/src/lib/include/fwts_pm_method.h
> @@ -30,8 +30,7 @@
>  
>  #include "fwts_types.h"
>  
> -typedef struct
> -{
> +typedef struct {
>  	fwts_framework *fw;
>  	time_t t_start;
>  	time_t t_end;
> @@ -53,32 +52,19 @@ typedef struct
>  #define FWTS_HIBERNATE		"FWTS_HIBERNATE"
>  #define FWTS_RESUME		"FWTS_RESUME"
>  
> -static inline void free_pm_method_vars(fwts_pm_method_vars *var)
> -{
> -	if (!var)
> -		return;
> -#if FWTS_ENABLE_LOGIND
> -	if (var->logind_proxy)
> -		g_object_unref(var->logind_proxy);
> -	if (var->logind_connection)
> -		g_object_unref(var->logind_connection);
> -	if (var->gmainloop)
> -		g_main_loop_unref(var->gmainloop);
> -	if (var->action)
> -		free(var->action);
> -#endif
> -	free(var);
> -}
> -
> +void free_pm_method_vars(fwts_pm_method_vars *var);
>  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);
> +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);
>  bool fwts_logind_can_hybrid_suspend(fwts_pm_method_vars *fwts_settings);
>  bool fwts_logind_can_hibernate(fwts_pm_method_vars *fwts_settings);
>  bool fwts_sysfs_can_suspend(const fwts_pm_method_vars *fwts_settings);
>  bool fwts_sysfs_can_hybrid_suspend(const fwts_pm_method_vars *fwts_settings);
>  bool fwts_sysfs_can_hibernate(const fwts_pm_method_vars *fwts_settings);
> -int fwts_sysfs_do_suspend(const fwts_pm_method_vars *fwts_settings, bool s3_hybrid);
> +int fwts_sysfs_do_suspend(const fwts_pm_method_vars *fwts_settings,
> +	const bool s3_hybrid);
>  int fwts_sysfs_do_hibernate(const fwts_pm_method_vars *fwts_settings);
>  
>  #endif
> diff --git a/src/lib/src/fwts_pm_method.c b/src/lib/src/fwts_pm_method.c
> index b4e1bdf7..ead3f1b6 100644
> --- a/src/lib/src/fwts_pm_method.c
> +++ b/src/lib/src/fwts_pm_method.c
> @@ -415,7 +415,7 @@ bool fwts_sysfs_can_hibernate(const fwts_pm_method_vars *fwts_settings)
>   */
>  int fwts_sysfs_do_suspend(
>  	const fwts_pm_method_vars *fwts_settings,
> -	bool s3_hybrid)
> +	const bool s3_hybrid)
>  {
>  	int status;
>  
> @@ -446,3 +446,19 @@ int fwts_sysfs_do_hibernate(const fwts_pm_method_vars *fwts_settings)
>  		"/sys/power/state", "disk");
>  }
>  
> +void free_pm_method_vars(fwts_pm_method_vars *var)
> +{
> +	if (!var)
> +		return;
> +#if FWTS_ENABLE_LOGIND
> +	if (var->logind_proxy)
> +		g_object_unref(var->logind_proxy);
> +	if (var->logind_connection)
> +		g_object_unref(var->logind_connection);
> +	if (var->gmainloop)
> +		g_main_loop_unref(var->gmainloop);
> +	if (var->action)
> +		free(var->action);
> +#endif
> +	free(var);
> +}
> 


Acked-by: Alex Hung <alex.hung at canonical.com>



More information about the fwts-devel mailing list