diff mbox series

[1/7] netlink: Remove pointless checks

Message ID 20240726161232.146982-1-denkenz@gmail.com (mailing list archive)
State New
Headers show
Series [1/7] netlink: Remove pointless checks | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-ci-setupell success Prep - Setup ELL
prestwoj/iwd-ci-makedistcheck fail Make Distcheck Make FAIL: ../../src/netdev.c: In function ‘netdev_get_link’: ../../src/netdev.c:6107:56: warning: passing argument 2 of ‘l_netlink_send’ makes pointer from integer without a cast [-Wint-conversion] 6107 | netdev->get_link_cmd_id = l_netlink_send(rtnl, RTM_GETLINK, 0, rtmmsg, | ^~~~~~~~~~~ | | | int In file included from ./ell/ell.h:17, from ../../src/netdev.c:40: ../../ell/netlink.h:34:59: note: expected ‘struct l_netlink_message *’ but argument is of type ‘int’ 34 | struct l_netlink_message *message, | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~ ../../src/netdev.c:6108:49: warning: passing argument 5 of ‘l_netlink_send’ makes pointer from integer without a cast [-Wint-conversion] 6108 | bufsize, netdev_getlink_cb, | ^~~~~~~ | | | size_t {aka long unsigned int} In file included from ./ell/ell.h:17, from ../../src/netdev.c:40: ../../ell/netlink.h:37:58: note: expected ‘l_netlink_destroy_func_t’ {aka ‘void (*)(void *)’} but argument is of type ‘size_t’ {aka ‘long unsigned int’} 37 | l_netlink_destroy_func_t destroy); | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~ ../../src/netdev.c:6107:35: error: too many arguments to function ‘l_netlink_send’ 6107 | netdev->get_link_cmd_id = l_netlink_send(rtnl, RTM_GETLINK, 0, rtmmsg, | ^~~~~~~~~~~~~~ In file included from ./ell/ell.h:17, from ../../src/netdev.c:40: ../../ell/netlink.h:33:14: note: declared here 33 | unsigned int l_netlink_send(struct l_netlink *netlink, | ^~~~~~~~~~~~~~ make[2]: *** [Makefile:2578: src/netdev.o] Error 1 make[2]: *** Waiting for unfinished jobs.... make[1]: *** [Makefile:1741: all] Error 2 make: *** [Makefile:3362: distcheck] Error 1
prestwoj/iwd-ci-build success Build - Configure
prestwoj/iwd-ci-makecheckvalgrind fail Make FAIL: src/netdev.c: In function ‘netdev_get_link’: src/netdev.c:6107:56: error: passing argument 2 of ‘l_netlink_send’ makes pointer from integer without a cast [-Werror=int-conversion] 6107 | netdev->get_link_cmd_id = l_netlink_send(rtnl, RTM_GETLINK, 0, rtmmsg, | ^~~~~~~~~~~ | | | int In file included from ./ell/ell.h:17, from src/netdev.c:40: ./ell/netlink.h:34:59: note: expected ‘struct l_netlink_message *’ but argument is of type ‘int’ 34 | struct l_netlink_message *message, | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~ src/netdev.c:6108:49: error: passing argument 5 of ‘l_netlink_send’ makes pointer from integer without a cast [-Werror=int-conversion] 6108 | bufsize, netdev_getlink_cb, | ^~~~~~~ | | | size_t {aka long unsigned int} In file included from ./ell/ell.h:17, from src/netdev.c:40: ./ell/netlink.h:37:58: note: expected ‘l_netlink_destroy_func_t’ {aka ‘void (*)(void *)’} but argument is of type ‘size_t’ {aka ‘long unsigned int’} 37 | l_netlink_destroy_func_t destroy); | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~ src/netdev.c:6107:35: error: too many arguments to function ‘l_netlink_send’ 6107 | netdev->get_link_cmd_id = l_netlink_send(rtnl, RTM_GETLINK, 0, rtmmsg, | ^~~~~~~~~~~~~~ In file included from ./ell/ell.h:17, from src/netdev.c:40: ./ell/netlink.h:33:14: note: declared here 33 | unsigned int l_netlink_send(struct l_netlink *netlink, | ^~~~~~~~~~~~~~ cc1: all warnings being treated as errors make[1]: *** [Makefile:2578: src/netdev.o] Error 1 make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:1741: all] Error 2
prestwoj/iwd-ci-testrunner pending testrunner SKIP
prestwoj/iwd-ci-makecheck pending makecheck SKIP
prestwoj/iwd-ci-clang fail Clang IWD - make FAIL: src/netdev.c:6108:16: error: too many arguments to function call, expected 5, have 8 bufsize, netdev_getlink_cb, ^~~~~~~~~~~~~~~~~~ ./ell/netlink.h:33:14: note: 'l_netlink_send' declared here unsigned int l_netlink_send(struct l_netlink *netlink, ^ 1 error generated. make[1]: *** [Makefile:2578: src/netdev.o] Error 1 make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:1741: all] Error 2

Commit Message

Denis Kenzior July 26, 2024, 4:12 p.m. UTC
command_queue, command_pending and command_lookup structures are always
initialized at construction time and are not destroyed until l_netlink
destruction.  There's no need to check whether they ar valid.
---
 ell/netlink.c | 8 --------
 1 file changed, 8 deletions(-)

Comments

James Prestwood July 26, 2024, 5:55 p.m. UTC | #1
Hi Denis,

On 7/26/24 9:12 AM, Denis Kenzior wrote:
> command_queue, command_pending and command_lookup structures are always
> initialized at construction time and are not destroyed until l_netlink
> destruction.  There's no need to check whether they ar valid.
> ---
>   ell/netlink.c | 8 --------
>   1 file changed, 8 deletions(-)
>
> diff --git a/ell/netlink.c b/ell/netlink.c
> index 024740b62fc3..26c31679e4c7 100644
> --- a/ell/netlink.c
> +++ b/ell/netlink.c
> @@ -410,10 +410,6 @@ LIB_EXPORT unsigned int l_netlink_send(struct l_netlink *netlink,
>   	if (unlikely(!netlink))
>   		return 0;
>   
> -	if (!netlink->command_queue || !netlink->command_pending ||
> -						!netlink->command_lookup)
> -		return 0;
> -
>   	if (flags & 0xff)
>   		return 0;
>   
> @@ -471,10 +467,6 @@ LIB_EXPORT bool l_netlink_cancel(struct l_netlink *netlink, unsigned int id)
>   	if (unlikely(!netlink || !id))
>   		return false;
>   
> -	if (!netlink->command_queue || !netlink->command_pending ||
> -						!netlink->command_lookup)
> -		return false;
> -
>   	command = l_hashmap_remove(netlink->command_lookup, L_UINT_TO_PTR(id));
>   	if (!command)
>   		return false;

These all look good to me visually, assuming they pass autotests (once 
the update to IWD/netdev is done)

Thanks,

James
Denis Kenzior July 26, 2024, 7:31 p.m. UTC | #2
Hi James,

> 
> These all look good to me visually, assuming they pass autotests (once the 
> update to IWD/netdev is done)
>

autotests seem to pass locally (with some usual test-runner flakiness), so I'll 
push this out and send the iwd patchset in a bit.  I do need to merge the iwd 
monitor patch first though.  Have you looked at that one?

Regards,
-Denis
diff mbox series

Patch

diff --git a/ell/netlink.c b/ell/netlink.c
index 024740b62fc3..26c31679e4c7 100644
--- a/ell/netlink.c
+++ b/ell/netlink.c
@@ -410,10 +410,6 @@  LIB_EXPORT unsigned int l_netlink_send(struct l_netlink *netlink,
 	if (unlikely(!netlink))
 		return 0;
 
-	if (!netlink->command_queue || !netlink->command_pending ||
-						!netlink->command_lookup)
-		return 0;
-
 	if (flags & 0xff)
 		return 0;
 
@@ -471,10 +467,6 @@  LIB_EXPORT bool l_netlink_cancel(struct l_netlink *netlink, unsigned int id)
 	if (unlikely(!netlink || !id))
 		return false;
 
-	if (!netlink->command_queue || !netlink->command_pending ||
-						!netlink->command_lookup)
-		return false;
-
 	command = l_hashmap_remove(netlink->command_lookup, L_UINT_TO_PTR(id));
 	if (!command)
 		return false;