Skip to contentSkip to conversation

eth-raw-os.c: Add cast to bind(2) call

PATCH New Tom Rini 4 participants 15 messages Nov 28, 2015 – Jan 15, 2016

Subsystems (3)
lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/4 eth-raw-os.c: Add cast to bind(2) call

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 <[email protected]>
Cc Simon Glass <[email protected]>
---
 arch/sandbox/cpu/eth-raw-os.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/sandbox/cpu/eth-raw-os.c +2 -1
index b76a731..5df01ba 100644
@@ -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));
Signature · 1 line
2.6.2
author
#1 lore raw

PATCH 1/4 eth-raw-os.c: Add cast to bind(2) call

Quoted 11 lines · Tom Rini

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.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160115/85b953b2/attachment.sig>
author
#2 lore raw

PATCH 2/4 fsl_*_serdes.c: Modify memset call in serdes_init

In reply to Tom Rini

GCC 5.x does not like sizeof(array_variable) and errors out. Change these calls to be instead sizeof(u8) (as that's what serdes_prtcl_map is) * SERDES_PRCTL_COUNT (the number of array elements).

---
 arch/arm/cpu/armv8/fsl-layerscape/fsl_lsch2_serdes.c | 2 +-
 arch/arm/cpu/armv8/fsl-layerscape/fsl_lsch3_serdes.c | 2 +-
 arch/powerpc/cpu/mpc85xx/fsl_corenet2_serdes.c       | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
arch/arm/cpu/armv8/fsl-layerscape/fsl_lsch2_serdes.c +1 -1
index f7178d1..fe3444a 100644
@@ -86,7 +86,7 @@ void serdes_init(u32 sd, u32 sd_addr, u32 sd_prctl_mask, u32 sd_prctl_shift,
 	u32 cfg;
 	int lane;
 
-	memset(serdes_prtcl_map, 0, sizeof(serdes_prtcl_map));
+	memset(serdes_prtcl_map, 0, sizeof(u8) * SERDES_PRCTL_COUNT);
 
 	cfg = gur_in32(&gur->rcwsr[4]) & sd_prctl_mask;
 	cfg >>= sd_prctl_shift;
arch/arm/cpu/armv8/fsl-layerscape/fsl_lsch3_serdes.c +1 -1
index 2ab8da6..4f6b601 100644
@@ -74,7 +74,7 @@ void serdes_init(u32 sd, u32 sd_addr, u32 sd_prctl_mask, u32 sd_prctl_shift,
 	u32 cfg;
 	int lane;
 
-	memset(serdes_prtcl_map, 0, sizeof(serdes_prtcl_map));
+	memset(serdes_prtcl_map, 0, sizeof(u8) * SERDES_PRCTL_COUNT);
 
 	cfg = gur_in32(&gur->rcwsr[28]) & sd_prctl_mask;
 	cfg >>= sd_prctl_shift;
arch/powerpc/cpu/mpc85xx/fsl_corenet2_serdes.c +1 -1
index acb1353..b439b5b 100644
@@ -184,7 +184,7 @@ void serdes_init(u32 sd, u32 sd_addr, u32 sd_prctl_mask, u32 sd_prctl_shift,
 	u32 cfg;
 	int lane;
 
-	memset(serdes_prtcl_map, 0, sizeof(serdes_prtcl_map));
+	memset(serdes_prtcl_map, 0, sizeof(u8) * SERDES_PRCTL_COUNT);
 #ifdef CONFIG_SYS_FSL_ERRATUM_A007186
 	struct ccsr_sfp_regs  __iomem *sfp_regs =
 			(struct ccsr_sfp_regs __iomem *)(CONFIG_SYS_SFP_ADDR);
Signature · 1 line
2.6.2
#3 lore raw

PATCH 2/4 fsl_*_serdes.c: Modify memset call in serdes_init

Quoted 43 lines · Tom Rini

GCC 5.x does not like sizeof(array_variable) and errors out. Change these calls to be instead sizeof(u8) (as that's what serdes_prtcl_map is) * SERDES_PRCTL_COUNT (the number of array elements).

---
 arch/arm/cpu/armv8/fsl-layerscape/fsl_lsch2_serdes.c | 2 +-
 arch/arm/cpu/armv8/fsl-layerscape/fsl_lsch3_serdes.c | 2 +-
 arch/powerpc/cpu/mpc85xx/fsl_corenet2_serdes.c       | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
arch/arm/cpu/armv8/fsl-layerscape/fsl_lsch2_serdes.c +1 -1
index f7178d1..fe3444a 100644
@@ -86,7 +86,7 @@ void serdes_init(u32 sd, u32 sd_addr, u32 sd_prctl_mask, u32 sd_prctl_shift,
        u32 cfg;
        int lane;
 
-       memset(serdes_prtcl_map, 0, sizeof(serdes_prtcl_map));
+       memset(serdes_prtcl_map, 0, sizeof(u8) * SERDES_PRCTL_COUNT);
 
        cfg = gur_in32(&gur->rcwsr[4]) & sd_prctl_mask;
        cfg >>= sd_prctl_shift;
arch/arm/cpu/armv8/fsl-layerscape/fsl_lsch3_serdes.c +1 -1
index 2ab8da6..4f6b601 100644
@@ -74,7 +74,7 @@ void serdes_init(u32 sd, u32 sd_addr, u32 sd_prctl_mask, u32 sd_prctl_shift,
        u32 cfg;
        int lane;
 
-       memset(serdes_prtcl_map, 0, sizeof(serdes_prtcl_map));
+       memset(serdes_prtcl_map, 0, sizeof(u8) * SERDES_PRCTL_COUNT);
 
        cfg = gur_in32(&gur->rcwsr[28]) & sd_prctl_mask;
        cfg >>= sd_prctl_shift;
arch/powerpc/cpu/mpc85xx/fsl_corenet2_serdes.c +0 -0
index acb1353..b439b5b 100644

arch/powerpc/cpu/mpc85xx/fsl_corenet2_serdes.c void serdes_init(u32 sd, u32 sd_addr, u32 sd_prctl_mask, u32 sd_prctl_shift,

Quoted 9 lines
arch/powerpc/cpu/mpc85xx/fsl_corenet2_serdes.c +1 -2
@@ -184,7 +184,7 @@ void serdes_init(u32 sd, u32 sd_addr, u32 sd_prctl_mask, u32 sd_prctl_shift,
        u32 cfg;
        int lane;
 
-       memset(serdes_prtcl_map, 0, sizeof(serdes_prtcl_map));
+       memset(serdes_prtcl_map, 0, sizeof(u8) * SERDES_PRCTL_COUNT);
 #ifdef CONFIG_SYS_FSL_ERRATUM_A007186
        struct ccsr_sfp_regs  __iomem *sfp_regs =
                        (struct ccsr_sfp_regs __iomem *)(CONFIG_SYS_SFP_ADDR);
--
Applied
#4 lore raw

PATCH 2/4 fsl_*_serdes.c: Modify memset call in serdes_init

In reply to Tom Rini
Quoted 7 lines · Tom Rini

GCC 5.x does not like sizeof(array_variable) and errors out. Change these calls to be instead sizeof(u8) (as that's what serdes_prtcl_map is) * SERDES_PRCTL_COUNT (the number of array elements).

---

Applied to fsl-qoriq master. Awaiting upstream.

York

author
#5 lore raw

PATCH 3/4 qbman_portal.c: Update BUG_ON() call in qbman_swp_mc_submit

In reply to Tom Rini

With gcc-5.x we get a warning about the ambiguity of BUG_ON(!a != b) and becomes BUG_ON((!a) != b). In this case reading of the function leads to us wanting to rewrite this as BUG_ON(a != b).

Cc Prabhakar Kushwaha <[email protected]>
Cc Geoff Thorpe <[email protected]>
Cc Haiying Wang <[email protected]>
Cc Roy Pledge <[email protected]>
Cc York Sun <[email protected]>
---
 drivers/net/fsl-mc/dpio/qbman_portal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/fsl-mc/dpio/qbman_portal.c +1 -1
index 5fa8d95..449ff8a 100644
@@ -117,7 +117,7 @@ void qbman_swp_mc_submit(struct qbman_swp *p, void *cmd, uint32_t cmd_verb)
 {
 	uint32_t *v = cmd;
 #ifdef QBMAN_CHECKING
-	BUG_ON(!p->mc.check != swp_mc_can_submit);
+	BUG_ON(p->mc.check != swp_mc_can_submit);
 #endif
 	lwsync();
 	/* TBD: "|=" is going to hurt performance. Need to move as many fields
Signature · 1 line
2.6.2
#6 lore raw

PATCH 3/4 qbman_portal.c: Update BUG_ON() call in qbman_swp_mc_submit

Quoted 19 lines · Tom Rini

With gcc-5.x we get a warning about the ambiguity of BUG_ON(!a != b) and becomes BUG_ON((!a) != b). In this case reading of the function leads to us wanting to rewrite this as BUG_ON(a != b).

Cc Prabhakar Kushwaha <[email protected]>
Cc Geoff Thorpe <[email protected]>
Cc Haiying Wang <[email protected]>
Cc Roy Pledge <[email protected]>
Cc York Sun <[email protected]>
---
 drivers/net/fsl-mc/dpio/qbman_portal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/fsl-mc/dpio/qbman_portal.c +0 -0
index 5fa8d95..449ff8a 100644

drivers/net/fsl-mc/dpio/qbman_portal.c void qbman_swp_mc_submit(struct qbman_swp *p, void *cmd, uint32_t cmd_verb)

Quoted 9 lines
drivers/net/fsl-mc/dpio/qbman_portal.c +1 -2
@@ -117,7 +117,7 @@ void qbman_swp_mc_submit(struct qbman_swp *p, void *cmd, uint32_t cmd_verb)
 {
        uint32_t *v = cmd;
 #ifdef QBMAN_CHECKING
-       BUG_ON(!p->mc.check != swp_mc_can_submit);
+       BUG_ON(p->mc.check != swp_mc_can_submit);
 #endif
        lwsync();
        /* TBD: "|=" is going to hurt performance. Need to move as many fields
--
Applied
#7 lore raw

PATCH 3/4 qbman_portal.c: Update BUG_ON() call in qbman_swp_mc_submit

In reply to Tom Rini
Quoted 11 lines · Tom Rini

With gcc-5.x we get a warning about the ambiguity of BUG_ON(!a != b) and becomes BUG_ON((!a) != b). In this case reading of the function leads to us wanting to rewrite this as BUG_ON(a != b).

Cc Prabhakar Kushwaha <[email protected]>
Cc Geoff Thorpe <[email protected]>
Cc Haiying Wang <[email protected]>
Cc Roy Pledge <[email protected]>
Cc York Sun <[email protected]>

---

Applied to fsl-qoriq master. Awaiting upstream.

York

#8 lore raw

PATCH 1/4 eth-raw-os.c: Add cast to bind(2) call

In reply to Tom Rini
Quoted 18 lines · Tom Rini

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 <[email protected]>
Cc Simon Glass <[email protected]>
---
 arch/sandbox/cpu/eth-raw-os.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/sandbox/cpu/eth-raw-os.c +0 -0
index b76a731..5df01ba 100644

arch/sandbox/cpu/eth-raw-os.c int sandbox_eth_raw_os_send(void *packet, int length,

Quoted 10 lines
arch/sandbox/cpu/eth-raw-os.c +2 -2
@@ -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));
--
#9 lore raw

PATCH 1/4 eth-raw-os.c: Add cast to bind(2) call

In reply to Tom Rini
Quoted 9 lines · Tom Rini

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 <[email protected]>
Cc Simon Glass <[email protected]>
#10 lore raw

PATCH 1/4 eth-raw-os.c: Add cast to bind(2) call

Hi Tom,

Quoted 5 lines · Joe Hershberger
Quoted 4 lines · Tom Rini

With more recent gcc versions we otherwise get an error like:
note: expected 'const struct sockaddr *' but argument is of type 'struct sockaddr_in *'

Quoted 7 lines
Quoted 5 lines

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

Cc Joe Hershberger <[email protected]>
Cc Simon Glass <[email protected]>

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

author
#11 lore raw

PATCH 1/4 eth-raw-os.c: Add cast to bind(2) call

Quoted 15 lines · Bin Meng

Hi Tom,

Quoted 11 lines · Joe Hershberger
Quoted 9 lines · Tom Rini

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 <[email protected]>
Cc Simon Glass <[email protected]>
Quoted 6 lines
Quoted 1 line

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 :)

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160115/3dd881c7/attachment.sig>
author
#12 lore raw

PATCH 4/4 arch/arm/cpu/arm920t/ep93xx/led.c: Mark inline functions as static inline

In reply to Tom Rini

With gcc-5.x we get warning about inline non-static functions referring to static elements.

---
 arch/arm/cpu/arm920t/ep93xx/led.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/cpu/arm920t/ep93xx/led.c +2 -2
index 6144729..ecceb98 100644
@@ -13,7 +13,7 @@ static uint8_t saved_state[2] = {STATUS_LED_OFF, STATUS_LED_OFF};
 static uint32_t gpio_pin[2] = {1 << STATUS_LED_GREEN,
 			       1 << STATUS_LED_RED};
 
-inline void switch_LED_on(uint8_t led)
+static inline void switch_LED_on(uint8_t led)
 {
 	register struct gpio_regs *gpio = (struct gpio_regs *)GPIO_BASE;
 
@@ -21,7 +21,7 @@ inline void switch_LED_on(uint8_t led)
 	saved_state[led] = STATUS_LED_ON;
 }
 
-inline void switch_LED_off(uint8_t led)
+static inline void switch_LED_off(uint8_t led)
 {
 	register struct gpio_regs *gpio = (struct gpio_regs *)GPIO_BASE;
 
Signature · 1 line
2.6.2
#13 lore raw

PATCH 4/4 arch/arm/cpu/arm920t/ep93xx/led.c: Mark inline functions as static inline

Quoted 22 lines · Tom Rini

With gcc-5.x we get warning about inline non-static functions referring to static elements.

---
 arch/arm/cpu/arm920t/ep93xx/led.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/cpu/arm920t/ep93xx/led.c +1 -1
index 6144729..ecceb98 100644
@@ -13,7 +13,7 @@ static uint8_t saved_state[2] = {STATUS_LED_OFF, STATUS_LED_OFF};
 static uint32_t gpio_pin[2] = {1 << STATUS_LED_GREEN,
                               1 << STATUS_LED_RED};
 
-inline void switch_LED_on(uint8_t led)
+static inline void switch_LED_on(uint8_t led)
 {
        register struct gpio_regs *gpio = (struct gpio_regs *)GPIO_BASE;
 

arch/arm/cpu/arm920t/ep93xx/led.c inline void switch_LED_on(uint8_t led)

Quoted 9 lines
arch/arm/cpu/arm920t/ep93xx/led.c +1 -2
@@ -21,7 +21,7 @@ inline void switch_LED_on(uint8_t led)
        saved_state[led] = STATUS_LED_ON;
 }
 
-inline void switch_LED_off(uint8_t led)
+static inline void switch_LED_off(uint8_t led)
 {
        register struct gpio_regs *gpio = (struct gpio_regs *)GPIO_BASE;
 
--
author
#14 lore raw

PATCH 4/4 arch/arm/cpu/arm920t/ep93xx/led.c: Mark inline functions as static inline

In reply to Tom Rini
Quoted 5 lines · Tom Rini

With gcc-5.x we get warning about inline non-static functions referring to static elements.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151206/7d833422/attachment.sig>