summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-06-15 17:58:36 +0200
committerThomas Haller <thaller@redhat.com>2015-06-22 09:54:52 +0200
commitdd49380d42737b0c28ac561c502d22fe2e74a8c9 (patch)
tree1c22ba2f57a33a0242be6f3060cedad96593ed51
parent26b39df884ec5fb3034730ca78b1013aa3d4d9eb (diff)
downloadNetworkManager-dd49380d42737b0c28ac561c502d22fe2e74a8c9.tar.gz
platform: drop nm_platform_get_error()
For NMPlatform instances we had an error reporting mechanism which stores the last error reason in a private field. Later we would check it via nm_platform_get_error(). Remove this. It was not used much, and it is not a great way to report errors. One problem is that at the point where the error happens, you don't know whether anybody cares about an error code. So, you add code to set the error reason because somebody *might* need it (but in realitiy, almost no caller cares). Also, we tested this functionality which is hardly used in non-testing code. While this was a burden to maintain in the tests, it was likely still buggy because there were no real use-cases, beside the tests. Then, sometimes platform functions call each other which might overwrite the error reason. So, every function must be cautious to preserve/set the error reason according to it's own meaning. This can involve storing the error code, calling another function, and restoring it afterwards. This is harder to get right compared to a "return-error-code" pattern, where every function manages its error code independently. It is better to return the error reason whenever due. For that we already have our common glib patterns (1) gboolean fcn (...); (2) gboolean fcn (..., GError **error); In few cases, we need more details then a #gboolean, but don't want to bother constructing a #GError. Then we should do instead: (3) NMPlatformError fcn (...); (cherry picked from commit 68a4ffb4e2e38f9476e51da75770239493cb47b7)
-rw-r--r--src/platform/nm-fake-platform.c5
-rw-r--r--src/platform/nm-linux-platform.c38
-rw-r--r--src/platform/nm-platform.c168
-rw-r--r--src/platform/nm-platform.h5
-rw-r--r--src/platform/tests/platform.c10
-rw-r--r--src/platform/tests/test-address.c18
-rw-r--r--src/platform/tests/test-common.h3
-rw-r--r--src/platform/tests/test-link.c75
-rw-r--r--src/platform/tests/test-route.c28
9 files changed, 38 insertions, 312 deletions
diff --git a/src/platform/nm-fake-platform.c b/src/platform/nm-fake-platform.c
index ff97d551c1..1eac40d9e2 100644
--- a/src/platform/nm-fake-platform.c
+++ b/src/platform/nm-fake-platform.c
@@ -160,7 +160,6 @@ link_get (NMPlatform *platform, int ifindex)
return device;
not_found:
debug ("link not found: %d", ifindex);
- platform->error = NM_PLATFORM_ERROR_NOT_FOUND;
return NULL;
}
@@ -649,10 +648,8 @@ link_release (NMPlatform *platform, int master_idx, int slave_idx)
g_return_val_if_fail (master, FALSE);
g_return_val_if_fail (slave, FALSE);
- if (slave->link.master != master->link.ifindex) {
- platform->error = NM_PLATFORM_ERROR_NOT_SLAVE;
+ if (slave->link.master != master->link.ifindex)
return FALSE;
- }
slave->link.master = 0;
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
index ddb82adfa7..0a6f8e4350 100644
--- a/src/platform/nm-linux-platform.c
+++ b/src/platform/nm-linux-platform.c
@@ -2477,10 +2477,8 @@ cache_lookup_link (NMPlatform *platform, int ifindex)
const NMPObject *obj_cache;
obj_cache = nmp_cache_lookup_link (NM_LINUX_PLATFORM_GET_PRIVATE (platform)->cache, ifindex);
- if (!nmp_object_is_visible (obj_cache)) {
- platform->error = NM_PLATFORM_ERROR_NOT_FOUND;
+ if (!nmp_object_is_visible (obj_cache))
return NULL;
- }
return obj_cache;
}
@@ -2718,13 +2716,11 @@ do_change_link (NMPlatform *platform, struct rtnl_link *nlo, gboolean complete_f
_LOGD ("do-change-link: success changing link %d: %s (%d)", ifindex, nl_geterror (nle), -nle);
break;
case -NLE_OBJ_NOTFOUND:
- platform->error = NM_PLATFORM_ERROR_NO_FIRMWARE;
/* fall-through */
default:
- if (complete_from_cache != complete_from_cache2) {
- platform->error = NM_PLATFORM_ERROR_NOT_FOUND;
+ if (complete_from_cache != complete_from_cache2)
_LOGD ("do-change-link: failure changing link %d: link does not exist in cache", ifindex);
- } else
+ else
_LOGE ("do-change-link: failure changing link %d: %s (%d)", ifindex, nl_geterror (nle), -nle);
return nle == -NLE_OBJ_NOTFOUND ? NM_PLATFORM_ERROR_NO_FIRMWARE : NM_PLATFORM_ERROR_UNSPECIFIED;
}
@@ -2780,10 +2776,8 @@ link_delete (NMPlatform *platform, int ifindex)
const NMPObject *obj;
obj = nmp_cache_lookup_link (priv->cache, ifindex);
- if (!obj || !obj->_link.netlink.is_in_netlink) {
- platform->error = NM_PLATFORM_ERROR_NOT_FOUND;
+ if (!obj || !obj->_link.netlink.is_in_netlink)
return FALSE;
- }
nmp_object_stackinit_id_link (&obj_needle, ifindex);
return do_delete_object (platform, &obj_needle, NULL);
@@ -2798,8 +2792,6 @@ link_get_ifindex (NMPlatform *platform, const char *ifname)
obj = nmp_cache_lookup_link_full (NM_LINUX_PLATFORM_GET_PRIVATE (platform)->cache,
0, ifname, TRUE, NM_LINK_TYPE_NONE, NULL, NULL);
- if (!obj)
- platform->error = NM_PLATFORM_ERROR_NOT_FOUND;
return obj ? obj->link.ifindex : 0;
}
@@ -2951,15 +2943,15 @@ link_set_noarp (NMPlatform *platform, int ifindex)
static gboolean
link_get_ipv6_token (NMPlatform *platform, int ifindex, NMUtilsIPv6IfaceId *iid)
{
+#if HAVE_LIBNL_INET6_TOKEN
const NMPObject *obj = cache_lookup_link (platform, ifindex);
- /* Always lookup @obj, because it properly sets nm_platform_get_error().
- * Otherwise, we could save this '#ifndef HAVE_LIBNL_INET6_TOKEN' */
- if (!obj || !obj->link.inet6_token.is_valid)
- return FALSE;
-
- *iid = obj->link.inet6_token.iid;
- return TRUE;
+ if (obj && obj->link.inet6_token.is_valid) {
+ *iid = obj->link.inet6_token.iid;
+ return TRUE;
+ }
+#endif
+ return FALSE;
}
static const char *
@@ -2991,12 +2983,12 @@ link_get_udev_device (NMPlatform *platform, int ifindex)
static gboolean
link_get_user_ipv6ll_enabled (NMPlatform *platform, int ifindex)
{
+#if HAVE_LIBNL_INET6_ADDR_GEN_MODE
const NMPObject *obj = cache_lookup_link (platform, ifindex);
- /* Always lookup @obj, because it properly sets nm_platform_get_error().
- * Otherwise, we could save this '#ifndef HAVE_LIBNL_INET6_ADDR_GEN_MODE' */
if (obj && obj->link.inet6_addr_gen_mode_inv)
return (~obj->link.inet6_addr_gen_mode_inv) == IN6_ADDR_GEN_MODE_NONE;
+#endif
return FALSE;
}
@@ -3301,10 +3293,8 @@ slave_category (NMPlatform *platform, int slave)
{
int master = link_get_master (platform, slave);
- if (master <= 0) {
- platform->error = NM_PLATFORM_ERROR_NOT_SLAVE;
+ if (master <= 0)
return NULL;
- }
switch (link_get_type (platform, master)) {
case NM_LINK_TYPE_BRIDGE:
diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c
index d2a996c2ea..e150bcc987 100644
--- a/src/platform/nm-platform.c
+++ b/src/platform/nm-platform.c
@@ -146,39 +146,6 @@ nm_platform_try_get (void)
/******************************************************************/
/**
- * nm_platform_set_error:
- * @self: platform instance
- * @error: The error code
- *
- * Convenience function to falsify self->error. It can be used for example
- * by functions that want to save the error, execute some operations and
- * restore it.
- */
-void nm_platform_set_error (NMPlatform *self, NMPlatformError error)
-{
- _CHECK_SELF_VOID (self, klass);
-
- self->error = error;
-}
-
-/**
- * nm_platform_get_error:
- * @self: platform instance
- *
- * Convenience function to quickly retrieve the error code of the last
- * operation.
- *
- * Returns: Integer error code.
- */
-NMPlatformError
-nm_platform_get_error (NMPlatform *self)
-{
- _CHECK_SELF (self, klass, NM_PLATFORM_ERROR_BUG);
-
- return self->error;
-}
-
-/**
* nm_platform_error_to_string:
* @error_code: the error code to stringify.
*
@@ -213,26 +180,7 @@ nm_platform_error_to_string (NMPlatformError error)
}
}
-/**
- * nm_platform_get_error_message:
- * @self: platform instance
- *
- * Returns: Static human-readable string for the error. Don't free.
- */
-const char *
-nm_platform_get_error_msg (NMPlatform *self)
-{
- _CHECK_SELF (self, klass, NULL);
-
- return nm_platform_error_to_string (self->error);
-}
-
-static void
-reset_error (NMPlatform *self)
-{
- g_assert (self);
- self->error = NM_PLATFORM_ERROR_SUCCESS;
-}
+/******************************************************************/
#define IFA_F_MANAGETEMPADDR_STR "mngtmpaddr"
#define IFA_F_NOPREFIXROUTE_STR "noprefixroute"
@@ -299,8 +247,6 @@ nm_platform_sysctl_set (NMPlatform *self, const char *path, const char *value)
g_return_val_if_fail (value, FALSE);
g_return_val_if_fail (klass->sysctl_set, FALSE);
- reset_error (self);
-
return klass->sysctl_set (self, path, value);
}
@@ -353,8 +299,6 @@ nm_platform_sysctl_get (NMPlatform *self, const char *path)
g_return_val_if_fail (path, NULL);
g_return_val_if_fail (klass->sysctl_get, NULL);
- reset_error (self);
-
return klass->sysctl_get (self, path);
}
@@ -432,7 +376,6 @@ nm_platform_link_get_all (NMPlatform *self)
NMPlatformLink *item;
_CHECK_SELF (self, klass, NULL);
- reset_error (self);
g_return_val_if_fail (klass->link_get_all, NULL);
@@ -594,11 +537,8 @@ _link_add_check_existing (NMPlatform *self, const char *name, NMLinkType type, N
wrong_type ? nm_link_type_to_string (type) : "");
if (out_link)
*out_link = pllink;
- if (wrong_type) {
- nm_platform_set_error (self, NM_PLATFORM_ERROR_WRONG_TYPE);
+ if (wrong_type)
return NM_PLATFORM_ERROR_WRONG_TYPE;
- }
- nm_platform_set_error (self, NM_PLATFORM_ERROR_EXISTS);
return NM_PLATFORM_ERROR_EXISTS;
}
/* strange, nm_platform_link_get_ifindex() returned a valid ifindex, but nm_platform_link_get() failed.
@@ -637,7 +577,6 @@ nm_platform_link_add (NMPlatform *self,
NMPlatformError plerr;
_CHECK_SELF (self, klass, NM_PLATFORM_ERROR_BUG);
- reset_error (self);
g_return_val_if_fail (name, NM_PLATFORM_ERROR_BUG);
g_return_val_if_fail (klass->link_add, NM_PLATFORM_ERROR_BUG);
@@ -648,12 +587,8 @@ nm_platform_link_add (NMPlatform *self,
return plerr;
debug ("link: adding %s '%s'", nm_link_type_to_string (type), name);
- reset_error(self);
- if (!klass->link_add (self, name, type, address, address_len, out_link)) {
- nm_platform_set_error (self, NM_PLATFORM_ERROR_UNSPECIFIED);
+ if (!klass->link_add (self, name, type, address, address_len, out_link))
return NM_PLATFORM_ERROR_UNSPECIFIED;
- }
- reset_error (self);
return NM_PLATFORM_ERROR_SUCCESS;
}
@@ -687,7 +622,6 @@ nm_platform_link_exists (NMPlatform *self, const char *name)
ifindex = nm_platform_link_get_ifindex (self, name);
- reset_error (self);
return ifindex > 0;
}
@@ -695,9 +629,6 @@ nm_platform_link_exists (NMPlatform *self, const char *name)
* nm_platform_link_delete:
* @self: platform instance
* @ifindex: Interface index
- *
- * Delete a software interface. Sets self->error to
- * NM_PLATFORM_ERROR_NOT_FOUND if ifindex not available.
*/
gboolean
nm_platform_link_delete (NMPlatform *self, int ifindex)
@@ -705,7 +636,6 @@ nm_platform_link_delete (NMPlatform *self, int ifindex)
const char *name;
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (klass->link_delete, FALSE);
@@ -732,17 +662,14 @@ nm_platform_link_get_ifindex (NMPlatform *self, const char *name)
int ifindex;
_CHECK_SELF (self, klass, 0);
- reset_error (self);
g_return_val_if_fail (name, 0);
g_return_val_if_fail (klass->link_get_ifindex, 0);
ifindex = klass->link_get_ifindex (self, name);
- if (!ifindex) {
+ if (!ifindex)
debug ("link not found: %s", name);
- self->error = NM_PLATFORM_ERROR_NOT_FOUND;
- }
return ifindex;
}
@@ -761,7 +688,6 @@ nm_platform_link_get_name (NMPlatform *self, int ifindex)
const char *name;
_CHECK_SELF (self, klass, NULL);
- reset_error (self);
g_return_val_if_fail (klass->link_get_name, NULL);
@@ -769,7 +695,6 @@ nm_platform_link_get_name (NMPlatform *self, int ifindex)
if (!name) {
debug ("link not found: %d", ifindex);
- self->error = NM_PLATFORM_ERROR_NOT_FOUND;
return FALSE;
}
@@ -788,7 +713,6 @@ NMLinkType
nm_platform_link_get_type (NMPlatform *self, int ifindex)
{
_CHECK_SELF (self, klass, NM_LINK_TYPE_NONE);
- reset_error (self);
g_return_val_if_fail (klass->link_get_type, NM_LINK_TYPE_NONE);
@@ -808,7 +732,6 @@ const char *
nm_platform_link_get_type_name (NMPlatform *self, int ifindex)
{
_CHECK_SELF (self, klass, NULL);
- reset_error (self);
g_return_val_if_fail (klass->link_get_type_name, NULL);
@@ -829,7 +752,6 @@ gboolean
nm_platform_link_get_unmanaged (NMPlatform *self, int ifindex, gboolean *managed)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (klass->link_get_unmanaged, FALSE);
@@ -875,7 +797,6 @@ gboolean
nm_platform_link_refresh (NMPlatform *self, int ifindex)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
@@ -896,7 +817,6 @@ gboolean
nm_platform_link_is_up (NMPlatform *self, int ifindex)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (ifindex >= 0, FALSE);
g_return_val_if_fail (klass->link_is_up, FALSE);
@@ -915,7 +835,6 @@ gboolean
nm_platform_link_is_connected (NMPlatform *self, int ifindex)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (ifindex >= 0, FALSE);
g_return_val_if_fail (klass->link_is_connected, FALSE);
@@ -934,7 +853,6 @@ gboolean
nm_platform_link_uses_arp (NMPlatform *self, int ifindex)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (ifindex >= 0, FALSE);
g_return_val_if_fail (klass->link_uses_arp, FALSE);
@@ -958,7 +876,6 @@ gboolean
nm_platform_link_get_ipv6_token (NMPlatform *self, int ifindex, NMUtilsIPv6IfaceId *iid)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (ifindex >= 0, FALSE);
g_return_val_if_fail (iid, FALSE);
@@ -972,7 +889,6 @@ const char *
nm_platform_link_get_udi (NMPlatform *self, int ifindex)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (ifindex >= 0, NULL);
@@ -985,7 +901,6 @@ GObject *
nm_platform_link_get_udev_device (NMPlatform *self, int ifindex)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (ifindex >= 0, NULL);
@@ -1009,7 +924,6 @@ gboolean
nm_platform_link_get_user_ipv6ll_enabled (NMPlatform *self, int ifindex)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (ifindex >= 0, FALSE);
g_return_val_if_fail (klass->check_support_user_ipv6ll, FALSE);
@@ -1034,7 +948,6 @@ gboolean
nm_platform_link_set_user_ipv6ll_enabled (NMPlatform *self, int ifindex, gboolean enabled)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (ifindex >= 0, FALSE);
g_return_val_if_fail (klass->check_support_user_ipv6ll, FALSE);
@@ -1056,7 +969,6 @@ gboolean
nm_platform_link_set_address (NMPlatform *self, int ifindex, gconstpointer address, size_t length)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (address, FALSE);
@@ -1080,7 +992,6 @@ gconstpointer
nm_platform_link_get_address (NMPlatform *self, int ifindex, size_t *length)
{
_CHECK_SELF (self, klass, NULL);
- reset_error (self);
if (length)
*length = 0;
@@ -1106,7 +1017,6 @@ gboolean
nm_platform_link_get_permanent_address (NMPlatform *self, int ifindex, guint8 *buf, size_t *length)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
if (length)
*length = 0;
@@ -1153,7 +1063,6 @@ gboolean
nm_platform_link_set_up (NMPlatform *self, int ifindex, gboolean *out_no_firmware)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (klass->link_set_up, FALSE);
@@ -1173,7 +1082,6 @@ gboolean
nm_platform_link_set_down (NMPlatform *self, int ifindex)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (klass->link_set_down, FALSE);
@@ -1193,7 +1101,6 @@ gboolean
nm_platform_link_set_arp (NMPlatform *self, int ifindex)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (ifindex >= 0, FALSE);
g_return_val_if_fail (klass->link_set_arp, FALSE);
@@ -1213,7 +1120,6 @@ gboolean
nm_platform_link_set_noarp (NMPlatform *self, int ifindex)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (ifindex >= 0, FALSE);
g_return_val_if_fail (klass->link_set_noarp, FALSE);
@@ -1234,7 +1140,6 @@ gboolean
nm_platform_link_set_mtu (NMPlatform *self, int ifindex, guint32 mtu)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (ifindex >= 0, FALSE);
g_return_val_if_fail (mtu > 0, FALSE);
@@ -1255,7 +1160,6 @@ guint32
nm_platform_link_get_mtu (NMPlatform *self, int ifindex)
{
_CHECK_SELF (self, klass, 0);
- reset_error (self);
g_return_val_if_fail (ifindex >= 0, 0);
g_return_val_if_fail (klass->link_get_mtu, 0);
@@ -1281,7 +1185,6 @@ char *
nm_platform_link_get_physical_port_id (NMPlatform *self, int ifindex)
{
_CHECK_SELF (self, klass, NULL);
- reset_error (self);
g_return_val_if_fail (ifindex >= 0, NULL);
g_return_val_if_fail (klass->link_get_physical_port_id, NULL);
@@ -1305,7 +1208,6 @@ guint
nm_platform_link_get_dev_id (NMPlatform *self, int ifindex)
{
_CHECK_SELF (self, klass, 0);
- reset_error (self);
g_return_val_if_fail (ifindex >= 0, 0);
g_return_val_if_fail (klass->link_get_dev_id, 0);
@@ -1324,7 +1226,6 @@ gboolean
nm_platform_link_get_wake_on_lan (NMPlatform *self, int ifindex)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (ifindex >= 0, FALSE);
g_return_val_if_fail (klass->link_get_wake_on_lan, FALSE);
@@ -1352,7 +1253,6 @@ nm_platform_link_get_driver_info (NMPlatform *self,
char **out_fw_version)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (ifindex >= 0, FALSE);
g_return_val_if_fail (klass->link_get_driver_info, FALSE);
@@ -1376,7 +1276,6 @@ gboolean
nm_platform_link_enslave (NMPlatform *self, int master, int slave)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (master > 0, FALSE);
g_return_val_if_fail (slave> 0, FALSE);
@@ -1400,16 +1299,13 @@ gboolean
nm_platform_link_release (NMPlatform *self, int master, int slave)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (master > 0, FALSE);
g_return_val_if_fail (slave > 0, FALSE);
g_return_val_if_fail (klass->link_release, FALSE);
- if (nm_platform_link_get_master (self, slave) != master) {
- self->error = NM_PLATFORM_ERROR_NOT_SLAVE;
+ if (nm_platform_link_get_master (self, slave) != master)
return FALSE;
- }
debug ("link: releasing '%s' (%d) from master '%s' (%d)",
nm_platform_link_get_name (self, slave), slave,
@@ -1428,15 +1324,12 @@ int
nm_platform_link_get_master (NMPlatform *self, int slave)
{
_CHECK_SELF (self, klass, 0);
- reset_error (self);
g_return_val_if_fail (slave >= 0, FALSE);
g_return_val_if_fail (klass->link_get_master, FALSE);
- if (!nm_platform_link_get_name (self, slave)) {
- self->error = NM_PLATFORM_ERROR_NOT_FOUND;
+ if (!nm_platform_link_get_name (self, slave))
return 0;
- }
return klass->link_get_master (self, slave);
}
@@ -1509,7 +1402,6 @@ nm_platform_vlan_add (NMPlatform *self,
NMPlatformError plerr;
_CHECK_SELF (self, klass, NM_PLATFORM_ERROR_BUG);
- reset_error (self);
g_return_val_if_fail (parent >= 0, NM_PLATFORM_ERROR_BUG);
g_return_val_if_fail (vlanid >= 0, NM_PLATFORM_ERROR_BUG);
@@ -1531,7 +1423,6 @@ gboolean
nm_platform_master_set_option (NMPlatform *self, int ifindex, const char *option, const char *value)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (option, FALSE);
@@ -1545,7 +1436,6 @@ char *
nm_platform_master_get_option (NMPlatform *self, int ifindex, const char *option)
{
_CHECK_SELF (self, klass, NULL);
- reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (option, FALSE);
@@ -1558,7 +1448,6 @@ gboolean
nm_platform_slave_set_option (NMPlatform *self, int ifindex, const char *option, const char *value)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (option, FALSE);
@@ -1572,7 +1461,6 @@ char *
nm_platform_slave_get_option (NMPlatform *self, int ifindex, const char *option)
{
_CHECK_SELF (self, klass, NULL);
- reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (option, FALSE);
@@ -1585,7 +1473,6 @@ gboolean
nm_platform_vlan_get_info (NMPlatform *self, int ifindex, int *parent, int *vlanid)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (klass->vlan_get_info, FALSE);
@@ -1604,7 +1491,6 @@ gboolean
nm_platform_vlan_set_ingress_map (NMPlatform *self, int ifindex, int from, int to)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (klass->vlan_set_ingress_map, FALSE);
@@ -1616,7 +1502,6 @@ gboolean
nm_platform_vlan_set_egress_map (NMPlatform *self, int ifindex, int from, int to)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (klass->vlan_set_egress_map, FALSE);
@@ -1632,7 +1517,6 @@ nm_platform_infiniband_partition_add (NMPlatform *self, int parent, int p_key, N
NMPlatformError plerr;
_CHECK_SELF (self, klass, NM_PLATFORM_ERROR_BUG);
- reset_error (self);
g_return_val_if_fail (parent >= 0, NM_PLATFORM_ERROR_BUG);
g_return_val_if_fail (p_key >= 0, NM_PLATFORM_ERROR_BUG);
@@ -1640,10 +1524,8 @@ nm_platform_infiniband_partition_add (NMPlatform *self, int parent, int p_key, N
parent_name = g_strdup (nm_platform_link_get_name (self, parent));
if ( !parent_name
- || nm_platform_link_get_type (self, parent) != NM_LINK_TYPE_INFINIBAND) {
- self->error = NM_PLATFORM_ERROR_WRONG_TYPE;
+ || nm_platform_link_get_type (self, parent) != NM_LINK_TYPE_INFINIBAND)
return NM_PLATFORM_ERROR_WRONG_TYPE;
- }
name = g_strdup_printf ("%s.%04x", parent_name, p_key);
plerr = _link_add_check_existing (self, name, NM_LINK_TYPE_INFINIBAND, out_link);
@@ -1665,7 +1547,6 @@ nm_platform_infiniband_get_info (NMPlatform *self,
const char **mode)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (klass->infiniband_get_info, FALSE);
@@ -1677,7 +1558,6 @@ gboolean
nm_platform_veth_get_properties (NMPlatform *self, int ifindex, NMPlatformVethProperties *props)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (props != NULL, FALSE);
@@ -1689,7 +1569,6 @@ gboolean
nm_platform_tun_get_properties (NMPlatform *self, int ifindex, NMPlatformTunProperties *props)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (props != NULL, FALSE);
@@ -1701,7 +1580,6 @@ gboolean
nm_platform_macvlan_get_properties (NMPlatform *self, int ifindex, NMPlatformMacvlanProperties *props)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (props != NULL, FALSE);
@@ -1713,7 +1591,6 @@ gboolean
nm_platform_vxlan_get_properties (NMPlatform *self, int ifindex, NMPlatformVxlanProperties *props)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (props != NULL, FALSE);
@@ -1725,7 +1602,6 @@ gboolean
nm_platform_gre_get_properties (NMPlatform *self, int ifindex, NMPlatformGreProperties *props)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (props != NULL, FALSE);
@@ -1737,7 +1613,6 @@ gboolean
nm_platform_wifi_get_capabilities (NMPlatform *self, int ifindex, NMDeviceWifiCapabilities *caps)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
@@ -1748,7 +1623,6 @@ gboolean
nm_platform_wifi_get_bssid (NMPlatform *self, int ifindex, guint8 *bssid)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
@@ -1759,7 +1633,6 @@ GByteArray *
nm_platform_wifi_get_ssid (NMPlatform *self, int ifindex)
{
_CHECK_SELF (self, klass, NULL);
- reset_error (self);
g_return_val_if_fail (ifindex > 0, NULL);
@@ -1770,7 +1643,6 @@ guint32
nm_platform_wifi_get_frequency (NMPlatform *self, int ifindex)
{
_CHECK_SELF (self, klass, 0);
- reset_error (self);
g_return_val_if_fail (ifindex > 0, 0);
@@ -1781,7 +1653,6 @@ int
nm_platform_wifi_get_quality (NMPlatform *self, int ifindex)
{
_CHECK_SELF (self, klass, 0);
- reset_error (self);
g_return_val_if_fail (ifindex > 0, 0);
@@ -1792,7 +1663,6 @@ guint32
nm_platform_wifi_get_rate (NMPlatform *self, int ifindex)
{
_CHECK_SELF (self, klass, 0);
- reset_error (self);
g_return_val_if_fail (ifindex > 0, 0);
@@ -1803,7 +1673,6 @@ NM80211Mode
nm_platform_wifi_get_mode (NMPlatform *self, int ifindex)
{
_CHECK_SELF (self, klass, NM_802_11_MODE_UNKNOWN);
- reset_error (self);
g_return_val_if_fail (ifindex > 0, NM_802_11_MODE_UNKNOWN);
@@ -1814,7 +1683,6 @@ void
nm_platform_wifi_set_mode (NMPlatform *self, int ifindex, NM80211Mode mode)
{
_CHECK_SELF_VOID (self, klass);
- reset_error (self);
g_return_if_fail (ifindex > 0);
@@ -1825,7 +1693,6 @@ guint32
nm_platform_wifi_find_frequency (NMPlatform *self, int ifindex, const guint32 *freqs)
{
_CHECK_SELF (self, klass, 0);
- reset_error (self);
g_return_val_if_fail (ifindex > 0, 0);
g_return_val_if_fail (freqs != NULL, 0);
@@ -1837,7 +1704,6 @@ void
nm_platform_wifi_indicate_addressing_running (NMPlatform *self, int ifindex, gboolean running)
{
_CHECK_SELF_VOID (self, klass);
- reset_error (self);
g_return_if_fail (ifindex > 0);
@@ -1848,7 +1714,6 @@ guint32
nm_platform_mesh_get_channel (NMPlatform *self, int ifindex)
{
_CHECK_SELF (self, klass, 0);
- reset_error (self);
g_return_val_if_fail (ifindex > 0, 0);
@@ -1859,7 +1724,6 @@ gboolean
nm_platform_mesh_set_channel (NMPlatform *self, int ifindex, guint32 channel)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
@@ -1870,7 +1734,6 @@ gboolean
nm_platform_mesh_set_ssid (NMPlatform *self, int ifindex, const guint8 *ssid, gsize len)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (ssid != NULL, FALSE);
@@ -1908,7 +1771,6 @@ GArray *
nm_platform_ip4_address_get_all (NMPlatform *self, int ifindex)
{
_CHECK_SELF (self, klass, NULL);
- reset_error (self);
g_return_val_if_fail (ifindex > 0, NULL);
g_return_val_if_fail (klass->ip4_address_get_all, NULL);
@@ -1920,7 +1782,6 @@ GArray *
nm_platform_ip6_address_get_all (NMPlatform *self, int ifindex)
{
_CHECK_SELF (self, klass, NULL);
- reset_error (self);
g_return_val_if_fail (ifindex > 0, NULL);
g_return_val_if_fail (klass->ip6_address_get_all, NULL);
@@ -1939,7 +1800,6 @@ nm_platform_ip4_address_add (NMPlatform *self,
const char *label)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (plen > 0, FALSE);
@@ -1977,7 +1837,6 @@ nm_platform_ip6_address_add (NMPlatform *self,
guint flags)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (plen > 0, FALSE);
@@ -2009,7 +1868,6 @@ nm_platform_ip4_address_delete (NMPlatform *self, int ifindex, in_addr_t address
char str_peer[NM_UTILS_INET_ADDRSTRLEN];
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (plen > 0, FALSE);
@@ -2031,7 +1889,6 @@ nm_platform_ip6_address_delete (NMPlatform *self, int ifindex, struct in6_addr a
char str_dev[TO_STRING_DEV_BUF_SIZE];
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (plen > 0, FALSE);
@@ -2047,7 +1904,6 @@ gboolean
nm_platform_ip4_address_exists (NMPlatform *self, int ifindex, in_addr_t address, int plen)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (plen > 0, FALSE);
g_return_val_if_fail (klass->ip4_address_exists, FALSE);
@@ -2059,7 +1915,6 @@ gboolean
nm_platform_ip6_address_exists (NMPlatform *self, int ifindex, struct in6_addr address, int plen)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (plen > 0, FALSE);
g_return_val_if_fail (klass->ip6_address_exists, FALSE);
@@ -2173,7 +2028,6 @@ gboolean
nm_platform_ip4_check_reinstall_device_route (NMPlatform *self, int ifindex, const NMPlatformIP4Address *address, guint32 device_route_metric)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
if ( ifindex <= 0
|| address->plen <= 0
@@ -2334,7 +2188,6 @@ GArray *
nm_platform_ip4_route_get_all (NMPlatform *self, int ifindex, NMPlatformGetRouteMode mode)
{
_CHECK_SELF (self, klass, NULL);
- reset_error (self);
g_return_val_if_fail (ifindex >= 0, NULL);
g_return_val_if_fail (klass->ip4_route_get_all, NULL);
@@ -2346,7 +2199,6 @@ GArray *
nm_platform_ip6_route_get_all (NMPlatform *self, int ifindex, NMPlatformGetRouteMode mode)
{
_CHECK_SELF (self, klass, NULL);
- reset_error (self);
g_return_val_if_fail (ifindex >= 0, NULL);
g_return_val_if_fail (klass->ip6_route_get_all, NULL);
@@ -2362,7 +2214,6 @@ nm_platform_ip4_route_add (NMPlatform *self,
guint32 metric, guint32 mss)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (0 <= plen && plen <= 32, FALSE);
g_return_val_if_fail (klass->ip4_route_add, FALSE);
@@ -2394,7 +2245,6 @@ nm_platform_ip6_route_add (NMPlatform *self,
guint32 metric, guint32 mss)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (0 <= plen && plen <= 128, FALSE);
g_return_val_if_fail (klass->ip6_route_add, FALSE);
@@ -2421,7 +2271,6 @@ nm_platform_ip4_route_delete (NMPlatform *self, int ifindex, in_addr_t network,
char str_dev[TO_STRING_DEV_BUF_SIZE];
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (klass->ip4_route_delete, FALSE);
@@ -2437,7 +2286,6 @@ nm_platform_ip6_route_delete (NMPlatform *self, int ifindex, struct in6_addr net
char str_dev[TO_STRING_DEV_BUF_SIZE];
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (klass->ip6_route_delete, FALSE);
@@ -2451,7 +2299,6 @@ gboolean
nm_platform_ip4_route_exists (NMPlatform *self, int ifindex, in_addr_t network, int plen, guint32 metric)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (klass->ip4_route_exists, FALSE);
@@ -2462,7 +2309,6 @@ gboolean
nm_platform_ip6_route_exists (NMPlatform *self, int ifindex, struct in6_addr network, int plen, guint32 metric)
{
_CHECK_SELF (self, klass, FALSE);
- reset_error (self);
g_return_val_if_fail (klass->ip6_route_exists, FALSE);
diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h
index f34355b606..6121387fc2 100644
--- a/src/platform/nm-platform.h
+++ b/src/platform/nm-platform.h
@@ -401,8 +401,6 @@ typedef struct {
struct _NMPlatform {
GObject parent;
-
- NMPlatformError error;
};
typedef struct {
@@ -589,9 +587,6 @@ nm_platform_route_scope_inv (guint8 scope)
const char *nm_link_type_to_string (NMLinkType link_type);
const char *nm_platform_error_to_string (NMPlatformError error);
-void nm_platform_set_error (NMPlatform *self, NMPlatformError error);
-NMPlatformError nm_platform_get_error (NMPlatform *self);
-const char *nm_platform_get_error_msg (NMPlatform *self);
gboolean nm_platform_sysctl_set (NMPlatform *self, const char *path, const char *value);
char *nm_platform_sysctl_get (NMPlatform *self, const char *path);
diff --git a/src/platform/tests/platform.c b/src/platform/tests/platform.c
index ee48a9d7cb..fe148518c2 100644
--- a/src/platform/tests/platform.c
+++ b/src/platform/tests/platform.c
@@ -865,7 +865,6 @@ main (int argc, char **argv)
const char *arg0 = *argv++;
const command_t *command = NULL;
gboolean status = TRUE;
- int error;
#if !GLIB_CHECK_VERSION (2, 35, 0)
g_type_init ();
@@ -899,12 +898,5 @@ main (int argc, char **argv)
error ("\n");
}
- error = nm_platform_get_error (NM_PLATFORM_GET);
- if (error) {
- const char *msg = nm_platform_get_error_msg (NM_PLATFORM_GET);
-
- error ("nm-platform: %s\n", msg);
- }
-
- return !!error;
+ return EXIT_SUCCESS;
}
diff --git a/src/platform/tests/test-address.c b/src/platform/tests/test-address.c
index 06cd3aac14..6d7a47def4 100644
--- a/src/platform/tests/test-address.c
+++ b/src/platform/tests/test-address.c
@@ -65,22 +65,17 @@ test_ip4_address (void)
/* Add address */
g_assert (!nm_platform_ip4_address_exists (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN));
- no_error ();
g_assert (nm_platform_ip4_address_add (NM_PLATFORM_GET, ifindex, addr, 0, IP4_PLEN, lifetime, preferred, NULL));
- no_error ();
g_assert (nm_platform_ip4_address_exists (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN));
- no_error ();
accept_signal (address_added);
/* Add address again (aka update) */
g_assert (nm_platform_ip4_address_add (NM_PLATFORM_GET, ifindex, addr, 0, IP4_PLEN, lifetime, preferred, NULL));
- no_error ();
accept_signals (address_changed, 0, 1);
/* Test address listing */
addresses = nm_platform_ip4_address_get_all (NM_PLATFORM_GET, ifindex);
g_assert (addresses);
- no_error ();
g_assert_cmpint (addresses->len, ==, 1);
address = &g_array_index (addresses, NMPlatformIP4Address, 0);
g_assert_cmpint (address->ifindex, ==, ifindex);
@@ -90,13 +85,11 @@ test_ip4_address (void)
/* Remove address */
g_assert (nm_platform_ip4_address_delete (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN, 0));
- no_error ();
g_assert (!nm_platform_ip4_address_exists (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN));
accept_signal (address_removed);
/* Remove address again */
g_assert (nm_platform_ip4_address_delete (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN, 0));
- no_error ();
free_signal (address_added);
free_signal (address_changed);
@@ -121,22 +114,17 @@ test_ip6_address (void)
/* Add address */
g_assert (!nm_platform_ip6_address_exists (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN));
- no_error ();
g_assert (nm_platform_ip6_address_add (NM_PLATFORM_GET, ifindex, addr, in6addr_any, IP6_PLEN, lifetime, preferred, flags));
- no_error ();
g_assert (nm_platform_ip6_address_exists (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN));
- no_error ();
accept_signal (address_added);
/* Add address again (aka update) */
g_assert (nm_platform_ip6_address_add (NM_PLATFORM_GET, ifindex, addr, in6addr_any, IP6_PLEN, lifetime, preferred, flags));
- no_error ();
accept_signals (address_changed, 0, 1);
/* Test address listing */
addresses = nm_platform_ip6_address_get_all (NM_PLATFORM_GET, ifindex);
g_assert (addresses);
- no_error ();
g_assert_cmpint (addresses->len, ==, 1);
address = &g_array_index (addresses, NMPlatformIP6Address, 0);
g_assert_cmpint (address->ifindex, ==, ifindex);
@@ -146,13 +134,11 @@ test_ip6_address (void)
/* Remove address */
g_assert (nm_platform_ip6_address_delete (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN));
- no_error ();
g_assert (!nm_platform_ip6_address_exists (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN));
accept_signal (address_removed);
/* Remove address again */
g_assert (nm_platform_ip6_address_delete (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN));
- no_error ();
free_signal (address_added);
free_signal (address_changed);
@@ -190,12 +176,10 @@ test_ip4_address_external (void)
run_command ("ip address add %s/%d dev %s valid_lft %d preferred_lft %d",
IP4_ADDRESS, IP4_PLEN, DEVICE_NAME, lifetime, preferred);
g_assert (nm_platform_ip4_address_add (NM_PLATFORM_GET, ifindex, addr, 0, IP4_PLEN, lifetime, preferred, NULL));
- no_error ();
g_assert (nm_platform_ip4_address_exists (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN));
accept_signal (address_added);
/*run_command ("ip address delete %s/%d dev %s", IP4_ADDRESS, IP4_PLEN, DEVICE_NAME);
g_assert (nm_platform_ip4_address_delete (ifindex, addr, IP4_PLEN, 0));
- no_error ();
g_assert (!nm_platform_ip4_address_exists (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN));
accept_signal (address_removed);*/
@@ -229,12 +213,10 @@ test_ip6_address_external (void)
run_command ("ip address add %s/%d dev %s valid_lft %d preferred_lft %d",
IP6_ADDRESS, IP6_PLEN, DEVICE_NAME, lifetime, preferred);
g_assert (nm_platform_ip6_address_add (NM_PLATFORM_GET, ifindex, addr, in6addr_any, IP6_PLEN, lifetime, preferred, flags));
- no_error ();
g_assert (nm_platform_ip6_address_exists (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN));
accept_signal (address_added);
/*run_command ("ip address delete %s/%d dev %s", IP6_ADDRESS, IP6_PLEN, DEVICE_NAME);
g_assert (nm_platform_ip6_address_delete (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN));
- no_error ();
g_assert (!nm_platform_ip6_address_exists (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN));
wait_signal (address_removed);*/
diff --git a/src/platform/tests/test-common.h b/src/platform/tests/test-common.h
index 5f72a1480d..4a1814f85a 100644
--- a/src/platform/tests/test-common.h
+++ b/src/platform/tests/test-common.h
@@ -15,9 +15,6 @@
#define debug(...) nm_log_dbg (LOGD_PLATFORM, __VA_ARGS__)
-#define error(err) g_assert (nm_platform_get_error (NM_PLATFORM_GET) == err)
-#define no_error() error (NM_PLATFORM_ERROR_SUCCESS)
-
typedef struct {
int handler_id;
const char *name;
diff --git a/src/platform/tests/test-link.c b/src/platform/tests/test-link.c
index 40b4731b66..e09e1eb9d1 100644
--- a/src/platform/tests/test-link.c
+++ b/src/platform/tests/test-link.c
@@ -22,54 +22,32 @@ test_bogus(void)
size_t addrlen;
g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, BOGUS_NAME));
- no_error ();
g_assert (!nm_platform_link_delete (NM_PLATFORM_GET, BOGUS_IFINDEX));
- error (NM_PLATFORM_ERROR_NOT_FOUND);
g_assert (!nm_platform_link_get_ifindex (NM_PLATFORM_GET, BOGUS_NAME));
- error (NM_PLATFORM_ERROR_NOT_FOUND);
g_assert (!nm_platform_link_get_name (NM_PLATFORM_GET, BOGUS_IFINDEX));
- error (NM_PLATFORM_ERROR_NOT_FOUND);
g_assert (!nm_platform_link_get_type (NM_PLATFORM_GET, BOGUS_IFINDEX));
- error (NM_PLATFORM_ERROR_NOT_FOUND);
g_assert (!nm_platform_link_get_type_name (NM_PLATFORM_GET, BOGUS_IFINDEX));
- error (NM_PLATFORM_ERROR_NOT_FOUND);
g_assert (!nm_platform_link_set_up (NM_PLATFORM_GET, BOGUS_IFINDEX, NULL));
- error (NM_PLATFORM_ERROR_NOT_FOUND);
g_assert (!nm_platform_link_set_down (NM_PLATFORM_GET, BOGUS_IFINDEX));
- error (NM_PLATFORM_ERROR_NOT_FOUND);
g_assert (!nm_platform_link_set_arp (NM_PLATFORM_GET, BOGUS_IFINDEX));
- error (NM_PLATFORM_ERROR_NOT_FOUND);
g_assert (!nm_platform_link_set_noarp (NM_PLATFORM_GET, BOGUS_IFINDEX));
- error (NM_PLATFORM_ERROR_NOT_FOUND);
g_assert (!nm_platform_link_is_up (NM_PLATFORM_GET, BOGUS_IFINDEX));
- error (NM_PLATFORM_ERROR_NOT_FOUND);
g_assert (!nm_platform_link_is_connected (NM_PLATFORM_GET, BOGUS_IFINDEX));
- error (NM_PLATFORM_ERROR_NOT_FOUND);
g_assert (!nm_platform_link_uses_arp (NM_PLATFORM_GET, BOGUS_IFINDEX));
- error (NM_PLATFORM_ERROR_NOT_FOUND);
g_assert (!nm_platform_link_get_address (NM_PLATFORM_GET, BOGUS_IFINDEX, &addrlen));
g_assert (!addrlen);
- error (NM_PLATFORM_ERROR_NOT_FOUND);
g_assert (!nm_platform_link_get_address (NM_PLATFORM_GET, BOGUS_IFINDEX, NULL));
- error (NM_PLATFORM_ERROR_NOT_FOUND);
g_assert (!nm_platform_link_set_mtu (NM_PLATFORM_GET, BOGUS_IFINDEX, MTU));
- error (NM_PLATFORM_ERROR_NOT_FOUND);
g_assert (!nm_platform_link_get_mtu (NM_PLATFORM_GET, BOGUS_IFINDEX));
- error (NM_PLATFORM_ERROR_NOT_FOUND);
g_assert (!nm_platform_link_supports_carrier_detect (NM_PLATFORM_GET, BOGUS_IFINDEX));
- error (NM_PLATFORM_ERROR_NOT_FOUND);
g_assert (!nm_platform_link_supports_vlans (NM_PLATFORM_GET, BOGUS_IFINDEX));
- error (NM_PLATFORM_ERROR_NOT_FOUND);
g_assert (!nm_platform_vlan_get_info (NM_PLATFORM_GET, BOGUS_IFINDEX, NULL, NULL));
- error (NM_PLATFORM_ERROR_NOT_FOUND);
g_assert (!nm_platform_vlan_set_ingress_map (NM_PLATFORM_GET, BOGUS_IFINDEX, 0, 0));
- error (NM_PLATFORM_ERROR_NOT_FOUND);
g_assert (!nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, BOGUS_IFINDEX, 0, 0));
- error (NM_PLATFORM_ERROR_NOT_FOUND);
}
static void
@@ -103,8 +81,6 @@ software_add (NMLinkType link_type, const char *name)
/* Check that bond0 is *not* automatically created. */
if (!bond0_exists)
g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, "bond0"));
-
- nm_platform_set_error (NM_PLATFORM_GET, plerr);
return plerr == NM_PLATFORM_ERROR_SUCCESS;
}
case NM_LINK_TYPE_TEAM:
@@ -170,8 +146,8 @@ test_slave (int master, int type, SignalData *master_changed)
/* Enslave */
link_changed->ifindex = ifindex;
- g_assert (nm_platform_link_enslave (NM_PLATFORM_GET, master, ifindex)); no_error ();
- g_assert_cmpint (nm_platform_link_get_master (NM_PLATFORM_GET, ifindex), ==, master); no_error ();
+ g_assert (nm_platform_link_enslave (NM_PLATFORM_GET, master, ifindex));
+ g_assert_cmpint (nm_platform_link_get_master (NM_PLATFORM_GET, ifindex), ==, master);
accept_signals (link_changed, 1, 3);
accept_signals (master_changed, 0, 1);
@@ -220,7 +196,7 @@ test_slave (int master, int type, SignalData *master_changed)
}
/* Set slave up and see if master gets up too */
- g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, ifindex, NULL)); no_error ();
+ g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, ifindex, NULL));
g_assert (nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex));
g_assert (nm_platform_link_is_connected (NM_PLATFORM_GET, master));
accept_signals (link_changed, 1, 3);
@@ -232,7 +208,7 @@ test_slave (int master, int type, SignalData *master_changed)
* Gracefully succeed if already enslaved.
*/
ensure_no_signal (link_changed);
- g_assert (nm_platform_link_enslave (NM_PLATFORM_GET, master, ifindex)); no_error ();
+ g_assert (nm_platform_link_enslave (NM_PLATFORM_GET, master, ifindex));
accept_signals (link_changed, 0, 2);
ensure_no_signal (master_changed);
@@ -241,9 +217,7 @@ test_slave (int master, int type, SignalData *master_changed)
case NM_LINK_TYPE_BRIDGE:
if (nmtst_platform_is_sysfs_writable ()) {
g_assert (nm_platform_slave_set_option (NM_PLATFORM_GET, ifindex, "priority", "789"));
- no_error ();
value = nm_platform_slave_get_option (NM_PLATFORM_GET, ifindex, "priority");
- no_error ();
g_assert_cmpstr (value, ==, "789");
g_free (value);
}
@@ -255,7 +229,7 @@ test_slave (int master, int type, SignalData *master_changed)
/* Release */
ensure_no_signal (link_changed);
g_assert (nm_platform_link_release (NM_PLATFORM_GET, master, ifindex));
- g_assert_cmpint (nm_platform_link_get_master (NM_PLATFORM_GET, ifindex), ==, 0); no_error ();
+ g_assert_cmpint (nm_platform_link_get_master (NM_PLATFORM_GET, ifindex), ==, 0);
accept_signals (link_changed, 1, 3);
if (link_type != NM_LINK_TYPE_TEAM)
accept_signals (master_changed, 1, 2);
@@ -267,14 +241,12 @@ test_slave (int master, int type, SignalData *master_changed)
/* Release again */
ensure_no_signal (link_changed);
g_assert (!nm_platform_link_release (NM_PLATFORM_GET, master, ifindex));
- error (NM_PLATFORM_ERROR_NOT_SLAVE);
ensure_no_signal (master_changed);
/* Remove */
ensure_no_signal (link_changed);
g_assert (nm_platform_link_delete (NM_PLATFORM_GET, ifindex));
- no_error ();
accept_signals (master_changed, 0, 1);
accept_signals (link_changed, 0, 1);
accept_signal (link_removed);
@@ -296,7 +268,6 @@ test_software (NMLinkType link_type, const char *link_typename)
/* Add */
link_added = add_signal_ifname (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_ADDED, link_callback, DEVICE_NAME);
g_assert (software_add (link_type, DEVICE_NAME));
- no_error ();
accept_signal (link_added);
g_assert (nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME));
ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
@@ -309,12 +280,10 @@ test_software (NMLinkType link_type, const char *link_typename)
g_assert (nm_platform_vlan_get_info (NM_PLATFORM_GET, ifindex, &vlan_parent, &vlan_id));
g_assert_cmpint (vlan_parent, ==, nm_platform_link_get_ifindex (NM_PLATFORM_GET, PARENT_NAME));
g_assert_cmpint (vlan_id, ==, VLAN_ID);
- no_error ();
}
/* Add again */
g_assert (!software_add (link_type, DEVICE_NAME));
- error (NM_PLATFORM_ERROR_EXISTS);
/* Set ARP/NOARP */
g_assert (nm_platform_link_uses_arp (NM_PLATFORM_GET, ifindex));
@@ -330,9 +299,7 @@ test_software (NMLinkType link_type, const char *link_typename)
case NM_LINK_TYPE_BRIDGE:
if (nmtst_platform_is_sysfs_writable ()) {
g_assert (nm_platform_master_set_option (NM_PLATFORM_GET, ifindex, "forward_delay", "789"));
- no_error ();
value = nm_platform_master_get_option (NM_PLATFORM_GET, ifindex, "forward_delay");
- no_error ();
g_assert_cmpstr (value, ==, "789");
g_free (value);
}
@@ -340,9 +307,7 @@ test_software (NMLinkType link_type, const char *link_typename)
case NM_LINK_TYPE_BOND:
if (nmtst_platform_is_sysfs_writable ()) {
g_assert (nm_platform_master_set_option (NM_PLATFORM_GET, ifindex, "mode", "active-backup"));
- no_error ();
value = nm_platform_master_get_option (NM_PLATFORM_GET, ifindex, "mode");
- no_error ();
/* When reading back, the output looks slightly different. */
g_assert (g_str_has_prefix (value, "active-backup"));
g_free (value);
@@ -368,17 +333,13 @@ test_software (NMLinkType link_type, const char *link_typename)
/* Delete */
g_assert (nm_platform_link_delete (NM_PLATFORM_GET, ifindex));
- no_error ();
- g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME)); no_error ();
+ g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME));
g_assert_cmpint (nm_platform_link_get_type (NM_PLATFORM_GET, ifindex), ==, NM_LINK_TYPE_NONE);
- error (NM_PLATFORM_ERROR_NOT_FOUND);
g_assert (!nm_platform_link_get_type (NM_PLATFORM_GET, ifindex));
- error (NM_PLATFORM_ERROR_NOT_FOUND);
accept_signal (link_removed);
/* Delete again */
g_assert (!nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME)));
- error (NM_PLATFORM_ERROR_NOT_FOUND);
/* VLAN: Delete parent */
if (link_type == NM_LINK_TYPE_VLAN) {
@@ -436,18 +397,15 @@ test_internal (void)
int ifindex;
/* Check the functions for non-existent devices */
- g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME)); no_error ();
+ g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME));
g_assert (!nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME));
- error (NM_PLATFORM_ERROR_NOT_FOUND);
/* Add device */
g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME, NULL) == NM_PLATFORM_ERROR_SUCCESS);
- no_error ();
accept_signal (link_added);
/* Try to add again */
g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME, NULL) == NM_PLATFORM_ERROR_EXISTS);
- error (NM_PLATFORM_ERROR_EXISTS);
/* Check device index, name and type */
ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
@@ -459,15 +417,15 @@ test_internal (void)
link_removed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, link_callback, ifindex);
/* Up/connected */
- g_assert (!nm_platform_link_is_up (NM_PLATFORM_GET, ifindex)); no_error ();
- g_assert (!nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex)); no_error ();
- g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, ifindex, NULL)); no_error ();
- g_assert (nm_platform_link_is_up (NM_PLATFORM_GET, ifindex)); no_error ();
- g_assert (nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex)); no_error ();
+ g_assert (!nm_platform_link_is_up (NM_PLATFORM_GET, ifindex));
+ g_assert (!nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex));
+ g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, ifindex, NULL));
+ g_assert (nm_platform_link_is_up (NM_PLATFORM_GET, ifindex));
+ g_assert (nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex));
accept_signal (link_changed);
- g_assert (nm_platform_link_set_down (NM_PLATFORM_GET, ifindex)); no_error ();
- g_assert (!nm_platform_link_is_up (NM_PLATFORM_GET, ifindex)); no_error ();
- g_assert (!nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex)); no_error ();
+ g_assert (nm_platform_link_set_down (NM_PLATFORM_GET, ifindex));
+ g_assert (!nm_platform_link_is_up (NM_PLATFORM_GET, ifindex));
+ g_assert (!nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex));
accept_signal (link_changed);
/* arp/noarp */
@@ -494,18 +452,15 @@ test_internal (void)
/* Set MTU */
g_assert (nm_platform_link_set_mtu (NM_PLATFORM_GET, ifindex, MTU));
- no_error ();
g_assert_cmpint (nm_platform_link_get_mtu (NM_PLATFORM_GET, ifindex), ==, MTU);
accept_signal (link_changed);
/* Delete device */
g_assert (nm_platform_link_delete (NM_PLATFORM_GET, ifindex));
- no_error ();
accept_signal (link_removed);
/* Try to delete again */
g_assert (!nm_platform_link_delete (NM_PLATFORM_GET, ifindex));
- error (NM_PLATFORM_ERROR_NOT_FOUND);
free_signal (link_added);
free_signal (link_changed);
diff --git a/src/platform/tests/test-route.c b/src/platform/tests/test-route.c
index 1bf18ff12a..cd4217d248 100644
--- a/src/platform/tests/test-route.c
+++ b/src/platform/tests/test-route.c
@@ -66,7 +66,6 @@ test_ip4_route_metric0 (void)
/* add the first route */
g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, INADDR_ANY, 0, metric, mss));
- no_error ();
accept_signal (route_added);
assert_ip4_route_exists (FALSE, DEVICE_NAME, network, plen, 0);
@@ -74,7 +73,6 @@ test_ip4_route_metric0 (void)
/* Deleting route with metric 0 does nothing */
g_assert (nm_platform_ip4_route_delete (NM_PLATFORM_GET, ifindex, network, plen, 0));
- no_error ();
ensure_no_signal (route_removed);
assert_ip4_route_exists (FALSE, DEVICE_NAME, network, plen, 0);
@@ -82,7 +80,6 @@ test_ip4_route_metric0 (void)
/* add the second route */
g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, INADDR_ANY, 0, 0, mss));
- no_error ();
accept_signal (route_added);
assert_ip4_route_exists (TRUE, DEVICE_NAME, network, plen, 0);
@@ -90,7 +87,6 @@ test_ip4_route_metric0 (void)
/* Delete route with metric 0 */
g_assert (nm_platform_ip4_route_delete (NM_PLATFORM_GET, ifindex, network, plen, 0));
- no_error ();
accept_signal (route_removed);
assert_ip4_route_exists (FALSE, DEVICE_NAME, network, plen, 0);
@@ -98,7 +94,6 @@ test_ip4_route_metric0 (void)
/* Delete route with metric 0 again (we expect nothing to happen) */
g_assert (nm_platform_ip4_route_delete (NM_PLATFORM_GET, ifindex, network, plen, 0));
- no_error ();
ensure_no_signal (route_removed);
assert_ip4_route_exists (FALSE, DEVICE_NAME, network, plen, 0);
@@ -106,7 +101,6 @@ test_ip4_route_metric0 (void)
/* Delete the other route */
g_assert (nm_platform_ip4_route_delete (NM_PLATFORM_GET, ifindex, network, plen, metric));
- no_error ();
accept_signal (route_removed);
assert_ip4_route_exists (FALSE, DEVICE_NAME, network, plen, 0);
@@ -138,35 +132,26 @@ test_ip4_route (void)
/* Add route to gateway */
g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, gateway, 32, INADDR_ANY, 0, metric, mss));
- no_error ();
accept_signal (route_added);
/* Add route */
assert_ip4_route_exists (FALSE, DEVICE_NAME, network, plen, metric);
- no_error ();
g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, 0, metric, mss));
- no_error ();
assert_ip4_route_exists (TRUE, DEVICE_NAME, network, plen, metric);
- no_error ();
accept_signal (route_added);
/* Add route again */
g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, 0, metric, mss));
- no_error ();
accept_signals (route_changed, 0, 1);
/* Add default route */
assert_ip4_route_exists (FALSE, DEVICE_NAME, 0, 0, metric);
- no_error ();
g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, 0, 0, gateway, 0, metric, mss));
- no_error ();
assert_ip4_route_exists (TRUE, DEVICE_NAME, 0, 0, metric);
- no_error ();
accept_signal (route_added);
/* Add default route again */
g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, 0, 0, gateway, 0, metric, mss));
- no_error ();
accept_signals (route_changed, 0, 1);
/* Test route listing */
@@ -202,13 +187,11 @@ test_ip4_route (void)
/* Remove route */
g_assert (nm_platform_ip4_route_delete (NM_PLATFORM_GET, ifindex, network, plen, metric));
- no_error ();
assert_ip4_route_exists (FALSE, DEVICE_NAME, network, plen, metric);
accept_signal (route_removed);
/* Remove route again */
g_assert (nm_platform_ip4_route_delete (NM_PLATFORM_GET, ifindex, network, plen, metric));
- no_error ();
free_signal (route_added);
free_signal (route_changed);
@@ -236,35 +219,26 @@ test_ip6_route (void)
/* Add route to gateway */
g_assert (nm_platform_ip6_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, gateway, 128, in6addr_any, metric, mss));
- no_error ();
accept_signal (route_added);
/* Add route */
g_assert (!nm_platform_ip6_route_exists (NM_PLATFORM_GET, ifindex, network, plen, metric));
- no_error ();
g_assert (nm_platform_ip6_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, metric, mss));
- no_error ();
g_assert (nm_platform_ip6_route_exists (NM_PLATFORM_GET, ifindex, network, plen, metric));
- no_error ();
accept_signal (route_added);
/* Add route again */
g_assert (nm_platform_ip6_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, metric, mss));
- no_error ();
accept_signals (route_changed, 0, 1);
/* Add default route */
g_assert (!nm_platform_ip6_route_exists (NM_PLATFORM_GET, ifindex, in6addr_any, 0, metric));
- no_error ();
g_assert (nm_platform_ip6_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, in6addr_any, 0, gateway, metric, mss));
- no_error ();
g_assert (nm_platform_ip6_route_exists (NM_PLATFORM_GET, ifindex, in6addr_any, 0, metric));
- no_error ();
accept_signal (route_added);
/* Add default route again */
g_assert (nm_platform_ip6_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, in6addr_any, 0, gateway, metric, mss));
- no_error ();
accept_signals (route_changed, 0, 1);
/* Test route listing */
@@ -297,13 +271,11 @@ test_ip6_route (void)
/* Remove route */
g_assert (nm_platform_ip6_route_delete (NM_PLATFORM_GET, ifindex, network, plen, metric));
- no_error ();
g_assert (!nm_platform_ip6_route_exists (NM_PLATFORM_GET, ifindex, network, plen, metric));
accept_signal (route_removed);
/* Remove route again */
g_assert (nm_platform_ip6_route_delete (NM_PLATFORM_GET, ifindex, network, plen, metric));
- no_error ();
free_signal (route_added);
free_signal (route_changed);