From 0d7d2425c413a2c798eab8afc5738b8051917825 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 11 May 2020 14:45:09 +0200 Subject: [PATCH] ethtool: accept %NULL as argument for nm_ethtool_data_get_by_optname()/nm_ethtool_id_get_by_name() Often it is useful to not accept %NULL as input argument, to catch bugs. For simple functions like nm_ethtool_id_get_by_name(), such limitations are more annoying than helpful. Gracefully accept %NULL and treat is like an invalid ethtool option. --- shared/nm-libnm-core-intern/nm-ethtool-utils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shared/nm-libnm-core-intern/nm-ethtool-utils.c b/shared/nm-libnm-core-intern/nm-ethtool-utils.c index f080b5c173..ace47680f5 100644 --- a/shared/nm-libnm-core-intern/nm-ethtool-utils.c +++ b/shared/nm-libnm-core-intern/nm-ethtool-utils.c @@ -196,7 +196,8 @@ nm_ethtool_data_get_by_optname (const char *optname) { gssize idx; - nm_assert (optname); + if (!optname) + return NULL; _ASSERT_data ();