All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cmd/misc: Stop using a function pointer
@ 2022-06-22 20:10 Tom Rini
  2022-06-23  0:14 ` Bin Meng
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Tom Rini @ 2022-06-22 20:10 UTC (permalink / raw)
  To: u-boot; +Cc: Bin Meng

Currently, enabling CMD_MISC gives:
cmd/misc.c:67:25: warning: assignment to 'int (*)(struct udevice *, int,  void *, int)' from incompatible pointer type 'int (*)(struct udevice *, int,  const void *, int)' [-Wincompatible-pointer-types]

Because 'misc_read' takes a void * and 'misc_write' takes a const void
*, both of which make sense for their operation.  Given there's one
place we make use of the function pointer, just call read or write
directly for the operation we're called with.

Cc: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Tom Rini <trini@konsulko.com>
---
 cmd/misc.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/cmd/misc.c b/cmd/misc.c
index bcd8d960ee06..ec32b41ed1e9 100644
--- a/cmd/misc.c
+++ b/cmd/misc.c
@@ -44,7 +44,6 @@ static int do_misc_list(struct cmd_tbl *cmdtp, int flag,
 static int do_misc_op(struct cmd_tbl *cmdtp, int flag,
 		      int argc, char *const argv[], enum misc_op op)
 {
-	int (*misc_op)(struct udevice *, int, void *, int);
 	struct udevice *dev;
 	int offset;
 	void *buf;
@@ -62,11 +61,10 @@ static int do_misc_op(struct cmd_tbl *cmdtp, int flag,
 	size = hextoul(argv[3], NULL);
 
 	if (op == MISC_OP_READ)
-		misc_op = misc_read;
+		ret = misc_read(dev, offset, buf, size);
 	else
-		misc_op = misc_write;
+		ret = misc_write(dev, offset, buf, size);
 
-	ret = misc_op(dev, offset, buf, size);
 	if (ret < 0) {
 		if (ret == -ENOSYS) {
 			printf("The device does not support %s\n",
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] cmd/misc: Stop using a function pointer
  2022-06-22 20:10 [PATCH] cmd/misc: Stop using a function pointer Tom Rini
@ 2022-06-23  0:14 ` Bin Meng
  2022-06-23  0:23 ` Sean Anderson
  2022-06-23 12:18 ` Tom Rini
  2 siblings, 0 replies; 4+ messages in thread
From: Bin Meng @ 2022-06-23  0:14 UTC (permalink / raw)
  To: Tom Rini; +Cc: U-Boot Mailing List

On Thu, Jun 23, 2022 at 4:10 AM Tom Rini <trini@konsulko.com> wrote:
>
> Currently, enabling CMD_MISC gives:
> cmd/misc.c:67:25: warning: assignment to 'int (*)(struct udevice *, int,  void *, int)' from incompatible pointer type 'int (*)(struct udevice *, int,  const void *, int)' [-Wincompatible-pointer-types]
>
> Because 'misc_read' takes a void * and 'misc_write' takes a const void
> *, both of which make sense for their operation.  Given there's one
> place we make use of the function pointer, just call read or write
> directly for the operation we're called with.
>
> Cc: Bin Meng <bmeng.cn@gmail.com>
> Signed-off-by: Tom Rini <trini@konsulko.com>
> ---
>  cmd/misc.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] cmd/misc: Stop using a function pointer
  2022-06-22 20:10 [PATCH] cmd/misc: Stop using a function pointer Tom Rini
  2022-06-23  0:14 ` Bin Meng
@ 2022-06-23  0:23 ` Sean Anderson
  2022-06-23 12:18 ` Tom Rini
  2 siblings, 0 replies; 4+ messages in thread
From: Sean Anderson @ 2022-06-23  0:23 UTC (permalink / raw)
  To: Tom Rini, u-boot; +Cc: Bin Meng

On 6/22/22 4:10 PM, Tom Rini wrote:
> Currently, enabling CMD_MISC gives:
> cmd/misc.c:67:25: warning: assignment to 'int (*)(struct udevice *, int,  void *, int)' from incompatible pointer type 'int (*)(struct udevice *, int,  const void *, int)' [-Wincompatible-pointer-types]
> 
> Because 'misc_read' takes a void * and 'misc_write' takes a const void
> *, both of which make sense for their operation.  Given there's one
> place we make use of the function pointer, just call read or write
> directly for the operation we're called with.
> 
> Cc: Bin Meng <bmeng.cn@gmail.com>
> Signed-off-by: Tom Rini <trini@konsulko.com>
> ---
>   cmd/misc.c | 6 ++----
>   1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/cmd/misc.c b/cmd/misc.c
> index bcd8d960ee06..ec32b41ed1e9 100644
> --- a/cmd/misc.c
> +++ b/cmd/misc.c
> @@ -44,7 +44,6 @@ static int do_misc_list(struct cmd_tbl *cmdtp, int flag,
>   static int do_misc_op(struct cmd_tbl *cmdtp, int flag,
>   		      int argc, char *const argv[], enum misc_op op)
>   {
> -	int (*misc_op)(struct udevice *, int, void *, int);
>   	struct udevice *dev;
>   	int offset;
>   	void *buf;
> @@ -62,11 +61,10 @@ static int do_misc_op(struct cmd_tbl *cmdtp, int flag,
>   	size = hextoul(argv[3], NULL);
>   
>   	if (op == MISC_OP_READ)
> -		misc_op = misc_read;
> +		ret = misc_read(dev, offset, buf, size);
>   	else
> -		misc_op = misc_write;
> +		ret = misc_write(dev, offset, buf, size);
>   
> -	ret = misc_op(dev, offset, buf, size);
>   	if (ret < 0) {
>   		if (ret == -ENOSYS) {
>   			printf("The device does not support %s\n",
> 

Reviewed-by: Sean Anderson <seanga2@gmail.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] cmd/misc: Stop using a function pointer
  2022-06-22 20:10 [PATCH] cmd/misc: Stop using a function pointer Tom Rini
  2022-06-23  0:14 ` Bin Meng
  2022-06-23  0:23 ` Sean Anderson
@ 2022-06-23 12:18 ` Tom Rini
  2 siblings, 0 replies; 4+ messages in thread
From: Tom Rini @ 2022-06-23 12:18 UTC (permalink / raw)
  To: u-boot; +Cc: Bin Meng

[-- Attachment #1: Type: text/plain, Size: 769 bytes --]

On Wed, Jun 22, 2022 at 04:10:18PM -0400, Tom Rini wrote:

> Currently, enabling CMD_MISC gives:
> cmd/misc.c:67:25: warning: assignment to 'int (*)(struct udevice *, int,  void *, int)' from incompatible pointer type 'int (*)(struct udevice *, int,  const void *, int)' [-Wincompatible-pointer-types]
> 
> Because 'misc_read' takes a void * and 'misc_write' takes a const void
> *, both of which make sense for their operation.  Given there's one
> place we make use of the function pointer, just call read or write
> directly for the operation we're called with.
> 
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
> Reviewed-by: Sean Anderson <seanga2@gmail.com>
> Signed-off-by: Tom Rini <trini@konsulko.com>

Applied to u-boot/next, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-06-23 12:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-22 20:10 [PATCH] cmd/misc: Stop using a function pointer Tom Rini
2022-06-23  0:14 ` Bin Meng
2022-06-23  0:23 ` Sean Anderson
2022-06-23 12:18 ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.