diff mbox series

[u-boot-marvell,v2,17/20] tools: kwbimage: Do not cast const pointers to non-const pointers

Message ID 20220112172054.5961-18-pali@kernel.org
State Accepted
Commit 1a0e52f50a2085c46bf3bc5116f820a3cb655a2c
Delegated to: Stefan Roese
Headers show
Series tools: kwbimage: Load address fixes | expand

Commit Message

Pali Rohár Jan. 12, 2022, 5:20 p.m. UTC
Avoid casting const to non-const.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
---
 tools/kwbimage.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Stefan Roese Jan. 13, 2022, 6:45 a.m. UTC | #1
On 1/12/22 18:20, Pali Rohár wrote:
> Avoid casting const to non-const.
> 
> Signed-off-by: Pali Rohár <pali@kernel.org>
> Reviewed-by: Marek Behún <marek.behun@nic.cz>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

> ---
>   tools/kwbimage.h | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/kwbimage.h b/tools/kwbimage.h
> index 8d37357e5abd..c000cba4b8d1 100644
> --- a/tools/kwbimage.h
> +++ b/tools/kwbimage.h
> @@ -235,11 +235,11 @@ static inline int opt_hdr_v1_valid_size(const struct opt_hdr_v1 *ohdr,
>   {
>   	uint32_t ohdr_size;
>   
> -	if ((void *)(ohdr + 1) > mhdr_end)
> +	if ((const void *)(ohdr + 1) > mhdr_end)
>   		return 0;
>   
>   	ohdr_size = opt_hdr_v1_size(ohdr);
> -	if (ohdr_size < 8 || (void *)((uint8_t *)ohdr + ohdr_size) > mhdr_end)
> +	if (ohdr_size < 8 || (const void *)((const uint8_t *)ohdr + ohdr_size) > mhdr_end)
>   		return 0;
>   
>   	return 1;
> 

Viele Grüße,
Stefan Roese
diff mbox series

Patch

diff --git a/tools/kwbimage.h b/tools/kwbimage.h
index 8d37357e5abd..c000cba4b8d1 100644
--- a/tools/kwbimage.h
+++ b/tools/kwbimage.h
@@ -235,11 +235,11 @@  static inline int opt_hdr_v1_valid_size(const struct opt_hdr_v1 *ohdr,
 {
 	uint32_t ohdr_size;
 
-	if ((void *)(ohdr + 1) > mhdr_end)
+	if ((const void *)(ohdr + 1) > mhdr_end)
 		return 0;
 
 	ohdr_size = opt_hdr_v1_size(ohdr);
-	if (ohdr_size < 8 || (void *)((uint8_t *)ohdr + ohdr_size) > mhdr_end)
+	if (ohdr_size < 8 || (const void *)((const uint8_t *)ohdr + ohdr_size) > mhdr_end)
 		return 0;
 
 	return 1;