Patchwork [2/2] fwts: use fwts_exec rather than fwts_pipe_exec

login
register
mail settings
Submitter Colin King
Date Dec. 29, 2013, 7:21 p.m.
Message ID <1388344902-19151-3-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/305668/
State Accepted
Headers show

Comments

Colin King - Dec. 29, 2013, 7:21 p.m.
From: Colin Ian King <colin.king@canonical.com>

The following changes use fwts_exec because we don't care about
the output and we just discard it by default.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/acpi/s3/s3.c              |  4 +---
 src/acpi/s3power/s3power.c    |  5 +----
 src/acpi/s4/s4.c              |  4 +---
 src/lib/src/fwts_efi_module.c | 11 ++---------
 4 files changed, 5 insertions(+), 19 deletions(-)
Keng-Yu Lin - Jan. 2, 2014, 6:01 a.m.
On Mon, Dec 30, 2013 at 3:21 AM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The following changes use fwts_exec because we don't care about
> the output and we just discard it by default.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/acpi/s3/s3.c              |  4 +---
>  src/acpi/s3power/s3power.c    |  5 +----
>  src/acpi/s4/s4.c              |  4 +---
>  src/lib/src/fwts_efi_module.c | 11 ++---------
>  4 files changed, 5 insertions(+), 19 deletions(-)
>
> diff --git a/src/acpi/s3/s3.c b/src/acpi/s3/s3.c
> index 7a86641..4161ea2 100644
> --- a/src/acpi/s3/s3.c
> +++ b/src/acpi/s3/s3.c
> @@ -66,7 +66,6 @@ static int s3_do_suspend_resume(fwts_framework *fw,
>         int delay,
>         int percent)
>  {
> -       fwts_list *output;
>         fwts_hwinfo hwinfo1, hwinfo2;
>         int status;
>         int duration;
> @@ -105,12 +104,11 @@ static int s3_do_suspend_resume(fwts_framework *fw,
>         time(&t_start);
>         (void)fwts_klog_write(fw, "Starting fwts suspend\n");
>         (void)fwts_klog_write(fw, FWTS_SUSPEND "\n");
> -       (void)fwts_pipe_exec(command, &output, &status);
> +       (void)fwts_exec(command, &status);
>         (void)fwts_klog_write(fw, FWTS_RESUME "\n");
>         (void)fwts_klog_write(fw, "Finished fwts resume\n");
>         time(&t_end);
>         fwts_progress_message(fw, percent, "(Resumed)");
> -       fwts_text_list_free(output);
>         free(command);
>
>         duration = (int)(t_end - t_start);
> diff --git a/src/acpi/s3power/s3power.c b/src/acpi/s3power/s3power.c
> index 75d660d..18a4a17 100644
> --- a/src/acpi/s3power/s3power.c
> +++ b/src/acpi/s3power/s3power.c
> @@ -172,8 +172,6 @@ static int s3power_test(fwts_framework *fw)
>         uint32_t capacity_before_mWh;
>         uint32_t capacity_after_mWh;
>
> -       fwts_list *output;
> -
>         if (s3power_wait_for_adapter_offline(fw, &offline) == FWTS_ERROR) {
>                 fwts_log_error(fw, "Cannot check if machine is running on battery, aborting test.");
>                 return FWTS_ABORTED;
> @@ -190,10 +188,9 @@ static int s3power_test(fwts_framework *fw)
>         /* Do S3 here */
>         fwts_progress_message(fw, 100, "(Suspending)");
>         time(&t_start);
> -       (void)fwts_pipe_exec(PM_SUSPEND, &output, &status);
> +       (void)fwts_exec(PM_SUSPEND, &status);
>         time(&t_end);
>         fwts_progress_message(fw, 100, "(Resumed)");
> -       fwts_text_list_free(output);
>
>         s3power_get_remaining_capacity(fw, &capacity_after_mAh, &capacity_after_mWh);
>
> diff --git a/src/acpi/s4/s4.c b/src/acpi/s4/s4.c
> index 48c0a30..701ee51 100644
> --- a/src/acpi/s4/s4.c
> +++ b/src/acpi/s4/s4.c
> @@ -97,7 +97,6 @@ static int s4_hibernate(fwts_framework *fw,
>         int *failed_alloc_image,
>         int percent)
>  {
> -       fwts_list *output;
>         fwts_list *klog_pre, *klog_post, *klog_diff;
>         fwts_hwinfo hwinfo1, hwinfo2;
>         int status;
> @@ -136,11 +135,10 @@ static int s4_hibernate(fwts_framework *fw,
>         fwts_progress_message(fw, percent, "(Hibernating)");
>         (void)fwts_klog_write(fw, "Starting fwts hibernate\n");
>         (void)fwts_klog_write(fw, FWTS_HIBERNATE "\n");
> -       (void)fwts_pipe_exec(command, &output, &status);
> +       (void)fwts_exec(command, &status);
>         (void)fwts_klog_write(fw, FWTS_RESUME "\n");
>         (void)fwts_klog_write(fw, "Finished fwts resume\n");
>         fwts_progress_message(fw, percent, "(Resumed)");
> -       fwts_text_list_free(output);
>         free(command);
>
>         if ((klog_post = fwts_klog_read()) == NULL)
> diff --git a/src/lib/src/fwts_efi_module.c b/src/lib/src/fwts_efi_module.c
> index e9d3b1a..565fcaf 100644
> --- a/src/lib/src/fwts_efi_module.c
> +++ b/src/lib/src/fwts_efi_module.c
> @@ -49,7 +49,6 @@ static int check_module_loaded(void)
>  int fwts_lib_efi_runtime_load_module(fwts_framework *fw)
>  {
>         struct stat statbuf;
> -       fwts_list *output;
>
>         if (check_module_loaded() != FWTS_OK) {
>                 fwts_log_error(fw, "Could not open /proc/modules for checking module loaded.");
> @@ -59,12 +58,10 @@ int fwts_lib_efi_runtime_load_module(fwts_framework *fw)
>         if (!module_already_loaded) {
>                 int status;
>
> -               if (fwts_pipe_exec("modprobe efi_runtime", &output, &status) != FWTS_OK) {
> +               if (fwts_exec("modprobe efi_runtime", &status) != FWTS_OK) {
>                         fwts_log_error(fw, "Load efi_runtime module error.");
>                         return FWTS_ERROR;
>                 } else {
> -                       if (output)
> -                               fwts_text_list_free(output);
>                         (void)check_module_loaded();
>                         if (!module_already_loaded) {
>                                 fwts_log_error(fw, "Could not load efi_runtime module.");
> @@ -89,8 +86,6 @@ int fwts_lib_efi_runtime_load_module(fwts_framework *fw)
>
>  int fwts_lib_efi_runtime_unload_module(fwts_framework *fw)
>  {
> -       fwts_list *output;
> -
>         if (check_module_loaded() != FWTS_OK) {
>                 fwts_log_error(fw, "Could not open /proc/modules for checking module loaded.");
>                 return FWTS_ERROR;
> @@ -98,12 +93,10 @@ int fwts_lib_efi_runtime_unload_module(fwts_framework *fw)
>         if (module_already_loaded) {
>                 int status;
>
> -               if (fwts_pipe_exec("modprobe -r efi_runtime", &output, &status) != FWTS_OK) {
> +               if (fwts_exec("modprobe -r efi_runtime", &status) != FWTS_OK) {
>                         fwts_log_error(fw, "Unload efi_runtime module error.");
>                         return FWTS_ERROR;
>                 } else {
> -                       if (output)
> -                               fwts_text_list_free(output);
>                         (void)check_module_loaded();
>                         if (module_already_loaded) {
>                                 fwts_log_error(fw, "Could not unload efi_runtime module.");
> --
> 1.8.5.2
>
>

Acked-by: Keng-Yu Lin <kengyu@canonical.com>
Ivan Hu - Jan. 2, 2014, 7:40 a.m.
On 12/30/2013 03:21 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The following changes use fwts_exec because we don't care about
> the output and we just discard it by default.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/acpi/s3/s3.c              |  4 +---
>   src/acpi/s3power/s3power.c    |  5 +----
>   src/acpi/s4/s4.c              |  4 +---
>   src/lib/src/fwts_efi_module.c | 11 ++---------
>   4 files changed, 5 insertions(+), 19 deletions(-)
>
> diff --git a/src/acpi/s3/s3.c b/src/acpi/s3/s3.c
> index 7a86641..4161ea2 100644
> --- a/src/acpi/s3/s3.c
> +++ b/src/acpi/s3/s3.c
> @@ -66,7 +66,6 @@ static int s3_do_suspend_resume(fwts_framework *fw,
>   	int delay,
>   	int percent)
>   {
> -	fwts_list *output;
>   	fwts_hwinfo hwinfo1, hwinfo2;
>   	int status;
>   	int duration;
> @@ -105,12 +104,11 @@ static int s3_do_suspend_resume(fwts_framework *fw,
>   	time(&t_start);
>   	(void)fwts_klog_write(fw, "Starting fwts suspend\n");
>   	(void)fwts_klog_write(fw, FWTS_SUSPEND "\n");
> -	(void)fwts_pipe_exec(command, &output, &status);
> +	(void)fwts_exec(command, &status);
>   	(void)fwts_klog_write(fw, FWTS_RESUME "\n");
>   	(void)fwts_klog_write(fw, "Finished fwts resume\n");
>   	time(&t_end);
>   	fwts_progress_message(fw, percent, "(Resumed)");
> -	fwts_text_list_free(output);
>   	free(command);
>
>   	duration = (int)(t_end - t_start);
> diff --git a/src/acpi/s3power/s3power.c b/src/acpi/s3power/s3power.c
> index 75d660d..18a4a17 100644
> --- a/src/acpi/s3power/s3power.c
> +++ b/src/acpi/s3power/s3power.c
> @@ -172,8 +172,6 @@ static int s3power_test(fwts_framework *fw)
>   	uint32_t capacity_before_mWh;
>   	uint32_t capacity_after_mWh;
>
> -	fwts_list *output;
> -
>   	if (s3power_wait_for_adapter_offline(fw, &offline) == FWTS_ERROR) {
>   		fwts_log_error(fw, "Cannot check if machine is running on battery, aborting test.");
>   		return FWTS_ABORTED;
> @@ -190,10 +188,9 @@ static int s3power_test(fwts_framework *fw)
>   	/* Do S3 here */
>   	fwts_progress_message(fw, 100, "(Suspending)");
>   	time(&t_start);
> -	(void)fwts_pipe_exec(PM_SUSPEND, &output, &status);
> +	(void)fwts_exec(PM_SUSPEND, &status);
>   	time(&t_end);
>   	fwts_progress_message(fw, 100, "(Resumed)");
> -	fwts_text_list_free(output);
>
>   	s3power_get_remaining_capacity(fw, &capacity_after_mAh, &capacity_after_mWh);
>
> diff --git a/src/acpi/s4/s4.c b/src/acpi/s4/s4.c
> index 48c0a30..701ee51 100644
> --- a/src/acpi/s4/s4.c
> +++ b/src/acpi/s4/s4.c
> @@ -97,7 +97,6 @@ static int s4_hibernate(fwts_framework *fw,
>   	int *failed_alloc_image,
>   	int percent)
>   {
> -	fwts_list *output;
>   	fwts_list *klog_pre, *klog_post, *klog_diff;
>   	fwts_hwinfo hwinfo1, hwinfo2;
>   	int status;
> @@ -136,11 +135,10 @@ static int s4_hibernate(fwts_framework *fw,
>   	fwts_progress_message(fw, percent, "(Hibernating)");
>   	(void)fwts_klog_write(fw, "Starting fwts hibernate\n");
>   	(void)fwts_klog_write(fw, FWTS_HIBERNATE "\n");
> -	(void)fwts_pipe_exec(command, &output, &status);
> +	(void)fwts_exec(command, &status);
>   	(void)fwts_klog_write(fw, FWTS_RESUME "\n");
>   	(void)fwts_klog_write(fw, "Finished fwts resume\n");
>   	fwts_progress_message(fw, percent, "(Resumed)");
> -	fwts_text_list_free(output);
>   	free(command);
>
>   	if ((klog_post = fwts_klog_read()) == NULL)
> diff --git a/src/lib/src/fwts_efi_module.c b/src/lib/src/fwts_efi_module.c
> index e9d3b1a..565fcaf 100644
> --- a/src/lib/src/fwts_efi_module.c
> +++ b/src/lib/src/fwts_efi_module.c
> @@ -49,7 +49,6 @@ static int check_module_loaded(void)
>   int fwts_lib_efi_runtime_load_module(fwts_framework *fw)
>   {
>   	struct stat statbuf;
> -	fwts_list *output;
>
>   	if (check_module_loaded() != FWTS_OK) {
>   		fwts_log_error(fw, "Could not open /proc/modules for checking module loaded.");
> @@ -59,12 +58,10 @@ int fwts_lib_efi_runtime_load_module(fwts_framework *fw)
>   	if (!module_already_loaded) {
>   		int status;
>
> -		if (fwts_pipe_exec("modprobe efi_runtime", &output, &status) != FWTS_OK) {
> +		if (fwts_exec("modprobe efi_runtime", &status) != FWTS_OK) {
>   			fwts_log_error(fw, "Load efi_runtime module error.");
>   			return FWTS_ERROR;
>   		} else {
> -			if (output)
> -				fwts_text_list_free(output);
>   			(void)check_module_loaded();
>   			if (!module_already_loaded) {
>   				fwts_log_error(fw, "Could not load efi_runtime module.");
> @@ -89,8 +86,6 @@ int fwts_lib_efi_runtime_load_module(fwts_framework *fw)
>
>   int fwts_lib_efi_runtime_unload_module(fwts_framework *fw)
>   {
> -	fwts_list *output;
> -
>   	if (check_module_loaded() != FWTS_OK) {
>   		fwts_log_error(fw, "Could not open /proc/modules for checking module loaded.");
>   		return FWTS_ERROR;
> @@ -98,12 +93,10 @@ int fwts_lib_efi_runtime_unload_module(fwts_framework *fw)
>   	if (module_already_loaded) {
>   		int status;
>
> -		if (fwts_pipe_exec("modprobe -r efi_runtime", &output, &status) != FWTS_OK) {
> +		if (fwts_exec("modprobe -r efi_runtime", &status) != FWTS_OK) {
>   			fwts_log_error(fw, "Unload efi_runtime module error.");
>   			return FWTS_ERROR;
>   		} else {
> -			if (output)
> -				fwts_text_list_free(output);
>   			(void)check_module_loaded();
>   			if (module_already_loaded) {
>   				fwts_log_error(fw, "Could not unload efi_runtime module.");
>

Acked-by: Ivan Hu <ivan.hu@canonical.com>

Patch

diff --git a/src/acpi/s3/s3.c b/src/acpi/s3/s3.c
index 7a86641..4161ea2 100644
--- a/src/acpi/s3/s3.c
+++ b/src/acpi/s3/s3.c
@@ -66,7 +66,6 @@  static int s3_do_suspend_resume(fwts_framework *fw,
 	int delay,
 	int percent)
 {
-	fwts_list *output;
 	fwts_hwinfo hwinfo1, hwinfo2;
 	int status;
 	int duration;
@@ -105,12 +104,11 @@  static int s3_do_suspend_resume(fwts_framework *fw,
 	time(&t_start);
 	(void)fwts_klog_write(fw, "Starting fwts suspend\n");
 	(void)fwts_klog_write(fw, FWTS_SUSPEND "\n");
-	(void)fwts_pipe_exec(command, &output, &status);
+	(void)fwts_exec(command, &status);
 	(void)fwts_klog_write(fw, FWTS_RESUME "\n");
 	(void)fwts_klog_write(fw, "Finished fwts resume\n");
 	time(&t_end);
 	fwts_progress_message(fw, percent, "(Resumed)");
-	fwts_text_list_free(output);
 	free(command);
 
 	duration = (int)(t_end - t_start);
diff --git a/src/acpi/s3power/s3power.c b/src/acpi/s3power/s3power.c
index 75d660d..18a4a17 100644
--- a/src/acpi/s3power/s3power.c
+++ b/src/acpi/s3power/s3power.c
@@ -172,8 +172,6 @@  static int s3power_test(fwts_framework *fw)
 	uint32_t capacity_before_mWh;
 	uint32_t capacity_after_mWh;
 
-	fwts_list *output;
-
 	if (s3power_wait_for_adapter_offline(fw, &offline) == FWTS_ERROR) {
 		fwts_log_error(fw, "Cannot check if machine is running on battery, aborting test.");
 		return FWTS_ABORTED;
@@ -190,10 +188,9 @@  static int s3power_test(fwts_framework *fw)
 	/* Do S3 here */
 	fwts_progress_message(fw, 100, "(Suspending)");
 	time(&t_start);
-	(void)fwts_pipe_exec(PM_SUSPEND, &output, &status);
+	(void)fwts_exec(PM_SUSPEND, &status);
 	time(&t_end);
 	fwts_progress_message(fw, 100, "(Resumed)");
-	fwts_text_list_free(output);
 
 	s3power_get_remaining_capacity(fw, &capacity_after_mAh, &capacity_after_mWh);
 
diff --git a/src/acpi/s4/s4.c b/src/acpi/s4/s4.c
index 48c0a30..701ee51 100644
--- a/src/acpi/s4/s4.c
+++ b/src/acpi/s4/s4.c
@@ -97,7 +97,6 @@  static int s4_hibernate(fwts_framework *fw,
 	int *failed_alloc_image,
 	int percent)
 {
-	fwts_list *output;
 	fwts_list *klog_pre, *klog_post, *klog_diff;
 	fwts_hwinfo hwinfo1, hwinfo2;
 	int status;
@@ -136,11 +135,10 @@  static int s4_hibernate(fwts_framework *fw,
 	fwts_progress_message(fw, percent, "(Hibernating)");
 	(void)fwts_klog_write(fw, "Starting fwts hibernate\n");
 	(void)fwts_klog_write(fw, FWTS_HIBERNATE "\n");
-	(void)fwts_pipe_exec(command, &output, &status);
+	(void)fwts_exec(command, &status);
 	(void)fwts_klog_write(fw, FWTS_RESUME "\n");
 	(void)fwts_klog_write(fw, "Finished fwts resume\n");
 	fwts_progress_message(fw, percent, "(Resumed)");
-	fwts_text_list_free(output);
 	free(command);
 
 	if ((klog_post = fwts_klog_read()) == NULL)
diff --git a/src/lib/src/fwts_efi_module.c b/src/lib/src/fwts_efi_module.c
index e9d3b1a..565fcaf 100644
--- a/src/lib/src/fwts_efi_module.c
+++ b/src/lib/src/fwts_efi_module.c
@@ -49,7 +49,6 @@  static int check_module_loaded(void)
 int fwts_lib_efi_runtime_load_module(fwts_framework *fw)
 {
 	struct stat statbuf;
-	fwts_list *output;
 
 	if (check_module_loaded() != FWTS_OK) {
 		fwts_log_error(fw, "Could not open /proc/modules for checking module loaded.");
@@ -59,12 +58,10 @@  int fwts_lib_efi_runtime_load_module(fwts_framework *fw)
 	if (!module_already_loaded) {
 		int status;
 
-		if (fwts_pipe_exec("modprobe efi_runtime", &output, &status) != FWTS_OK) {
+		if (fwts_exec("modprobe efi_runtime", &status) != FWTS_OK) {
 			fwts_log_error(fw, "Load efi_runtime module error.");
 			return FWTS_ERROR;
 		} else {
-			if (output)
-				fwts_text_list_free(output);
 			(void)check_module_loaded();
 			if (!module_already_loaded) {
 				fwts_log_error(fw, "Could not load efi_runtime module.");
@@ -89,8 +86,6 @@  int fwts_lib_efi_runtime_load_module(fwts_framework *fw)
 
 int fwts_lib_efi_runtime_unload_module(fwts_framework *fw)
 {
-	fwts_list *output;
-
 	if (check_module_loaded() != FWTS_OK) {
 		fwts_log_error(fw, "Could not open /proc/modules for checking module loaded.");
 		return FWTS_ERROR;
@@ -98,12 +93,10 @@  int fwts_lib_efi_runtime_unload_module(fwts_framework *fw)
 	if (module_already_loaded) {
 		int status;
 
-		if (fwts_pipe_exec("modprobe -r efi_runtime", &output, &status) != FWTS_OK) {
+		if (fwts_exec("modprobe -r efi_runtime", &status) != FWTS_OK) {
 			fwts_log_error(fw, "Unload efi_runtime module error.");
 			return FWTS_ERROR;
 		} else {
-			if (output)
-				fwts_text_list_free(output);
 			(void)check_module_loaded();
 			if (module_already_loaded) {
 				fwts_log_error(fw, "Could not unload efi_runtime module.");