Re: [PATCH] staging: r8188eu: Fix different base types in assignments and parameters
From: Fabio M. De Francesco
Date: Wed Aug 04 2021 - 05:00:32 EST
On Wednesday, August 4, 2021 9:59:30 AM CEST Dan Carpenter wrote:
> On Fri, Jul 30, 2021 at 08:14:52PM +0200, Fabio M. De Francesco wrote:
> > static inline void __nat25_generate_ipx_network_addr_with_socket(unsigned
char
> > *networkAddr,>
> > - unsigned int *ipxNetAddr,
unsigned short *ipxSocketAddr)
> >
> > [...]
> >
> Here is another bug which was obscured/caused by the union.
>
> addr.f0 = be16_to_cpu(*ipxSocketAddr);
>
> The addr.f0 variable is an int. On big endian systems only the last two
> bytes are set:
>
> memcpy(networkAddr+5, addr.f1, 2);
>
> So this is the equivalent of:
>
> memset(networkAddr+5, 0, 2);
>
> regards,
> dan carpenter
Dear Dan,
Thanks, for pointing me to one more bug I introduced with this patch. The most
of them were due to me forgetting that memcpy() takes pointers. For some
reason I was thinking it takes values, therefore I put in it a lot of
unnecessary and faulty complications.
I'd like to make a new patch, a better one (I hope), without unneeded unions
without the other wrong lines that are in the commit 56febcc2595e.
However, I see that Greg hasn't yet had the time to revert the above commit,
so I don't know how to make a new patch.
I mean: I could (1) either wait for Greg to revert it and then to fix the
sparse warnings with a new patch, or (2) I could fix the bugs I made in
56febcc2595e without having it reverted. I would prefer the solution (2) with
a "Fixes: 56febcc2595e (...)" and a "Reported-by: Dan Carpenter <...>" tags.
What is the best solution between the two above?
Thanks,
Fabio