[U-Boot] [PATCH 1/1] net: nfs: remove superfluous conversions

rpc_pkt.u.call.data is an array of uint32_t. There is no need to convert it to uint32_t *.
memcpy() expects void * as it 1st and 2nd argument. There is no point in converting pointers to char * before passing them to memcpy().
In ntohl(data[1]) != 0 calling ntohl() is superfluous. If the value is zero, does not depend on the byte order.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de --- net/nfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/nfs.c b/net/nfs.c index d6a7f8e827..105f990360 100644 --- a/net/nfs.c +++ b/net/nfs.c @@ -196,10 +196,10 @@ static void rpc_req(int rpc_prog, int rpc_proc, uint32_t *data, int datalen) rpc_pkt.u.call.vers = htonl(2); /* portmapper is version 2 */ } rpc_pkt.u.call.proc = htonl(rpc_proc); - p = (uint32_t *)&(rpc_pkt.u.call.data); + p = rpc_pkt.u.call.data;
if (datalen) - memcpy((char *)p, (char *)data, datalen*sizeof(uint32_t)); + memcpy(p, data, datalen * sizeof(uint32_t));
pktlen = (char *)p + datalen * sizeof(uint32_t) - (char *)&rpc_pkt;
@@ -579,7 +579,7 @@ static int nfs_lookup_reply(uchar *pkt, unsigned len)
static int nfs3_get_attributes_offset(uint32_t *data) { - if (ntohl(data[1]) != 0) { + if (data[1]) { /* 'attributes_follow' flag is TRUE, * so we have attributes on 21 dwords */ /* Skip unused values : -- 2.23.0.rc1

On Tue, Sep 3, 2019 at 5:55 AM Heinrich Schuchardt xypron.glpk@gmx.de wrote:
rpc_pkt.u.call.data is an array of uint32_t. There is no need to convert it to uint32_t *.
memcpy() expects void * as it 1st and 2nd argument. There is no point in converting pointers to char * before passing them to memcpy().
In ntohl(data[1]) != 0 calling ntohl() is superfluous. If the value is zero, does not depend on the byte order.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de
net/nfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Reviewed-by: Bin Meng bmeng.cn@gmail.com

On Mon, Sep 2, 2019 at 4:55 PM Heinrich Schuchardt xypron.glpk@gmx.de wrote:
rpc_pkt.u.call.data is an array of uint32_t. There is no need to convert it to uint32_t *.
memcpy() expects void * as it 1st and 2nd argument. There is no point in converting pointers to char * before passing them to memcpy().
In ntohl(data[1]) != 0 calling ntohl() is superfluous. If the value is zero, does not depend on the byte order.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de
Acked-by: Joe Hershberger joe.hershberger@ni.com

Hi Heinrich,
https://patchwork.ozlabs.org/patch/1156730/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks! -Joe
participants (3)
-
Bin Meng
-
Heinrich Schuchardt
-
Joe Hershberger