Message ID | 20130829082514.GB14334@elgon.mountain |
---|---|
State | Accepted, archived |
Delegated to: | David Miller |
Headers | show |
On Thu, 2013-08-29 at 11:25 +0300, Dan Carpenter wrote: > My static checker complains that on some arches unsigned longs can be 8 > characters which is larger than the buffer is only 6 chars. > Additionally, Ben Hutchings points out that the buffer actually holds > big endian data and the buffer we are reading from is CPU endian. It's not really as clear-cut as that. :-) But I think it's slightly more logical this way. > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Reviewed-by: Ben Hutchings <bhutchings@solarflare.com> > --- > v2: fix endian annotations and reverse the beXX_to_cpu() calls so that > they say cpu_to_beXX(). > > diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c > index fdf9307..0b12866 100644 > --- a/drivers/net/ethernet/freescale/fec_main.c > +++ b/drivers/net/ethernet/freescale/fec_main.c > @@ -1100,10 +1100,10 @@ static void fec_get_mac(struct net_device *ndev) > * 4) FEC mac registers set by bootloader > */ > if (!is_valid_ether_addr(iap)) { > - *((unsigned long *) &tmpaddr[0]) = > - be32_to_cpu(readl(fep->hwp + FEC_ADDR_LOW)); > - *((unsigned short *) &tmpaddr[4]) = > - be16_to_cpu(readl(fep->hwp + FEC_ADDR_HIGH) >> 16); > + *((__be32 *) &tmpaddr[0]) = > + cpu_to_be32(readl(fep->hwp + FEC_ADDR_LOW)); > + *((__be16 *) &tmpaddr[4]) = > + cpu_to_be16(readl(fep->hwp + FEC_ADDR_HIGH) >> 16); > iap = &tmpaddr[0]; > } >
On Fri, Aug 30, 2013 at 02:02:00AM +0000, Duan Fugang-B38611 wrote: > From: Ben Hutchings [mailto:bhutchings@solarflare.com] > Data: Friday, August 30, 2013 2:49 AM > > > To: Dan Carpenter > > Cc: Grant Likely; Rob Herring; David S. Miller; Estevam Fabio-R49496; Li > > Frank-B20596; Jim Baxter; Duan Fugang-B38611; netdev@vger.kernel.org; > > devicetree@vger.kernel.org; kernel-janitors@vger.kernel.org > > Subject: Re: [patch v2] net/fec: cleanup types in fec_get_mac() > > > > On Thu, 2013-08-29 at 11:25 +0300, Dan Carpenter wrote: > > > My static checker complains that on some arches unsigned longs can be > > > 8 characters which is larger than the buffer is only 6 chars. > > > Additionally, Ben Hutchings points out that the buffer actually holds > > > big endian data and the buffer we are reading from is CPU endian. > > > > It's not really as clear-cut as that. :-) But I think it's slightly more > > logical this way. > > > Yes, it is not clear, pls remove somebody's name from the commit log. Huh? No, I'm going to leave Ben's name as is. It's weird that you would ask for that. regards, dan carpenter -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Dan Carpenter <dan.carpenter@oracle.com> Date: Thu, 29 Aug 2013 11:25:14 +0300 > My static checker complains that on some arches unsigned longs can be 8 > characters which is larger than the buffer is only 6 chars. > Additionally, Ben Hutchings points out that the buffer actually holds > big endian data and the buffer we are reading from is CPU endian. > > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> > --- > v2: fix endian annotations and reverse the beXX_to_cpu() calls so that > they say cpu_to_beXX(). Applied, thanks. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index fdf9307..0b12866 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -1100,10 +1100,10 @@ static void fec_get_mac(struct net_device *ndev) * 4) FEC mac registers set by bootloader */ if (!is_valid_ether_addr(iap)) { - *((unsigned long *) &tmpaddr[0]) = - be32_to_cpu(readl(fep->hwp + FEC_ADDR_LOW)); - *((unsigned short *) &tmpaddr[4]) = - be16_to_cpu(readl(fep->hwp + FEC_ADDR_HIGH) >> 16); + *((__be32 *) &tmpaddr[0]) = + cpu_to_be32(readl(fep->hwp + FEC_ADDR_LOW)); + *((__be16 *) &tmpaddr[4]) = + cpu_to_be16(readl(fep->hwp + FEC_ADDR_HIGH) >> 16); iap = &tmpaddr[0]; }
My static checker complains that on some arches unsigned longs can be 8 characters which is larger than the buffer is only 6 chars. Additionally, Ben Hutchings points out that the buffer actually holds big endian data and the buffer we are reading from is CPU endian. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> --- v2: fix endian annotations and reverse the beXX_to_cpu() calls so that they say cpu_to_beXX(). -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html