[08/13] lib: fwts_keymap: some minor fwts coding style changes
diff mbox series

Message ID 20180814112435.22166-9-colin.king@canonical.com
State Accepted
Headers show
Series
  • lib: minor code clean up
Related show

Commit Message

Colin King Aug. 14, 2018, 11:24 a.m. UTC
From: Colin Ian King <colin.king@canonical.com>

No functional change.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/lib/src/fwts_keymap.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Comments

Alex Hung Aug. 14, 2018, 7:15 p.m. UTC | #1
On 2018-08-14 04:24 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> No functional change.
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/lib/src/fwts_keymap.c | 11 ++++++-----
>   1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/src/lib/src/fwts_keymap.c b/src/lib/src/fwts_keymap.c
> index a3256630..296c7443 100644
> --- a/src/lib/src/fwts_keymap.c
> +++ b/src/lib/src/fwts_keymap.c
> @@ -31,6 +31,7 @@
>   static void fwts_keymap_keycode_free(void *data)
>   {
>   	fwts_keycode *keycode = (fwts_keycode*)data;
> +
>   	free(keycode->keyname);
>   	free(keycode->keytext);
>   	free(keycode);
> @@ -70,24 +71,23 @@ fwts_list *fwts_keymap_load(const char *machine)
>   	while (fgets(buffer, sizeof(buffer), fp) != NULL) {
>   		fwts_keycode *key;
>   		char *str = buffer;
> -		int scancode;
>   		char *keyname = NULL;
>   		char *keytext = NULL;
> +		int scancode;
>   
>   		scancode = strtoul(buffer, &str, 16);
> -
> -		if (str == NULL || *str == '\0')
> +		if ((str == NULL) || (*str == '\0'))
>   			continue;
>   
>   		/* Skip over whitespace */
> -		while (*str != '\0' && isspace(*str))
> +		while ((*str != '\0') && isspace(*str))
>   			str++;
>   		if (*str == '\0')
>   			continue;
>   
>   		keyname = str;
>   		/* Skip over keyname */
> -		while (*str != '\0' && !isspace(*str))
> +		while ((*str != '\0') && !isspace(*str))
>   			str++;
>   
>   		keytext = keyname;  /* Default if we cannot find human readable name */
> @@ -132,6 +132,7 @@ fwts_keycode *fwts_keymap_find_scancode(fwts_list *keymap, const int scancode)
>   
>   	fwts_list_foreach(item, keymap) {
>   		fwts_keycode *keycode = fwts_list_data(fwts_keycode*, item);
> +
>   		if (keycode->scancode == scancode)
>   			return keycode;
>   	}
> 


Acked-by: Alex Hung <alex.hung@canonical.com>
ivanhu Aug. 16, 2018, 9:04 a.m. UTC | #2
On 08/14/2018 07:24 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> No functional change.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/lib/src/fwts_keymap.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/src/lib/src/fwts_keymap.c b/src/lib/src/fwts_keymap.c
> index a3256630..296c7443 100644
> --- a/src/lib/src/fwts_keymap.c
> +++ b/src/lib/src/fwts_keymap.c
> @@ -31,6 +31,7 @@
>  static void fwts_keymap_keycode_free(void *data)
>  {
>  	fwts_keycode *keycode = (fwts_keycode*)data;
> +
>  	free(keycode->keyname);
>  	free(keycode->keytext);
>  	free(keycode);
> @@ -70,24 +71,23 @@ fwts_list *fwts_keymap_load(const char *machine)
>  	while (fgets(buffer, sizeof(buffer), fp) != NULL) {
>  		fwts_keycode *key;
>  		char *str = buffer;
> -		int scancode;
>  		char *keyname = NULL;
>  		char *keytext = NULL;
> +		int scancode;
>  
>  		scancode = strtoul(buffer, &str, 16);
> -
> -		if (str == NULL || *str == '\0')
> +		if ((str == NULL) || (*str == '\0'))
>  			continue;
>  
>  		/* Skip over whitespace */
> -		while (*str != '\0' && isspace(*str))
> +		while ((*str != '\0') && isspace(*str))
>  			str++;
>  		if (*str == '\0')
>  			continue;
>  
>  		keyname = str;
>  		/* Skip over keyname */
> -		while (*str != '\0' && !isspace(*str))
> +		while ((*str != '\0') && !isspace(*str))
>  			str++;
>  
>  		keytext = keyname;  /* Default if we cannot find human readable name */
> @@ -132,6 +132,7 @@ fwts_keycode *fwts_keymap_find_scancode(fwts_list *keymap, const int scancode)
>  
>  	fwts_list_foreach(item, keymap) {
>  		fwts_keycode *keycode = fwts_list_data(fwts_keycode*, item);
> +
>  		if (keycode->scancode == scancode)
>  			return keycode;
>  	}
Acked-by: Ivan Hu <ivan.hu@canonical.com>

Patch
diff mbox series

diff --git a/src/lib/src/fwts_keymap.c b/src/lib/src/fwts_keymap.c
index a3256630..296c7443 100644
--- a/src/lib/src/fwts_keymap.c
+++ b/src/lib/src/fwts_keymap.c
@@ -31,6 +31,7 @@ 
 static void fwts_keymap_keycode_free(void *data)
 {
 	fwts_keycode *keycode = (fwts_keycode*)data;
+
 	free(keycode->keyname);
 	free(keycode->keytext);
 	free(keycode);
@@ -70,24 +71,23 @@  fwts_list *fwts_keymap_load(const char *machine)
 	while (fgets(buffer, sizeof(buffer), fp) != NULL) {
 		fwts_keycode *key;
 		char *str = buffer;
-		int scancode;
 		char *keyname = NULL;
 		char *keytext = NULL;
+		int scancode;
 
 		scancode = strtoul(buffer, &str, 16);
-
-		if (str == NULL || *str == '\0')
+		if ((str == NULL) || (*str == '\0'))
 			continue;
 
 		/* Skip over whitespace */
-		while (*str != '\0' && isspace(*str))
+		while ((*str != '\0') && isspace(*str))
 			str++;
 		if (*str == '\0')
 			continue;
 
 		keyname = str;
 		/* Skip over keyname */
-		while (*str != '\0' && !isspace(*str))
+		while ((*str != '\0') && !isspace(*str))
 			str++;
 
 		keytext = keyname;  /* Default if we cannot find human readable name */
@@ -132,6 +132,7 @@  fwts_keycode *fwts_keymap_find_scancode(fwts_list *keymap, const int scancode)
 
 	fwts_list_foreach(item, keymap) {
 		fwts_keycode *keycode = fwts_list_data(fwts_keycode*, item);
+
 		if (keycode->scancode == scancode)
 			return keycode;
 	}