Patchwork [11/11] lib: fwts_summary: constify function arguments where appropriate

login
register
mail settings
Submitter Colin King
Date Oct. 16, 2012, 7:20 p.m.
Message ID <1350415248-16965-12-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/191864/
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_summary.h |    2 +-
 src/lib/src/fwts_summary.c     |   13 ++++++++++---
 2 files changed, 11 insertions(+), 4 deletions(-)
Keng-Yu Lin - Oct. 18, 2012, 6:50 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_summary.h |    2 +-
>  src/lib/src/fwts_summary.c     |   13 ++++++++++---
>  2 files changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/src/lib/include/fwts_summary.h b/src/lib/include/fwts_summary.h
> index 6478020..7b73a3b 100644
> --- a/src/lib/include/fwts_summary.h
> +++ b/src/lib/include/fwts_summary.h
> @@ -27,7 +27,7 @@
>
>  int fwts_summary_init(void);
>  void fwts_summary_deinit(void);
> -int fwts_summary_add(fwts_framework *fw, const char *test, fwts_log_level level, char *text);
> +int fwts_summary_add(fwts_framework *fw, const char *test, const fwts_log_level level, const char *text);
>  int fwts_summary_report(fwts_framework *fw, fwts_list *test_list);
>
>  #endif
> diff --git a/src/lib/src/fwts_summary.c b/src/lib/src/fwts_summary.c
> index 5c401b1..c435aa5 100644
> --- a/src/lib/src/fwts_summary.c
> +++ b/src/lib/src/fwts_summary.c
> @@ -95,7 +95,7 @@ void fwts_summary_deinit(void)
>                         fwts_list_free(fwts_summaries[i], fwts_summary_item_free);
>  }
>
> -static int fwts_summary_level_to_index(fwts_log_level level)
> +static int fwts_summary_level_to_index(const fwts_log_level level)
>  {
>         switch (level) {
>         case LOG_LEVEL_CRITICAL:
> @@ -116,7 +116,11 @@ static int fwts_summary_level_to_index(fwts_log_level level)
>   *     add an error summary for a test with error message text at given
>   *     error level to the list of summaries.
>   */
> -int fwts_summary_add(fwts_framework *fw, const char *test, fwts_log_level level, char *text)
> +int fwts_summary_add(
> +       fwts_framework *fw,
> +       const char *test,
> +       const fwts_log_level level,
> +       const char *text)
>  {
>         fwts_list_link  *item;
>         fwts_summary_item *summary_item = NULL;
> @@ -157,7 +161,10 @@ int fwts_summary_add(fwts_framework *fw, const char *test, fwts_log_level level,
>         return FWTS_OK;
>  }
>
> -static void fwts_summary_format_field(char *buffer, int buflen, uint32_t value)
> +static void fwts_summary_format_field(
> +       char *buffer,
> +       const int buflen,
> +       const uint32_t value)
>  {
>         if (value)
>                 snprintf(buffer, buflen, "%5u", value);
> --
> 1.7.10.4
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>
Ivan Hu - Oct. 22, 2012, 9:34 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_summary.h |    2 +-
>   src/lib/src/fwts_summary.c     |   13 ++++++++++---
>   2 files changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/src/lib/include/fwts_summary.h b/src/lib/include/fwts_summary.h
> index 6478020..7b73a3b 100644
> --- a/src/lib/include/fwts_summary.h
> +++ b/src/lib/include/fwts_summary.h
> @@ -27,7 +27,7 @@
>
>   int fwts_summary_init(void);
>   void fwts_summary_deinit(void);
> -int fwts_summary_add(fwts_framework *fw, const char *test, fwts_log_level level, char *text);
> +int fwts_summary_add(fwts_framework *fw, const char *test, const fwts_log_level level, const char *text);
>   int fwts_summary_report(fwts_framework *fw, fwts_list *test_list);
>
>   #endif
> diff --git a/src/lib/src/fwts_summary.c b/src/lib/src/fwts_summary.c
> index 5c401b1..c435aa5 100644
> --- a/src/lib/src/fwts_summary.c
> +++ b/src/lib/src/fwts_summary.c
> @@ -95,7 +95,7 @@ void fwts_summary_deinit(void)
>   			fwts_list_free(fwts_summaries[i], fwts_summary_item_free);
>   }
>
> -static int fwts_summary_level_to_index(fwts_log_level level)
> +static int fwts_summary_level_to_index(const fwts_log_level level)
>   {
>   	switch (level) {
>   	case LOG_LEVEL_CRITICAL:
> @@ -116,7 +116,11 @@ static int fwts_summary_level_to_index(fwts_log_level level)
>    *	add an error summary for a test with error message text at given
>    *	error level to the list of summaries.
>    */
> -int fwts_summary_add(fwts_framework *fw, const char *test, fwts_log_level level, char *text)
> +int fwts_summary_add(
> +	fwts_framework *fw,
> +	const char *test,
> +	const fwts_log_level level,
> +	const char *text)
>   {
>   	fwts_list_link	*item;
>   	fwts_summary_item *summary_item = NULL;
> @@ -157,7 +161,10 @@ int fwts_summary_add(fwts_framework *fw, const char *test, fwts_log_level level,
>   	return FWTS_OK;
>   }
>
> -static void fwts_summary_format_field(char *buffer, int buflen, uint32_t value)
> +static void fwts_summary_format_field(
> +	char *buffer,
> +	const int buflen,
> +	const uint32_t value)
>   {
>   	if (value)
>   		snprintf(buffer, buflen, "%5u", value);
>

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

Patch

diff --git a/src/lib/include/fwts_summary.h b/src/lib/include/fwts_summary.h
index 6478020..7b73a3b 100644
--- a/src/lib/include/fwts_summary.h
+++ b/src/lib/include/fwts_summary.h
@@ -27,7 +27,7 @@ 
 
 int fwts_summary_init(void);
 void fwts_summary_deinit(void);
-int fwts_summary_add(fwts_framework *fw, const char *test, fwts_log_level level, char *text);
+int fwts_summary_add(fwts_framework *fw, const char *test, const fwts_log_level level, const char *text);
 int fwts_summary_report(fwts_framework *fw, fwts_list *test_list);
 
 #endif
diff --git a/src/lib/src/fwts_summary.c b/src/lib/src/fwts_summary.c
index 5c401b1..c435aa5 100644
--- a/src/lib/src/fwts_summary.c
+++ b/src/lib/src/fwts_summary.c
@@ -95,7 +95,7 @@  void fwts_summary_deinit(void)
 			fwts_list_free(fwts_summaries[i], fwts_summary_item_free);
 }
 
-static int fwts_summary_level_to_index(fwts_log_level level)
+static int fwts_summary_level_to_index(const fwts_log_level level)
 {
 	switch (level) {
 	case LOG_LEVEL_CRITICAL:
@@ -116,7 +116,11 @@  static int fwts_summary_level_to_index(fwts_log_level level)
  *	add an error summary for a test with error message text at given
  *	error level to the list of summaries.
  */
-int fwts_summary_add(fwts_framework *fw, const char *test, fwts_log_level level, char *text)
+int fwts_summary_add(
+	fwts_framework *fw,
+	const char *test,
+	const fwts_log_level level,
+	const char *text)
 {
 	fwts_list_link	*item;
 	fwts_summary_item *summary_item = NULL;
@@ -157,7 +161,10 @@  int fwts_summary_add(fwts_framework *fw, const char *test, fwts_log_level level,
 	return FWTS_OK;
 }
 
-static void fwts_summary_format_field(char *buffer, int buflen, uint32_t value)
+static void fwts_summary_format_field(
+	char *buffer,
+	const int buflen,
+	const uint32_t value)
 {
 	if (value)
 		snprintf(buffer, buflen, "%5u", value);