diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index 016c5f91bd..934af4d720 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -129,6 +129,19 @@ nm_platform_get (void) /******************************************************************/ +/** + * nm_platform_set_error: + * @error: The error code + * + * Convenience function to falsify platform->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 (NMPlatformError error) +{ + platform->error = error; +} + /** * nm_platform_get_error: * @@ -137,7 +150,7 @@ nm_platform_get (void) * * Returns: Integer error code. */ -int +NMPlatformError nm_platform_get_error (void) { g_assert (platform); diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h index 5f9cf06f65..b146892d07 100644 --- a/src/platform/nm-platform.h +++ b/src/platform/nm-platform.h @@ -34,6 +34,17 @@ /******************************************************************/ +typedef enum { + /* no error specified, sometimes this means the arguments were wrong */ + NM_PLATFORM_ERROR_NONE, + /* object was not found */ + NM_PLATFORM_ERROR_NOT_FOUND, + /* object already exists */ + NM_PLATFORM_ERROR_EXISTS, + /* object is not a slave */ + NM_PLATFORM_ERROR_NOT_SLAVE +} NMPlatformError; + typedef enum { NM_LINK_TYPE_NONE, NM_LINK_TYPE_UNKNOWN, @@ -117,7 +128,7 @@ typedef struct { typedef struct { GObject parent; - int error; + NMPlatformError error; } NMPlatform; typedef struct { @@ -206,18 +217,6 @@ typedef struct { #define NM_PLATFORM_IP6_ROUTE_CHANGED "ip6-route-changed" #define NM_PLATFORM_IP6_ROUTE_REMOVED "ip6-route-removed" -/* NMPlatform error codes */ -enum { - /* no error specified, sometimes this means the arguments were wrong */ - NM_PLATFORM_ERROR_NONE, - /* object was not found */ - NM_PLATFORM_ERROR_NOT_FOUND, - /* object already exists */ - NM_PLATFORM_ERROR_EXISTS, - /* object is not a slave */ - NM_PLATFORM_ERROR_NOT_SLAVE -}; - /******************************************************************/ GType nm_platform_get_type (void); @@ -228,7 +227,8 @@ void nm_platform_free (void); /******************************************************************/ -int nm_platform_get_error (void); +void nm_platform_set_error (NMPlatformError error); +NMPlatformError nm_platform_get_error (void); const char *nm_platform_get_error_msg (void); gboolean nm_platform_sysctl_set (const char *path, const char *value);