[PATCH] fpga: Avoid ignored-qualifiers warning

Michal Simek michal.simek at amd.com
Mon Feb 3 10:19:57 CET 2025



On 1/21/25 17:22, Alexander Dahl wrote:
> Fixes annoying warnings of the following type when built with W=1 (for
> each file including fpga.h):
> 
>        CC      drivers/fpga/fpga.o
>      In file included from /mnt/data/adahl/src/u-boot/include/xilinx.h:7,
>                       from /mnt/data/adahl/src/u-boot/drivers/fpga/fpga.c:10:
>      /mnt/data/adahl/src/u-boot/include/fpga.h:61:1: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
>         61 | const fpga_desc *const fpga_get_desc(int devnum);
>            | ^~~~~
>      /mnt/data/adahl/src/u-boot/include/fpga.h:81:1: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
>         81 | const fpga_desc *const fpga_validate(int devnum, const void *buf,
>            | ^~~~~
>      /mnt/data/adahl/src/u-boot/drivers/fpga/fpga.c:36:1: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
>         36 | const fpga_desc *const fpga_get_desc(int devnum)
>            | ^~~~~
>      /mnt/data/adahl/src/u-boot/drivers/fpga/fpga.c:53:1: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
>         53 | const fpga_desc *const fpga_validate(int devnum, const void *buf,
>            | ^~~~~
> 
> Do some type and cast cleanup on that fpga_desc type file at it.
> 
> Link: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wignored-qualifiers
> Signed-off-by: Alexander Dahl <ada at thorsis.com>
> ---
>   drivers/fpga/fpga.c | 14 +++++++-------
>   include/fpga.h      |  6 +++---
>   2 files changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/fpga/fpga.c b/drivers/fpga/fpga.c
> index 1f6782537de..f88267e01b6 100644
> --- a/drivers/fpga/fpga.c
> +++ b/drivers/fpga/fpga.c
> @@ -33,9 +33,9 @@ static void fpga_no_sup(char *fn, char *msg)
>   /* fpga_get_desc
>    *	map a device number to a descriptor
>    */
> -const fpga_desc *const fpga_get_desc(int devnum)
> +const fpga_desc *fpga_get_desc(int devnum)
>   {
> -	fpga_desc *desc = (fpga_desc *)NULL;
> +	const fpga_desc *desc = NULL;
>   
>   	if ((devnum >= 0) && (devnum < next_desc)) {
>   		desc = &desc_table[devnum];
> @@ -50,8 +50,8 @@ const fpga_desc *const fpga_get_desc(int devnum)
>    * fpga_validate
>    *	generic parameter checking code
>    */
> -const fpga_desc *const fpga_validate(int devnum, const void *buf,
> -				     size_t bsize, char *fn)
> +const fpga_desc *fpga_validate(int devnum, const void *buf,
> +			       size_t bsize, char *fn)
>   {
>   	const fpga_desc *desc = fpga_get_desc(devnum);
>   
> @@ -60,7 +60,7 @@ const fpga_desc *const fpga_validate(int devnum, const void *buf,
>   
>   	if (!buf) {
>   		printf("%s: Null buffer.\n", fn);
> -		return (fpga_desc * const)NULL;
> +		return NULL;
>   	}
>   	return desc;
>   }
> @@ -72,7 +72,7 @@ const fpga_desc *const fpga_validate(int devnum, const void *buf,
>   static int fpga_dev_info(int devnum)
>   {
>   	int ret_val = FPGA_FAIL; /* assume failure */
> -	const fpga_desc * const desc = fpga_get_desc(devnum);
> +	const fpga_desc *desc = fpga_get_desc(devnum);
>   
>   	if (desc) {
>   		debug("%s: Device Descriptor @ 0x%p\n",
> @@ -374,7 +374,7 @@ int fpga_info(int devnum)
>   #if CONFIG_IS_ENABLED(FPGA_LOAD_SECURE)
>   int fpga_compatible2flag(int devnum, const char *compatible)
>   {
> -	const fpga_desc * const desc = fpga_get_desc(devnum);
> +	const fpga_desc *desc = fpga_get_desc(devnum);
>   
>   	if (!desc)
>   		return 0;
> diff --git a/include/fpga.h b/include/fpga.h
> index 44f2755a3f1..4cc44164b2f 100644
> --- a/include/fpga.h
> +++ b/include/fpga.h
> @@ -58,7 +58,7 @@ typedef enum {
>   void fpga_init(void);
>   int fpga_add(fpga_type devtype, void *desc);
>   int fpga_count(void);
> -const fpga_desc *const fpga_get_desc(int devnum);
> +const fpga_desc *fpga_get_desc(int devnum);
>   int fpga_is_partial_data(int devnum, size_t img_len);
>   #if CONFIG_IS_ENABLED(FPGA)
>   int fpga_load(int devnum, const void *buf, size_t bsize,
> @@ -78,8 +78,8 @@ int fpga_loadbitstream(int devnum, char *fpgadata, size_t size,
>   		       bitstream_type bstype);
>   int fpga_dump(int devnum, const void *buf, size_t bsize);
>   int fpga_info(int devnum);
> -const fpga_desc *const fpga_validate(int devnum, const void *buf,
> -				     size_t bsize, char *fn);
> +const fpga_desc *fpga_validate(int devnum, const void *buf,
> +			       size_t bsize, char *fn);
>   int fpga_compatible2flag(int devnum, const char *compatible);
>   
>   #endif	/* _FPGA_H_ */
> 
> base-commit: 5d5ce5f25708077e354a5627ec92b643145992cc

Applied and fixed commit message as was reported by author.

M


More information about the U-Boot mailing list