Patchwork [2/2] lib: fwts_guid: constify guid_str_len and guid_len parameters

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

Comments

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

Constify the length parameters.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/lib/include/fwts_guid.h | 4 ++--
 src/lib/src/fwts_guid.c     | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
Keng-Yu Lin - Dec. 18, 2012, 3:52 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>
>
> Constify the length parameters.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/lib/include/fwts_guid.h | 4 ++--
>  src/lib/src/fwts_guid.c     | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/src/lib/include/fwts_guid.h b/src/lib/include/fwts_guid.h
> index ba5ee6c..cb13137 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, size_t guid_str_len);
> -void fwts_guid_str_to_buf(const char *guid_str, uint8_t *guid, size_t guid_len);
> +void fwts_guid_buf_to_str(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 b4e9b07..ebb5d4d 100644
> --- a/src/lib/src/fwts_guid.c
> +++ b/src/lib/src/fwts_guid.c
> @@ -26,7 +26,7 @@
>   *     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, size_t guid_str_len)
> +void fwts_guid_buf_to_str(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",
> @@ -39,7 +39,7 @@ void fwts_guid_buf_to_str(uint8_t *guid, char *guid_str, size_t guid_str_len)
>   *     convert a GUID string back to a 16 byte GUID
>   *     guid needs to be at least 16 chars long
>   */
> -void fwts_guid_str_to_buf(const char *guid_str, uint8_t *guid, size_t guid_len)
> +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",
> --
> 1.8.0
>
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>
Alex Hung - Dec. 20, 2012, 9:52 a.m.
On 12/17/2012 07:22 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Constify the length parameters.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/lib/include/fwts_guid.h | 4 ++--
>   src/lib/src/fwts_guid.c     | 4 ++--
>   2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/src/lib/include/fwts_guid.h b/src/lib/include/fwts_guid.h
> index ba5ee6c..cb13137 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, size_t guid_str_len);
> -void fwts_guid_str_to_buf(const char *guid_str, uint8_t *guid, size_t guid_len);
> +void fwts_guid_buf_to_str(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 b4e9b07..ebb5d4d 100644
> --- a/src/lib/src/fwts_guid.c
> +++ b/src/lib/src/fwts_guid.c
> @@ -26,7 +26,7 @@
>    *	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, size_t guid_str_len)
> +void fwts_guid_buf_to_str(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",
> @@ -39,7 +39,7 @@ void fwts_guid_buf_to_str(uint8_t *guid, char *guid_str, size_t guid_str_len)
>    *	convert a GUID string back to a 16 byte GUID
>    *	guid needs to be at least 16 chars long
>    */
> -void fwts_guid_str_to_buf(const char *guid_str, uint8_t *guid, size_t guid_len)
> +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",
>
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 ba5ee6c..cb13137 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, size_t guid_str_len);
-void fwts_guid_str_to_buf(const char *guid_str, uint8_t *guid, size_t guid_len);
+void fwts_guid_buf_to_str(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 b4e9b07..ebb5d4d 100644
--- a/src/lib/src/fwts_guid.c
+++ b/src/lib/src/fwts_guid.c
@@ -26,7 +26,7 @@ 
  *	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, size_t guid_str_len)
+void fwts_guid_buf_to_str(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",
@@ -39,7 +39,7 @@  void fwts_guid_buf_to_str(uint8_t *guid, char *guid_str, size_t guid_str_len)
  *	convert a GUID string back to a 16 byte GUID
  *	guid needs to be at least 16 chars long
  */
-void fwts_guid_str_to_buf(const char *guid_str, uint8_t *guid, size_t guid_len)
+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",