diff mbox

[U-Boot,1/4] eth-raw-os.c: Add cast to bind(2) call

Message ID 1448715883-14099-1-git-send-email-trini@konsulko.com
State Accepted
Commit 71229098a61c0b8c5abe24c4a644234e1679bca3
Delegated to: Tom Rini
Headers show

Commit Message

Tom Rini Nov. 28, 2015, 1:04 p.m. UTC
With more recent gcc versions we otherwise get an error like:
note: expected 'const struct sockaddr *' but argument is of type
'struct sockaddr_in *'

and the common solution here is to cast, rather than re-work the code.

Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
---
 arch/sandbox/cpu/eth-raw-os.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Bin Meng Nov. 29, 2015, 9:34 a.m. UTC | #1
On Sat, Nov 28, 2015 at 9:04 PM, Tom Rini <trini@konsulko.com> wrote:
> With more recent gcc versions we otherwise get an error like:
> note: expected 'const struct sockaddr *' but argument is of type
> 'struct sockaddr_in *'
>
> and the common solution here is to cast, rather than re-work the code.
>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Cc: Simon Glass <sjg@chromium.org>
> Signed-off-by: Tom Rini <trini@konsulko.com>
> ---
>  arch/sandbox/cpu/eth-raw-os.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/sandbox/cpu/eth-raw-os.c b/arch/sandbox/cpu/eth-raw-os.c
> index b76a731..5df01ba 100644
> --- a/arch/sandbox/cpu/eth-raw-os.c
> +++ b/arch/sandbox/cpu/eth-raw-os.c
> @@ -194,7 +194,8 @@ int sandbox_eth_raw_os_send(void *packet, int length,
>                 addr.sin_family = AF_INET;
>                 addr.sin_port = udph->source;
>                 addr.sin_addr.s_addr = iph->saddr;
> -               retval = bind(priv->local_bind_sd, &addr, sizeof(addr));
> +               retval = bind(priv->local_bind_sd, (struct sockaddr *)&addr,
> +                             sizeof(addr));
>                 if (retval < 0)
>                         printf("Failed to bind: %d %s\n", errno,
>                                strerror(errno));
> --

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Joe Hershberger Nov. 30, 2015, 10:13 p.m. UTC | #2
On Sat, Nov 28, 2015 at 7:04 AM, Tom Rini <trini@konsulko.com> wrote:
> With more recent gcc versions we otherwise get an error like:
> note: expected 'const struct sockaddr *' but argument is of type
> 'struct sockaddr_in *'
>
> and the common solution here is to cast, rather than re-work the code.
>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Cc: Simon Glass <sjg@chromium.org>
> Signed-off-by: Tom Rini <trini@konsulko.com>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Bin Meng Jan. 15, 2016, 3:45 a.m. UTC | #3
Hi Tom,

On Tue, Dec 1, 2015 at 6:13 AM, Joe Hershberger
<joe.hershberger@gmail.com> wrote:
> On Sat, Nov 28, 2015 at 7:04 AM, Tom Rini <trini@konsulko.com> wrote:
>> With more recent gcc versions we otherwise get an error like:
>> note: expected 'const struct sockaddr *' but argument is of type
>> 'struct sockaddr_in *'
>>
>> and the common solution here is to cast, rather than re-work the code.
>>
>> Cc: Joe Hershberger <joe.hershberger@ni.com>
>> Cc: Simon Glass <sjg@chromium.org>
>> Signed-off-by: Tom Rini <trini@konsulko.com>
>
> Acked-by: Joe Hershberger <joe.hershberger@ni.com>

I see this patch was assigned to me in patchwork. Patch 2&3 in the
same series were applied by York to fsl-qoriq repo and patch 4 was
applied by you to u-boot/master. So maybe you can apply this patch
directly to u-boot/master?

Regards,
Bin
Tom Rini Jan. 15, 2016, 12:28 p.m. UTC | #4
On Fri, Jan 15, 2016 at 11:45:22AM +0800, Bin Meng wrote:
> Hi Tom,
> 
> On Tue, Dec 1, 2015 at 6:13 AM, Joe Hershberger
> <joe.hershberger@gmail.com> wrote:
> > On Sat, Nov 28, 2015 at 7:04 AM, Tom Rini <trini@konsulko.com> wrote:
> >> With more recent gcc versions we otherwise get an error like:
> >> note: expected 'const struct sockaddr *' but argument is of type
> >> 'struct sockaddr_in *'
> >>
> >> and the common solution here is to cast, rather than re-work the code.
> >>
> >> Cc: Joe Hershberger <joe.hershberger@ni.com>
> >> Cc: Simon Glass <sjg@chromium.org>
> >> Signed-off-by: Tom Rini <trini@konsulko.com>
> >
> > Acked-by: Joe Hershberger <joe.hershberger@ni.com>
> 
> I see this patch was assigned to me in patchwork. Patch 2&3 in the
> same series were applied by York to fsl-qoriq repo and patch 4 was
> applied by you to u-boot/master. So maybe you can apply this patch
> directly to u-boot/master?

Sure.  I think I intended to assign this to Simon instead, sorry.  The
golden rule about patchwork assignments is I get 'em wrong sometimes,
just pass it around if so :)
Tom Rini Jan. 15, 2016, 1:10 p.m. UTC | #5
On Sat, Nov 28, 2015 at 08:04:40AM -0500, Tom Rini wrote:

> With more recent gcc versions we otherwise get an error like:
> note: expected 'const struct sockaddr *' but argument is of type
> 'struct sockaddr_in *'
> 
> and the common solution here is to cast, rather than re-work the code.
> 
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Cc: Simon Glass <sjg@chromium.org>
> Signed-off-by: Tom Rini <trini@konsulko.com>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
> Acked-by: Joe Hershberger <joe.hershberger@ni.com>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/arch/sandbox/cpu/eth-raw-os.c b/arch/sandbox/cpu/eth-raw-os.c
index b76a731..5df01ba 100644
--- a/arch/sandbox/cpu/eth-raw-os.c
+++ b/arch/sandbox/cpu/eth-raw-os.c
@@ -194,7 +194,8 @@  int sandbox_eth_raw_os_send(void *packet, int length,
 		addr.sin_family = AF_INET;
 		addr.sin_port = udph->source;
 		addr.sin_addr.s_addr = iph->saddr;
-		retval = bind(priv->local_bind_sd, &addr, sizeof(addr));
+		retval = bind(priv->local_bind_sd, (struct sockaddr *)&addr,
+			      sizeof(addr));
 		if (retval < 0)
 			printf("Failed to bind: %d %s\n", errno,
 			       strerror(errno));