lib: fwts_checksum: object sizes should be size_t rather than int

Message ID 20170908093302.518-1-colin.king@canonical.com
State Accepted
Headers show
Series
  • lib: fwts_checksum: object sizes should be size_t rather than int
Related show

Commit Message

Colin King Sept. 8, 2017, 9:33 a.m.
From: Colin Ian King <colin.king@canonical.com>

Checksum lengths should be on size_t sizes rather than ints.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/lib/include/fwts_checksum.h | 2 +-
 src/lib/src/fwts_checksum.c     | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

Comments

Alex Hung Sept. 11, 2017, 4:51 p.m. | #1
On 2017-09-08 02:33 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Checksum lengths should be on size_t sizes rather than ints.
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/lib/include/fwts_checksum.h | 2 +-
>   src/lib/src/fwts_checksum.c     | 4 ++--
>   2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/lib/include/fwts_checksum.h b/src/lib/include/fwts_checksum.h
> index 6aa21359..f1a6626f 100644
> --- a/src/lib/include/fwts_checksum.h
> +++ b/src/lib/include/fwts_checksum.h
> @@ -22,6 +22,6 @@
>   
>   #include "fwts.h"
>   
> -uint8_t fwts_checksum(const uint8_t *data, const int length);
> +uint8_t fwts_checksum(const uint8_t *data, const size_t length);
>   
>   #endif
> diff --git a/src/lib/src/fwts_checksum.c b/src/lib/src/fwts_checksum.c
> index 27ab8820..f7760a99 100644
> --- a/src/lib/src/fwts_checksum.c
> +++ b/src/lib/src/fwts_checksum.c
> @@ -23,9 +23,9 @@
>    *  fwts_checksum()
>    *	checksum a uint8_t * buffer
>    */
> -uint8_t fwts_checksum(const uint8_t *data, const int length)
> +uint8_t fwts_checksum(const uint8_t *data, const size_t length)
>   {
> -	int 	i;
> +	size_t i;
>   	uint8_t checksum = 0;
>   
>   	for (i = 0; i < length; i++)
> 

Acked-by: Alex Hung <alex.hung@canonical.com>
ivanhu Sept. 21, 2017, 9:16 a.m. | #2
On 09/08/2017 05:33 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Checksum lengths should be on size_t sizes rather than ints.
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/lib/include/fwts_checksum.h | 2 +-
>   src/lib/src/fwts_checksum.c     | 4 ++--
>   2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/lib/include/fwts_checksum.h b/src/lib/include/fwts_checksum.h
> index 6aa21359..f1a6626f 100644
> --- a/src/lib/include/fwts_checksum.h
> +++ b/src/lib/include/fwts_checksum.h
> @@ -22,6 +22,6 @@
>   
>   #include "fwts.h"
>   
> -uint8_t fwts_checksum(const uint8_t *data, const int length);
> +uint8_t fwts_checksum(const uint8_t *data, const size_t length);
>   
>   #endif
> diff --git a/src/lib/src/fwts_checksum.c b/src/lib/src/fwts_checksum.c
> index 27ab8820..f7760a99 100644
> --- a/src/lib/src/fwts_checksum.c
> +++ b/src/lib/src/fwts_checksum.c
> @@ -23,9 +23,9 @@
>    *  fwts_checksum()
>    *	checksum a uint8_t * buffer
>    */
> -uint8_t fwts_checksum(const uint8_t *data, const int length)
> +uint8_t fwts_checksum(const uint8_t *data, const size_t length)
>   {
> -	int 	i;
> +	size_t i;
>   	uint8_t checksum = 0;
>   
>   	for (i = 0; i < length; i++)
> 


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

Patch

diff --git a/src/lib/include/fwts_checksum.h b/src/lib/include/fwts_checksum.h
index 6aa21359..f1a6626f 100644
--- a/src/lib/include/fwts_checksum.h
+++ b/src/lib/include/fwts_checksum.h
@@ -22,6 +22,6 @@ 
 
 #include "fwts.h"
 
-uint8_t fwts_checksum(const uint8_t *data, const int length);
+uint8_t fwts_checksum(const uint8_t *data, const size_t length);
 
 #endif
diff --git a/src/lib/src/fwts_checksum.c b/src/lib/src/fwts_checksum.c
index 27ab8820..f7760a99 100644
--- a/src/lib/src/fwts_checksum.c
+++ b/src/lib/src/fwts_checksum.c
@@ -23,9 +23,9 @@ 
  *  fwts_checksum()
  *	checksum a uint8_t * buffer
  */
-uint8_t fwts_checksum(const uint8_t *data, const int length)
+uint8_t fwts_checksum(const uint8_t *data, const size_t length)
 {
-	int 	i;
+	size_t i;
 	uint8_t checksum = 0;
 
 	for (i = 0; i < length; i++)