Patchwork [02/11] lib: fwts_acpi_method: constify funcs and static tables

login
register
mail settings
Submitter Colin King
Date Oct. 16, 2012, 7:20 p.m.
Message ID <1350415248-16965-3-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/191856/
State Accepted
Headers show

Comments

Colin King - Oct. 16, 2012, 7:20 p.m.
From: Colin Ian King <colin.king@canonical.com>

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/lib/include/fwts_acpi_method.h |    6 +++---
 src/lib/src/fwts_acpi_method.c     |   19 +++++++++++++------
 2 files changed, 16 insertions(+), 9 deletions(-)
Keng-Yu Lin - Oct. 18, 2012, 6:47 a.m.
On Wed, Oct 17, 2012 at 3:20 AM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/lib/include/fwts_acpi_method.h |    6 +++---
>  src/lib/src/fwts_acpi_method.c     |   19 +++++++++++++------
>  2 files changed, 16 insertions(+), 9 deletions(-)
>
> diff --git a/src/lib/include/fwts_acpi_method.h b/src/lib/include/fwts_acpi_method.h
> index acaf8db..0313ceb 100644
> --- a/src/lib/include/fwts_acpi_method.h
> +++ b/src/lib/include/fwts_acpi_method.h
> @@ -27,10 +27,10 @@
>
>  int fwts_method_init(fwts_framework *fw);
>  int fwts_method_deinit(fwts_framework *fw);
> -char *fwts_method_exists(char *name);
> +char *fwts_method_exists(const char *name);
>  fwts_list *fwts_method_get_names(void);
> -void fwts_method_dump_object(fwts_framework *fw, ACPI_OBJECT *obj);
> -void fwts_method_evaluate_report_error(fwts_framework *fw, char *name, ACPI_STATUS status);
> +void fwts_method_dump_object(fwts_framework *fw, const ACPI_OBJECT *obj);
> +void fwts_method_evaluate_report_error(fwts_framework *fw, const char *name, const ACPI_STATUS status);
>  ACPI_STATUS fwts_method_evaluate(fwts_framework *fw, char *name, ACPI_OBJECT_LIST *arg_list, ACPI_BUFFER *buf);
>
>  #endif
> diff --git a/src/lib/src/fwts_acpi_method.c b/src/lib/src/fwts_acpi_method.c
> index 7974545..d9d9883 100644
> --- a/src/lib/src/fwts_acpi_method.c
> +++ b/src/lib/src/fwts_acpi_method.c
> @@ -28,13 +28,13 @@
>  #include "fwts_acpi_method.h"
>
>  typedef struct {
> -       ACPI_STATUS status;
> +       const ACPI_STATUS status;
>         const fwts_log_level level;
>         const char *error_type;
>         const char *error_text;
>  } acpi_eval_error;
>
> -static acpi_eval_error  errors[] = {
> +static const acpi_eval_error errors[] = {
>         /* ACPI_STATUS                  fwts_log_level          error_type              error_text */
>         { AE_ERROR,                     LOG_LEVEL_HIGH,         "AEError",              "Environment error" },
>         { AE_NO_ACPI_TABLES,            LOG_LEVEL_HIGH,         "AENoACPITables",       "NO ACPI tables" },
> @@ -160,7 +160,7 @@ fwts_list *fwts_method_get_names(void)
>   *  fwts_method_exists()
>   *     return first matching name
>   */
> -char *fwts_method_exists(char *name)
> +char *fwts_method_exists(const char *name)
>  {
>         size_t name_len = strlen(name);
>         fwts_list_link  *item;
> @@ -180,7 +180,11 @@ char *fwts_method_exists(char *name)
>   *   fwts_method_dump_object()
>   *     dump out an object, minimal form
>   */
> -static void fwts_method_dump_object_recursive(fwts_framework *fw, ACPI_OBJECT *obj, int depth, int index)
> +static void fwts_method_dump_object_recursive(
> +       fwts_framework *fw,
> +       const ACPI_OBJECT *obj,
> +       const int depth,
> +       const int index)
>  {
>         uint32_t i;
>         char index_buf[5];
> @@ -222,7 +226,7 @@ static void fwts_method_dump_object_recursive(fwts_framework *fw, ACPI_OBJECT *o
>   *   fwts_method_dump_object()
>   *     dump out an object, minimal form
>   */
> -void fwts_method_dump_object(fwts_framework *fw, ACPI_OBJECT *obj)
> +void fwts_method_dump_object(fwts_framework *fw, const ACPI_OBJECT *obj)
>  {
>         fwts_method_dump_object_recursive(fw, obj, 1, -1);
>  }
> @@ -231,7 +235,10 @@ void fwts_method_dump_object(fwts_framework *fw, ACPI_OBJECT *obj)
>   *  fwts_method_evaluate_report_error()
>   *     report any errors found during object evaluation
>   */
> -void fwts_method_evaluate_report_error(fwts_framework *fw, char *name, ACPI_STATUS status)
> +void fwts_method_evaluate_report_error(
> +       fwts_framework *fw,
> +       const char *name,
> +       const ACPI_STATUS status)
>  {
>         int i;
>
> --
> 1.7.10.4
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>
Ivan Hu - Oct. 22, 2012, 9:31 a.m.
On 10/17/2012 03:20 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/lib/include/fwts_acpi_method.h |    6 +++---
>   src/lib/src/fwts_acpi_method.c     |   19 +++++++++++++------
>   2 files changed, 16 insertions(+), 9 deletions(-)
>
> diff --git a/src/lib/include/fwts_acpi_method.h b/src/lib/include/fwts_acpi_method.h
> index acaf8db..0313ceb 100644
> --- a/src/lib/include/fwts_acpi_method.h
> +++ b/src/lib/include/fwts_acpi_method.h
> @@ -27,10 +27,10 @@
>
>   int fwts_method_init(fwts_framework *fw);
>   int fwts_method_deinit(fwts_framework *fw);
> -char *fwts_method_exists(char *name);
> +char *fwts_method_exists(const char *name);
>   fwts_list *fwts_method_get_names(void);
> -void fwts_method_dump_object(fwts_framework *fw, ACPI_OBJECT *obj);
> -void fwts_method_evaluate_report_error(fwts_framework *fw, char *name, ACPI_STATUS status);
> +void fwts_method_dump_object(fwts_framework *fw, const ACPI_OBJECT *obj);
> +void fwts_method_evaluate_report_error(fwts_framework *fw, const char *name, const ACPI_STATUS status);
>   ACPI_STATUS fwts_method_evaluate(fwts_framework *fw, char *name, ACPI_OBJECT_LIST *arg_list, ACPI_BUFFER *buf);
>
>   #endif
> diff --git a/src/lib/src/fwts_acpi_method.c b/src/lib/src/fwts_acpi_method.c
> index 7974545..d9d9883 100644
> --- a/src/lib/src/fwts_acpi_method.c
> +++ b/src/lib/src/fwts_acpi_method.c
> @@ -28,13 +28,13 @@
>   #include "fwts_acpi_method.h"
>
>   typedef struct {
> -	ACPI_STATUS status;
> +	const ACPI_STATUS status;
>   	const fwts_log_level level;
>   	const char *error_type;
>   	const char *error_text;
>   } acpi_eval_error;
>
> -static acpi_eval_error  errors[] = {
> +static const acpi_eval_error errors[] = {
>   	/* ACPI_STATUS			fwts_log_level		error_type		error_text */
>   	{ AE_ERROR,			LOG_LEVEL_HIGH,		"AEError",		"Environment error" },
>   	{ AE_NO_ACPI_TABLES,		LOG_LEVEL_HIGH,		"AENoACPITables",	"NO ACPI tables" },
> @@ -160,7 +160,7 @@ fwts_list *fwts_method_get_names(void)
>    *  fwts_method_exists()
>    *	return first matching name
>    */
> -char *fwts_method_exists(char *name)
> +char *fwts_method_exists(const char *name)
>   {
>   	size_t name_len = strlen(name);
>   	fwts_list_link	*item;
> @@ -180,7 +180,11 @@ char *fwts_method_exists(char *name)
>    *   fwts_method_dump_object()
>    *	dump out an object, minimal form
>    */
> -static void fwts_method_dump_object_recursive(fwts_framework *fw, ACPI_OBJECT *obj, int depth, int index)
> +static void fwts_method_dump_object_recursive(
> +	fwts_framework *fw,
> +	const ACPI_OBJECT *obj,
> +	const int depth,
> +	const int index)
>   {
>   	uint32_t i;
>   	char index_buf[5];
> @@ -222,7 +226,7 @@ static void fwts_method_dump_object_recursive(fwts_framework *fw, ACPI_OBJECT *o
>    *   fwts_method_dump_object()
>    *	dump out an object, minimal form
>    */
> -void fwts_method_dump_object(fwts_framework *fw, ACPI_OBJECT *obj)
> +void fwts_method_dump_object(fwts_framework *fw, const ACPI_OBJECT *obj)
>   {
>   	fwts_method_dump_object_recursive(fw, obj, 1, -1);
>   }
> @@ -231,7 +235,10 @@ void fwts_method_dump_object(fwts_framework *fw, ACPI_OBJECT *obj)
>    *  fwts_method_evaluate_report_error()
>    *	report any errors found during object evaluation
>    */
> -void fwts_method_evaluate_report_error(fwts_framework *fw, char *name, ACPI_STATUS status)
> +void fwts_method_evaluate_report_error(
> +	fwts_framework *fw,
> +	const char *name,
> +	const ACPI_STATUS status)
>   {
>   	int i;
>
>

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

Patch

diff --git a/src/lib/include/fwts_acpi_method.h b/src/lib/include/fwts_acpi_method.h
index acaf8db..0313ceb 100644
--- a/src/lib/include/fwts_acpi_method.h
+++ b/src/lib/include/fwts_acpi_method.h
@@ -27,10 +27,10 @@ 
 
 int fwts_method_init(fwts_framework *fw);
 int fwts_method_deinit(fwts_framework *fw);
-char *fwts_method_exists(char *name);
+char *fwts_method_exists(const char *name);
 fwts_list *fwts_method_get_names(void);
-void fwts_method_dump_object(fwts_framework *fw, ACPI_OBJECT *obj);
-void fwts_method_evaluate_report_error(fwts_framework *fw, char *name, ACPI_STATUS status);
+void fwts_method_dump_object(fwts_framework *fw, const ACPI_OBJECT *obj);
+void fwts_method_evaluate_report_error(fwts_framework *fw, const char *name, const ACPI_STATUS status);
 ACPI_STATUS fwts_method_evaluate(fwts_framework *fw, char *name, ACPI_OBJECT_LIST *arg_list, ACPI_BUFFER *buf);
 
 #endif
diff --git a/src/lib/src/fwts_acpi_method.c b/src/lib/src/fwts_acpi_method.c
index 7974545..d9d9883 100644
--- a/src/lib/src/fwts_acpi_method.c
+++ b/src/lib/src/fwts_acpi_method.c
@@ -28,13 +28,13 @@ 
 #include "fwts_acpi_method.h"
 
 typedef struct {
-	ACPI_STATUS status;
+	const ACPI_STATUS status;
 	const fwts_log_level level;
 	const char *error_type;
 	const char *error_text;
 } acpi_eval_error;
 
-static acpi_eval_error  errors[] = {
+static const acpi_eval_error errors[] = {
 	/* ACPI_STATUS			fwts_log_level		error_type		error_text */
 	{ AE_ERROR,			LOG_LEVEL_HIGH,		"AEError",		"Environment error" },
 	{ AE_NO_ACPI_TABLES,		LOG_LEVEL_HIGH,		"AENoACPITables",	"NO ACPI tables" },
@@ -160,7 +160,7 @@  fwts_list *fwts_method_get_names(void)
  *  fwts_method_exists()
  *	return first matching name
  */
-char *fwts_method_exists(char *name)
+char *fwts_method_exists(const char *name)
 {
 	size_t name_len = strlen(name);
 	fwts_list_link	*item;
@@ -180,7 +180,11 @@  char *fwts_method_exists(char *name)
  *   fwts_method_dump_object()
  *	dump out an object, minimal form
  */
-static void fwts_method_dump_object_recursive(fwts_framework *fw, ACPI_OBJECT *obj, int depth, int index)
+static void fwts_method_dump_object_recursive(
+	fwts_framework *fw,
+	const ACPI_OBJECT *obj,
+	const int depth,
+	const int index)
 {
 	uint32_t i;
 	char index_buf[5];
@@ -222,7 +226,7 @@  static void fwts_method_dump_object_recursive(fwts_framework *fw, ACPI_OBJECT *o
  *   fwts_method_dump_object()
  *	dump out an object, minimal form
  */
-void fwts_method_dump_object(fwts_framework *fw, ACPI_OBJECT *obj)
+void fwts_method_dump_object(fwts_framework *fw, const ACPI_OBJECT *obj)
 {
 	fwts_method_dump_object_recursive(fw, obj, 1, -1);
 }
@@ -231,7 +235,10 @@  void fwts_method_dump_object(fwts_framework *fw, ACPI_OBJECT *obj)
  *  fwts_method_evaluate_report_error()
  *	report any errors found during object evaluation
  */
-void fwts_method_evaluate_report_error(fwts_framework *fw, char *name, ACPI_STATUS status)
+void fwts_method_evaluate_report_error(
+	fwts_framework *fw,
+	const char *name,
+	const ACPI_STATUS status)
 {
 	int i;