Patchwork [1/2] lib: fwts_ac_adapter: constify some struct fields and variables

login
register
mail settings
Submitter Colin King
Date Dec. 16, 2012, 11:22 p.m.
Message ID <1355700145-5677-2-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/206747/
State Accepted
Headers show

Comments

Colin King - Dec. 16, 2012, 11:22 p.m.
From: Colin Ian King <colin.king@canonical.com>

Use const where appropriate in a few more places.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/lib/src/fwts_ac_adapter.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
Keng-Yu Lin - Dec. 18, 2012, 3:51 a.m.
On Mon, Dec 17, 2012 at 7:22 AM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Use const where appropriate in a few more places.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/lib/src/fwts_ac_adapter.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/src/lib/src/fwts_ac_adapter.c b/src/lib/src/fwts_ac_adapter.c
> index 9db1748..12cec04 100644
> --- a/src/lib/src/fwts_ac_adapter.c
> +++ b/src/lib/src/fwts_ac_adapter.c
> @@ -35,11 +35,11 @@
>  #define PROC_INTERFACE         (0x1)
>
>  typedef struct {
> -       char *path;     /* Path name of interface */
> -       char *state;    /* Name of online/offline status */
> -       char *offline;  /* Contents of state when offline */
> -       char *online;   /* Contents of state when online */
> -       char *type;     /* /sys/class type to indicate Mains power, NULL if not used */
> +       const char *path;       /* Path name of interface */
> +       const char *state;      /* Name of online/offline status */
> +       const char *offline;    /* Contents of state when offline */
> +       const char *online;     /* Contents of state when online */
> +       const char *type;       /* /sys/class type to indicate Mains power, NULL if not used */
>  } fwts_ac_interface_info;
>
>  static fwts_ac_interface_info fwts_ac_interfaces[] = {
> @@ -106,7 +106,7 @@ int fwts_ac_adapter_get_state(const int state, int *matching, int *not_matching)
>
>                         snprintf(path, sizeof(path), "%s/%s/%s", ac_interface->path, entry->d_name, ac_interface->state);
>                         if ((data = fwts_get(path)) != NULL) {
> -                               char *state_text = "";
> +                               const char *state_text = "";
>
>                                 switch (state) {
>                                 case FWTS_AC_ADAPTER_ANY:
> --
> 1.8.0
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>
Alex Hung - Dec. 20, 2012, 9:53 a.m.
On 12/17/2012 07:22 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Use const where appropriate in a few more places.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/lib/src/fwts_ac_adapter.c | 12 ++++++------
>   1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/src/lib/src/fwts_ac_adapter.c b/src/lib/src/fwts_ac_adapter.c
> index 9db1748..12cec04 100644
> --- a/src/lib/src/fwts_ac_adapter.c
> +++ b/src/lib/src/fwts_ac_adapter.c
> @@ -35,11 +35,11 @@
>   #define PROC_INTERFACE		(0x1)
>
>   typedef struct {
> -	char *path;	/* Path name of interface */
> -	char *state;	/* Name of online/offline status */
> -	char *offline;	/* Contents of state when offline */
> -	char *online;	/* Contents of state when online */
> -	char *type;	/* /sys/class type to indicate Mains power, NULL if not used */
> +	const char *path;	/* Path name of interface */
> +	const char *state;	/* Name of online/offline status */
> +	const char *offline;	/* Contents of state when offline */
> +	const char *online;	/* Contents of state when online */
> +	const char *type;	/* /sys/class type to indicate Mains power, NULL if not used */
>   } fwts_ac_interface_info;
>
>   static fwts_ac_interface_info fwts_ac_interfaces[] = {
> @@ -106,7 +106,7 @@ int fwts_ac_adapter_get_state(const int state, int *matching, int *not_matching)
>
>   			snprintf(path, sizeof(path), "%s/%s/%s", ac_interface->path, entry->d_name, ac_interface->state);
>   			if ((data = fwts_get(path)) != NULL) {
> -				char *state_text = "";
> +				const char *state_text = "";
>
>   				switch (state) {
>   				case FWTS_AC_ADAPTER_ANY:
>
Acked-by: Alex Hung <alex.hung@canonical.com>

Patch

diff --git a/src/lib/src/fwts_ac_adapter.c b/src/lib/src/fwts_ac_adapter.c
index 9db1748..12cec04 100644
--- a/src/lib/src/fwts_ac_adapter.c
+++ b/src/lib/src/fwts_ac_adapter.c
@@ -35,11 +35,11 @@ 
 #define PROC_INTERFACE		(0x1)
 
 typedef struct {
-	char *path;	/* Path name of interface */
-	char *state;	/* Name of online/offline status */
-	char *offline;	/* Contents of state when offline */
-	char *online;	/* Contents of state when online */
-	char *type;	/* /sys/class type to indicate Mains power, NULL if not used */
+	const char *path;	/* Path name of interface */
+	const char *state;	/* Name of online/offline status */
+	const char *offline;	/* Contents of state when offline */
+	const char *online;	/* Contents of state when online */
+	const char *type;	/* /sys/class type to indicate Mains power, NULL if not used */
 } fwts_ac_interface_info;
 
 static fwts_ac_interface_info fwts_ac_interfaces[] = {
@@ -106,7 +106,7 @@  int fwts_ac_adapter_get_state(const int state, int *matching, int *not_matching)
 
 			snprintf(path, sizeof(path), "%s/%s/%s", ac_interface->path, entry->d_name, ac_interface->state);
 			if ((data = fwts_get(path)) != NULL) {
-				char *state_text = "";
+				const char *state_text = "";
 
 				switch (state) {
 				case FWTS_AC_ADAPTER_ANY: