diff options
author | Philip Withnall <withnall@endlessm.com> | 2020-02-18 11:33:24 +0000 |
---|---|---|
committer | Ray Strode <halfline@gmail.com> | 2020-02-24 15:30:57 +0000 |
commit | 8ba5a67f1d0fe867ef5569ec22e236db4d228631 (patch) | |
tree | 8fa0ea4e6c2581a3e54890cc2326f2406f74e735 | |
parent | 8d348ba2016b6342f3362ee292c9ee088f2a3cf0 (diff) |
act-user: Use G_DECLARE_FINAL_TYPE to declare ActUser
This tidies up the code a bit, and (critically) exposes a concrete
structure for `ActUser` and `ActUserClass`. Previously these were
dangling typedefs, which meant the compiler had no idea they derived
from `GObject`, and hence would give warnings about strict aliasing when
(for example) calling:
```
g_set_object (&my_user, user);
```
where `my_user` and `user` were both `ActUser*`.
This shouldn’t introduce any API or ABI changes, as the library
basically exposed no API in this area before. The autoptr cleanup
function is now defined by `G_DECLARE_FINAL_TYPE`.
libaccountsservice already depends on GLib 2.63, so no dependency bump
is needed.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
-rw-r--r-- | src/libaccountsservice/act-user.c | 9 | ||||
-rw-r--r-- | src/libaccountsservice/act-user.h | 14 |
2 files changed, 2 insertions, 21 deletions
diff --git a/src/libaccountsservice/act-user.c b/src/libaccountsservice/act-user.c index 3752dc7..84774c7 100644 --- a/src/libaccountsservice/act-user.c +++ b/src/libaccountsservice/act-user.c @@ -66,10 +66,6 @@ * Mode for setting the user's password. */ -#define ACT_USER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ACT_TYPE_USER, ActUserClass)) -#define ACT_IS_USER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ACT_TYPE_USER)) -#define ACT_USER_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), ACT_TYPE_USER, ActUserClass)) - #define ACCOUNTS_NAME "org.freedesktop.Accounts" #define ACCOUNTS_USER_INTERFACE "org.freedesktop.Accounts.User" @@ -118,11 +114,6 @@ struct _ActUser { guint nonexistent : 1; }; -struct _ActUserClass -{ - GObjectClass parent_class; -}; - static void act_user_finalize (GObject *object); static guint signals[LAST_SIGNAL] = { 0 }; diff --git a/src/libaccountsservice/act-user.h b/src/libaccountsservice/act-user.h index 34d7fe3..89a8221 100644 --- a/src/libaccountsservice/act-user.h +++ b/src/libaccountsservice/act-user.h @@ -31,9 +31,8 @@ G_BEGIN_DECLS -#define ACT_TYPE_USER (act_user_get_type ()) -#define ACT_USER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), ACT_TYPE_USER, ActUser)) -#define ACT_IS_USER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), ACT_TYPE_USER)) +#define ACT_TYPE_USER (act_user_get_type()) +G_DECLARE_FINAL_TYPE (ActUser, act_user, ACT, USER, GObject) typedef enum { ACT_USER_ACCOUNT_TYPE_STANDARD, @@ -46,11 +45,6 @@ typedef enum { ACT_USER_PASSWORD_MODE_NONE, } ActUserPasswordMode; -typedef struct _ActUser ActUser; -typedef struct _ActUserClass ActUserClass; - -GType act_user_get_type (void) G_GNUC_CONST; - const char *act_user_get_object_path (ActUser *user); uid_t act_user_get_uid (ActUser *user); @@ -127,10 +121,6 @@ void act_user_set_locked (ActUser *user, void act_user_set_automatic_login (ActUser *user, gboolean enabled); -#if GLIB_CHECK_VERSION(2, 44, 0) -G_DEFINE_AUTOPTR_CLEANUP_FUNC (ActUser, g_object_unref) -#endif - G_END_DECLS #endif /* __ACT_USER_H__ */ |