genl: Fix casting error
PATCH 1/1 genl: Fix casting error
Fix for the cros-compilation with Chromium OS’s toolchain that uses GCC 4.9
--- ell/genl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ell/genl.c +1 -1
@@ -498,7 +498,7 @@ static bool received_data(struct l_io *io, void *user_data) group = pktinfo.group; } -for (nlmsg = iov.iov_base;NLMSG_OK (nlmsg, bytes_read); +for (nlmsg = iov.iov_base;NLMSG_OK (nlmsg, (uint32_t ) bytes_read); nlmsg =NLMSG_NEXT (nlmsg, bytes_read)) {if (group >0 )process_multicast (genl, group, nlmsg);
Signature · 1 line
2.9.4
Othman
Hi Tim,
ell/genl.c static bool received_data(struct l_io *io, void *user_data) · line 501
Quoted 3 lines · Tim Kourt
ell/genl.c +1
-1- for (nlmsg = iov.iov_base; NLMSG_OK(nlmsg, bytes_read); + for (nlmsg = iov.iov_base; NLMSG_OK(nlmsg, (uint32_t) bytes_read);
NLMSG_OK() expects an int for the second argument. Assuming truncation isn't an issue here, wouldn't it be better to cast to an int instead?
-Ossama
Kourt
Hi Ossama,
Quoted 1 line
NLMSG_OK()expects an int for the second argument. Assuming truncation isn't an issue here, wouldn't it be better to cast to an int instead?
The uint32_t was used to keep the consistency with the other usages of NLMSG_OK() within ELL and thereafter IWD. Maybe it is time to fix all of them.
Best regards,
Tim
Othman
Hi Tim,
Quoted 10 lines · Tim A
Quoted 2 lines
NLMSG_OK()expects an int for the second argument. Assuming truncationisn't an issue here, wouldn't it be better to cast to an int instead?
The
uint32_twas used to keep the consistency with the other usages ofNLMSG_OK()within ELL and thereafter IWD. Maybe it is time to fix all of them.
I did some digging into the NLMSG_OK() macro and found several patches and discussions related to this very same issue. It looks like everyone does indeed cast to an unsigned integer, even though the documentation states that the type is int. Patches to "fix" the issue with the macro have all been rejected, too. Consistency wins. :)
-Ossama