Patchwork lib: fwts_guid: consitify and minor tidy up

login
register
mail settings
Submitter Colin King
Date Dec. 4, 2013, 10:46 a.m.
Message ID <1386154001-29827-1-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/296485/
State Accepted
Headers show

Comments

Colin King - Dec. 4, 2013, 10:46 a.m.
From: Colin Ian King <colin.king@canonical.com>

Constify guid and minor tidy up of the source. Nothing major.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/lib/include/fwts_guid.h | 2 +-
 src/lib/src/fwts_guid.c     | 8 +++++---
 2 files changed, 6 insertions(+), 4 deletions(-)
Ivan Hu - Dec. 9, 2013, 2:26 a.m.
On 12/04/2013 06:46 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Constify guid and minor tidy up of the source. Nothing major.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/lib/include/fwts_guid.h | 2 +-
>   src/lib/src/fwts_guid.c     | 8 +++++---
>   2 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/src/lib/include/fwts_guid.h b/src/lib/include/fwts_guid.h
> index 8b1fca6..5602e5d 100644
> --- a/src/lib/include/fwts_guid.h
> +++ b/src/lib/include/fwts_guid.h
> @@ -23,7 +23,7 @@
>   #include <stdlib.h>
>   #include <stdint.h>
>
> -void fwts_guid_buf_to_str(uint8_t *guid, char *guid_str, const size_t guid_str_len);
> +void fwts_guid_buf_to_str(const uint8_t *guid, char *guid_str, const size_t guid_str_len);
>   void fwts_guid_str_to_buf(const char *guid_str, uint8_t *guid, const size_t guid_len);
>
>   #endif
> diff --git a/src/lib/src/fwts_guid.c b/src/lib/src/fwts_guid.c
> index 3f4ba50..afceacb 100644
> --- a/src/lib/src/fwts_guid.c
> +++ b/src/lib/src/fwts_guid.c
> @@ -26,10 +26,11 @@
>    *	format given GUID 'guid' into a string guid_str.
>    *	guid_str needs to be at least 37 chars long
>    */
> -void fwts_guid_buf_to_str(uint8_t *guid, char *guid_str, const size_t guid_str_len)
> +void fwts_guid_buf_to_str(const uint8_t *guid, char *guid_str, const size_t guid_str_len)
>   {
>   	if (guid_str && guid_str_len > 36)
> -        	snprintf(guid_str, guid_str_len, "%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X",
> +		snprintf(guid_str, guid_str_len,
> +			"%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X",
>   			guid[3], guid[2], guid[1], guid[0], guid[5], guid[4], guid[7], guid[6],
>   			guid[8], guid[9], guid[10], guid[11], guid[12], guid[13], guid[14], guid[15]);
>   }
> @@ -42,7 +43,8 @@ void fwts_guid_buf_to_str(uint8_t *guid, char *guid_str, const size_t guid_str_l
>   void fwts_guid_str_to_buf(const char *guid_str, uint8_t *guid, const size_t guid_len)
>   {
>   	if (guid && guid_len >= 16) {
> -		sscanf(guid_str, "%2hhx%2hhx%2hhx%2hhx-%2hhx%2hhx-%2hhx%2hhx-%2hhx%2hhx-%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx",
> +		sscanf(guid_str,
> +			"%2hhx%2hhx%2hhx%2hhx-%2hhx%2hhx-%2hhx%2hhx-%2hhx%2hhx-%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx",
>   			&guid[3], &guid[2], &guid[1], &guid[0], &guid[5], &guid[4], &guid[7], &guid[6],
>   			&guid[8], &guid[9], &guid[10], &guid[11], &guid[12], &guid[13], &guid[14], &guid[15]);
>   	}
>

Acked-by: Ivan Hu <ivan.hu@canonical.com>
Alex Hung - Dec. 9, 2013, 3:48 a.m.
On 12/04/2013 06:46 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Constify guid and minor tidy up of the source. Nothing major.
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/lib/include/fwts_guid.h | 2 +-
>  src/lib/src/fwts_guid.c     | 8 +++++---
>  2 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/src/lib/include/fwts_guid.h b/src/lib/include/fwts_guid.h
> index 8b1fca6..5602e5d 100644
> --- a/src/lib/include/fwts_guid.h
> +++ b/src/lib/include/fwts_guid.h
> @@ -23,7 +23,7 @@
>  #include <stdlib.h>
>  #include <stdint.h>
>  
> -void fwts_guid_buf_to_str(uint8_t *guid, char *guid_str, const size_t guid_str_len);
> +void fwts_guid_buf_to_str(const uint8_t *guid, char *guid_str, const size_t guid_str_len);
>  void fwts_guid_str_to_buf(const char *guid_str, uint8_t *guid, const size_t guid_len);
>  
>  #endif
> diff --git a/src/lib/src/fwts_guid.c b/src/lib/src/fwts_guid.c
> index 3f4ba50..afceacb 100644
> --- a/src/lib/src/fwts_guid.c
> +++ b/src/lib/src/fwts_guid.c
> @@ -26,10 +26,11 @@
>   *	format given GUID 'guid' into a string guid_str.
>   *	guid_str needs to be at least 37 chars long
>   */
> -void fwts_guid_buf_to_str(uint8_t *guid, char *guid_str, const size_t guid_str_len)
> +void fwts_guid_buf_to_str(const uint8_t *guid, char *guid_str, const size_t guid_str_len)
>  {
>  	if (guid_str && guid_str_len > 36)
> -        	snprintf(guid_str, guid_str_len, "%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X",
> +		snprintf(guid_str, guid_str_len,
> +			"%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X",
>  			guid[3], guid[2], guid[1], guid[0], guid[5], guid[4], guid[7], guid[6],
>  			guid[8], guid[9], guid[10], guid[11], guid[12], guid[13], guid[14], guid[15]);
>  }
> @@ -42,7 +43,8 @@ void fwts_guid_buf_to_str(uint8_t *guid, char *guid_str, const size_t guid_str_l
>  void fwts_guid_str_to_buf(const char *guid_str, uint8_t *guid, const size_t guid_len)
>  {
>  	if (guid && guid_len >= 16) {
> -		sscanf(guid_str, "%2hhx%2hhx%2hhx%2hhx-%2hhx%2hhx-%2hhx%2hhx-%2hhx%2hhx-%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx",
> +		sscanf(guid_str,
> +			"%2hhx%2hhx%2hhx%2hhx-%2hhx%2hhx-%2hhx%2hhx-%2hhx%2hhx-%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx",
>  			&guid[3], &guid[2], &guid[1], &guid[0], &guid[5], &guid[4], &guid[7], &guid[6],
>  			&guid[8], &guid[9], &guid[10], &guid[11], &guid[12], &guid[13], &guid[14], &guid[15]);
>  	}
> 


Acked-by: Alex Hung <alex.hung@canonical.com>

Patch

diff --git a/src/lib/include/fwts_guid.h b/src/lib/include/fwts_guid.h
index 8b1fca6..5602e5d 100644
--- a/src/lib/include/fwts_guid.h
+++ b/src/lib/include/fwts_guid.h
@@ -23,7 +23,7 @@ 
 #include <stdlib.h>
 #include <stdint.h>
 
-void fwts_guid_buf_to_str(uint8_t *guid, char *guid_str, const size_t guid_str_len);
+void fwts_guid_buf_to_str(const uint8_t *guid, char *guid_str, const size_t guid_str_len);
 void fwts_guid_str_to_buf(const char *guid_str, uint8_t *guid, const size_t guid_len);
 
 #endif
diff --git a/src/lib/src/fwts_guid.c b/src/lib/src/fwts_guid.c
index 3f4ba50..afceacb 100644
--- a/src/lib/src/fwts_guid.c
+++ b/src/lib/src/fwts_guid.c
@@ -26,10 +26,11 @@ 
  *	format given GUID 'guid' into a string guid_str.
  *	guid_str needs to be at least 37 chars long
  */
-void fwts_guid_buf_to_str(uint8_t *guid, char *guid_str, const size_t guid_str_len)
+void fwts_guid_buf_to_str(const uint8_t *guid, char *guid_str, const size_t guid_str_len)
 {
 	if (guid_str && guid_str_len > 36)
-        	snprintf(guid_str, guid_str_len, "%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X",
+		snprintf(guid_str, guid_str_len,
+			"%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X",
 			guid[3], guid[2], guid[1], guid[0], guid[5], guid[4], guid[7], guid[6],
 			guid[8], guid[9], guid[10], guid[11], guid[12], guid[13], guid[14], guid[15]);
 }
@@ -42,7 +43,8 @@  void fwts_guid_buf_to_str(uint8_t *guid, char *guid_str, const size_t guid_str_l
 void fwts_guid_str_to_buf(const char *guid_str, uint8_t *guid, const size_t guid_len)
 {
 	if (guid && guid_len >= 16) {
-		sscanf(guid_str, "%2hhx%2hhx%2hhx%2hhx-%2hhx%2hhx-%2hhx%2hhx-%2hhx%2hhx-%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx",
+		sscanf(guid_str,
+			"%2hhx%2hhx%2hhx%2hhx-%2hhx%2hhx-%2hhx%2hhx-%2hhx%2hhx-%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx",
 			&guid[3], &guid[2], &guid[1], &guid[0], &guid[5], &guid[4], &guid[7], &guid[6],
 			&guid[8], &guid[9], &guid[10], &guid[11], &guid[12], &guid[13], &guid[14], &guid[15]);
 	}