[systemd-devel] [PATCH 1/2] everywhere: don't use uprefixed word "context" in struct and function names

Lennart Poettering lennart at poettering.net
Mon Aug 25 11:12:39 PDT 2014


On Mon, 25.08.14 10:02, Michal Sekletar (msekleta at redhat.com) wrote:

> We use libselinux which exports context_free function. To prevent name
> clashes rename our internal APIs and don't use context_* but rather
> appropriately prefixed names.

I'd prefer if we'd leave the type name as it is now. But maybe just
rename our functions to "context_done()" (at least the ones in
hostnamed, localed, timedated, socket-proxyd, ... After all they don't really
free the context, just the stuff inside it)...

And the mmap_context doesn't actually have a context_free() right now,
right?

ANd let it be known for all times: libselinux is stupid. I wished they'd
do libselinux2 or so, and just start anew, with the redundancies
removed, and everything with properly namespaced names and stuff...

> ---
>  src/hostname/hostnamed.c         |  72 +++++++++++++--------------
>  src/journal/mmap-cache.c         | 102 +++++++++++++++++++--------------------
>  src/journal/mmap-cache.h         |   2 +-
>  src/locale/localed.c             |  84 ++++++++++++++++----------------
>  src/socket-proxy/socket-proxyd.c |  18 +++----
>  src/timedate/timedated.c         |  54 ++++++++++-----------
>  6 files changed, 166 insertions(+), 166 deletions(-)
> 
> diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c
> index d31fef7..edd9d9b 100644
> --- a/src/hostname/hostnamed.c
> +++ b/src/hostname/hostnamed.c
> @@ -53,12 +53,12 @@ enum {
>          _PROP_MAX
>  };
>  
> -typedef struct Context {
> +typedef struct HostnamedContext {
>          char *data[_PROP_MAX];
>          Hashmap *polkit_registry;
> -} Context;
> +} HostnamedContext;
>  
> -static void context_reset(Context *c) {
> +static void hostnamed_context_reset(HostnamedContext *c) {
>          int p;
>  
>          assert(c);
> @@ -69,20 +69,20 @@ static void context_reset(Context *c) {
>          }
>  }
>  
> -static void context_free(Context *c) {
> +static void hostnamed_context_free(HostnamedContext *c) {
>          assert(c);
>  
> -        context_reset(c);
> +        hostnamed_context_reset(c);
>          bus_verify_polkit_async_registry_free(c->polkit_registry);
>  }
>  
> -static int context_read_data(Context *c) {
> +static int hostnamed_context_read_data(HostnamedContext *c) {
>          int r;
>          struct utsname u;
>  
>          assert(c);
>  
> -        context_reset(c);
> +        hostnamed_context_reset(c);
>  
>          assert_se(uname(&u) >= 0);
>          c->data[PROP_KERNEL_NAME] = strdup(u.sysname);
> @@ -242,7 +242,7 @@ try_dmi:
>          return NULL;
>  }
>  
> -static char* context_fallback_icon_name(Context *c) {
> +static char* hostnamed_context_fallback_icon_name(HostnamedContext *c) {
>          const char *chassis;
>  
>          assert(c);
> @@ -262,7 +262,7 @@ static bool hostname_is_useful(const char *hn) {
>          return !isempty(hn) && !is_localhost(hn);
>  }
>  
> -static int context_update_kernel_hostname(Context *c) {
> +static int hostnamed_context_update_kernel_hostname(HostnamedContext *c) {
>          const char *static_hn;
>          const char *hn;
>  
> @@ -293,7 +293,7 @@ static int context_update_kernel_hostname(Context *c) {
>          return 0;
>  }
>  
> -static int context_write_data_static_hostname(Context *c) {
> +static int hostnamed_context_write_data_static_hostname(HostnamedContext *c) {
>  
>          assert(c);
>  
> @@ -307,7 +307,7 @@ static int context_write_data_static_hostname(Context *c) {
>          return write_string_file_atomic_label("/etc/hostname", c->data[PROP_STATIC_HOSTNAME]);
>  }
>  
> -static int context_write_data_machine_info(Context *c) {
> +static int hostnamed_context_write_data_machine_info(HostnamedContext *c) {
>  
>          static const char * const name[_PROP_MAX] = {
>                  [PROP_PRETTY_HOSTNAME] = "PRETTY_HOSTNAME",
> @@ -369,11 +369,11 @@ static int property_get_icon_name(
>                  sd_bus_error *error) {
>  
>          _cleanup_free_ char *n = NULL;
> -        Context *c = userdata;
> +        HostnamedContext *c = userdata;
>          const char *name;
>  
>          if (isempty(c->data[PROP_ICON_NAME]))
> -                name = n = context_fallback_icon_name(c);
> +                name = n = hostnamed_context_fallback_icon_name(c);
>          else
>                  name = c->data[PROP_ICON_NAME];
>  
> @@ -392,7 +392,7 @@ static int property_get_chassis(
>                  void *userdata,
>                  sd_bus_error *error) {
>  
> -        Context *c = userdata;
> +        HostnamedContext *c = userdata;
>          const char *name;
>  
>          if (isempty(c->data[PROP_CHASSIS]))
> @@ -404,7 +404,7 @@ static int property_get_chassis(
>  }
>  
>  static int method_set_hostname(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) {
> -        Context *c = userdata;
> +        HostnamedContext *c = userdata;
>          const char *name;
>          int interactive;
>          char *h;
> @@ -439,7 +439,7 @@ static int method_set_hostname(sd_bus *bus, sd_bus_message *m, void *userdata, s
>          free(c->data[PROP_HOSTNAME]);
>          c->data[PROP_HOSTNAME] = h;
>  
> -        r = context_update_kernel_hostname(c);
> +        r = hostnamed_context_update_kernel_hostname(c);
>          if (r < 0) {
>                  log_error("Failed to set host name: %s", strerror(-r));
>                  return sd_bus_error_set_errnof(error, r, "Failed to set hostname: %s", strerror(-r));
> @@ -453,7 +453,7 @@ static int method_set_hostname(sd_bus *bus, sd_bus_message *m, void *userdata, s
>  }
>  
>  static int method_set_static_hostname(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) {
> -        Context *c = userdata;
> +        HostnamedContext *c = userdata;
>          const char *name;
>          int interactive;
>          int r;
> @@ -491,13 +491,13 @@ static int method_set_static_hostname(sd_bus *bus, sd_bus_message *m, void *user
>                  c->data[PROP_STATIC_HOSTNAME] = h;
>          }
>  
> -        r = context_update_kernel_hostname(c);
> +        r = hostnamed_context_update_kernel_hostname(c);
>          if (r < 0) {
>                  log_error("Failed to set host name: %s", strerror(-r));
>                  return sd_bus_error_set_errnof(error, r, "Failed to set hostname: %s", strerror(-r));
>          }
>  
> -        r = context_write_data_static_hostname(c);
> +        r = hostnamed_context_write_data_static_hostname(c);
>          if (r < 0) {
>                  log_error("Failed to write static host name: %s", strerror(-r));
>                  return sd_bus_error_set_errnof(error, r, "Failed to set static hostname: %s", strerror(-r));
> @@ -510,7 +510,7 @@ static int method_set_static_hostname(sd_bus *bus, sd_bus_message *m, void *user
>          return sd_bus_reply_method_return(m, NULL);
>  }
>  
> -static int set_machine_info(Context *c, sd_bus *bus, sd_bus_message *m, int prop, sd_bus_message_handler_t cb, sd_bus_error *error) {
> +static int set_machine_info(HostnamedContext *c, sd_bus *bus, sd_bus_message *m, int prop, sd_bus_message_handler_t cb, sd_bus_error *error) {
>          int interactive;
>          const char *name;
>          int r;
> @@ -570,7 +570,7 @@ static int set_machine_info(Context *c, sd_bus *bus, sd_bus_message *m, int prop
>                  c->data[prop] = h;
>          }
>  
> -        r = context_write_data_machine_info(c);
> +        r = hostnamed_context_write_data_machine_info(c);
>          if (r < 0) {
>                  log_error("Failed to write machine info: %s", strerror(-r));
>                  return sd_bus_error_set_errnof(error, r, "Failed to write machine info: %s", strerror(-r));
> @@ -613,18 +613,18 @@ static int method_set_location(sd_bus *bus, sd_bus_message *m, void *userdata, s
>  
>  static const sd_bus_vtable hostname_vtable[] = {
>          SD_BUS_VTABLE_START(0),
> -        SD_BUS_PROPERTY("Hostname", "s", NULL, offsetof(Context, data) + sizeof(char*) * PROP_HOSTNAME, 0),
> -        SD_BUS_PROPERTY("StaticHostname", "s", NULL, offsetof(Context, data) + sizeof(char*) * PROP_STATIC_HOSTNAME, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
> -        SD_BUS_PROPERTY("PrettyHostname", "s", NULL, offsetof(Context, data) + sizeof(char*) * PROP_PRETTY_HOSTNAME, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
> +        SD_BUS_PROPERTY("Hostname", "s", NULL, offsetof(HostnamedContext, data) + sizeof(char*) * PROP_HOSTNAME, 0),
> +        SD_BUS_PROPERTY("StaticHostname", "s", NULL, offsetof(HostnamedContext, data) + sizeof(char*) * PROP_STATIC_HOSTNAME, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
> +        SD_BUS_PROPERTY("PrettyHostname", "s", NULL, offsetof(HostnamedContext, data) + sizeof(char*) * PROP_PRETTY_HOSTNAME, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
>          SD_BUS_PROPERTY("IconName", "s", property_get_icon_name, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
>          SD_BUS_PROPERTY("Chassis", "s", property_get_chassis, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
> -        SD_BUS_PROPERTY("Deployment", "s", NULL, offsetof(Context, data) + sizeof(char*) * PROP_DEPLOYMENT, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
> -        SD_BUS_PROPERTY("Location", "s", NULL, offsetof(Context, data) + sizeof(char*) * PROP_LOCATION, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
> -        SD_BUS_PROPERTY("KernelName", "s", NULL, offsetof(Context, data) + sizeof(char*) * PROP_KERNEL_NAME, SD_BUS_VTABLE_PROPERTY_CONST),
> -        SD_BUS_PROPERTY("KernelRelease", "s", NULL, offsetof(Context, data) + sizeof(char*) * PROP_KERNEL_RELEASE, SD_BUS_VTABLE_PROPERTY_CONST),
> -        SD_BUS_PROPERTY("KernelVersion", "s", NULL, offsetof(Context, data) + sizeof(char*) * PROP_KERNEL_VERSION, SD_BUS_VTABLE_PROPERTY_CONST),
> -        SD_BUS_PROPERTY("OperatingSystemPrettyName", "s", NULL, offsetof(Context, data) + sizeof(char*) * PROP_OS_PRETTY_NAME, SD_BUS_VTABLE_PROPERTY_CONST),
> -        SD_BUS_PROPERTY("OperatingSystemCPEName", "s", NULL, offsetof(Context, data) + sizeof(char*) * PROP_OS_CPE_NAME, SD_BUS_VTABLE_PROPERTY_CONST),
> +        SD_BUS_PROPERTY("Deployment", "s", NULL, offsetof(HostnamedContext, data) + sizeof(char*) * PROP_DEPLOYMENT, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
> +        SD_BUS_PROPERTY("Location", "s", NULL, offsetof(HostnamedContext, data) + sizeof(char*) * PROP_LOCATION, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
> +        SD_BUS_PROPERTY("KernelName", "s", NULL, offsetof(HostnamedContext, data) + sizeof(char*) * PROP_KERNEL_NAME, SD_BUS_VTABLE_PROPERTY_CONST),
> +        SD_BUS_PROPERTY("KernelRelease", "s", NULL, offsetof(HostnamedContext, data) + sizeof(char*) * PROP_KERNEL_RELEASE, SD_BUS_VTABLE_PROPERTY_CONST),
> +        SD_BUS_PROPERTY("KernelVersion", "s", NULL, offsetof(HostnamedContext, data) + sizeof(char*) * PROP_KERNEL_VERSION, SD_BUS_VTABLE_PROPERTY_CONST),
> +        SD_BUS_PROPERTY("OperatingSystemPrettyName", "s", NULL, offsetof(HostnamedContext, data) + sizeof(char*) * PROP_OS_PRETTY_NAME, SD_BUS_VTABLE_PROPERTY_CONST),
> +        SD_BUS_PROPERTY("OperatingSystemCPEName", "s", NULL, offsetof(HostnamedContext, data) + sizeof(char*) * PROP_OS_CPE_NAME, SD_BUS_VTABLE_PROPERTY_CONST),
>          SD_BUS_METHOD("SetHostname", "sb", NULL, method_set_hostname, SD_BUS_VTABLE_UNPRIVILEGED),
>          SD_BUS_METHOD("SetStaticHostname", "sb", NULL, method_set_static_hostname, SD_BUS_VTABLE_UNPRIVILEGED),
>          SD_BUS_METHOD("SetPrettyHostname", "sb", NULL, method_set_pretty_hostname, SD_BUS_VTABLE_UNPRIVILEGED),
> @@ -635,7 +635,7 @@ static const sd_bus_vtable hostname_vtable[] = {
>          SD_BUS_VTABLE_END,
>  };
>  
> -static int connect_bus(Context *c, sd_event *event, sd_bus **_bus) {
> +static int connect_bus(HostnamedContext *c, sd_event *event, sd_bus **_bus) {
>          _cleanup_bus_close_unref_ sd_bus *bus = NULL;
>          int r;
>  
> @@ -674,7 +674,7 @@ static int connect_bus(Context *c, sd_event *event, sd_bus **_bus) {
>  }
>  
>  int main(int argc, char *argv[]) {
> -        Context context = {};
> +        HostnamedContext hostnamed_context = {};
>          _cleanup_event_unref_ sd_event *event = NULL;
>          _cleanup_bus_close_unref_ sd_bus *bus = NULL;
>          int r;
> @@ -706,11 +706,11 @@ int main(int argc, char *argv[]) {
>  
>          sd_event_set_watchdog(event, true);
>  
> -        r = connect_bus(&context, event, &bus);
> +        r = connect_bus(&hostnamed_context, event, &bus);
>          if (r < 0)
>                  goto finish;
>  
> -        r = context_read_data(&context);
> +        r = hostnamed_context_read_data(&hostnamed_context);
>          if (r < 0) {
>                  log_error("Failed to read hostname and machine information: %s", strerror(-r));
>                  goto finish;
> @@ -723,7 +723,7 @@ int main(int argc, char *argv[]) {
>          }
>  
>  finish:
> -        context_free(&context);
> +        hostnamed_context_free(&hostnamed_context);
>  
>          return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
>  }
> diff --git a/src/journal/mmap-cache.c b/src/journal/mmap-cache.c
> index 7dbbb5e..06fa7f0 100644
> --- a/src/journal/mmap-cache.c
> +++ b/src/journal/mmap-cache.c
> @@ -32,7 +32,7 @@
>  #include "mmap-cache.h"
>  
>  typedef struct Window Window;
> -typedef struct Context Context;
> +typedef struct MmapContext MmapContext;
>  typedef struct FileDescriptor FileDescriptor;
>  
>  struct Window {
> @@ -51,15 +51,15 @@ struct Window {
>          LIST_FIELDS(Window, by_fd);
>          LIST_FIELDS(Window, unused);
>  
> -        LIST_HEAD(Context, contexts);
> +        LIST_HEAD(MmapContext, mmap_contexts);
>  };
>  
> -struct Context {
> +struct MmapContext {
>          MMapCache *cache;
>          unsigned id;
>          Window *window;
>  
> -        LIST_FIELDS(Context, by_window);
> +        LIST_FIELDS(MmapContext, by_window);
>  };
>  
>  struct FileDescriptor {
> @@ -76,7 +76,7 @@ struct MMapCache {
>  
>  
>          Hashmap *fds;
> -        Hashmap *contexts;
> +        Hashmap *mmap_contexts;
>  
>          LIST_HEAD(Window, unused);
>          Window *last_unused;
> @@ -105,7 +105,7 @@ MMapCache* mmap_cache_ref(MMapCache *m) {
>  }
>  
>  static void window_unlink(Window *w) {
> -        Context *c;
> +        MmapContext *c;
>  
>          assert(w);
>  
> @@ -122,7 +122,7 @@ static void window_unlink(Window *w) {
>                  LIST_REMOVE(unused, w->cache->unused, w);
>          }
>  
> -        LIST_FOREACH(by_window, c, w->contexts) {
> +        LIST_FOREACH(by_window, c, w->mmap_contexts) {
>                  assert(c->window == w);
>                  c->window = NULL;
>          }
> @@ -173,7 +173,7 @@ static Window *window_add(MMapCache *m) {
>          return w;
>  }
>  
> -static void context_detach_window(Context *c) {
> +static void mmap_context_detach_window(MmapContext *c) {
>          Window *w;
>  
>          assert(c);
> @@ -183,9 +183,9 @@ static void context_detach_window(Context *c) {
>  
>          w = c->window;
>          c->window = NULL;
> -        LIST_REMOVE(by_window, w->contexts, c);
> +        LIST_REMOVE(by_window, w->mmap_contexts, c);
>  
> -        if (!w->contexts && w->keep_always == 0) {
> +        if (!w->mmap_contexts && w->keep_always == 0) {
>                  /* Not used anymore? */
>                  LIST_PREPEND(unused, c->cache->unused, w);
>                  if (!c->cache->last_unused)
> @@ -195,14 +195,14 @@ static void context_detach_window(Context *c) {
>          }
>  }
>  
> -static void context_attach_window(Context *c, Window *w) {
> +static void mmap_context_attach_window(MmapContext *c, Window *w) {
>          assert(c);
>          assert(w);
>  
>          if (c->window == w)
>                  return;
>  
> -        context_detach_window(c);
> +        mmap_context_detach_window(c);
>  
>          if (w->in_unused) {
>                  /* Used again? */
> @@ -214,31 +214,31 @@ static void context_attach_window(Context *c, Window *w) {
>          }
>  
>          c->window = w;
> -        LIST_PREPEND(by_window, w->contexts, c);
> +        LIST_PREPEND(by_window, w->mmap_contexts, c);
>  }
>  
> -static Context *context_add(MMapCache *m, unsigned id) {
> -        Context *c;
> +static MmapContext *mmap_context_add(MMapCache *m, unsigned id) {
> +        MmapContext *c;
>          int r;
>  
>          assert(m);
>  
> -        c = hashmap_get(m->contexts, UINT_TO_PTR(id + 1));
> +        c = hashmap_get(m->mmap_contexts, UINT_TO_PTR(id + 1));
>          if (c)
>                  return c;
>  
> -        r = hashmap_ensure_allocated(&m->contexts, trivial_hash_func, trivial_compare_func);
> +        r = hashmap_ensure_allocated(&m->mmap_contexts, trivial_hash_func, trivial_compare_func);
>          if (r < 0)
>                  return NULL;
>  
> -        c = new0(Context, 1);
> +        c = new0(MmapContext, 1);
>          if (!c)
>                  return NULL;
>  
>          c->cache = m;
>          c->id = id;
>  
> -        r = hashmap_put(m->contexts, UINT_TO_PTR(id + 1), c);
> +        r = hashmap_put(m->mmap_contexts, UINT_TO_PTR(id + 1), c);
>          if (r < 0) {
>                  free(c);
>                  return NULL;
> @@ -247,13 +247,13 @@ static Context *context_add(MMapCache *m, unsigned id) {
>          return c;
>  }
>  
> -static void context_free(Context *c) {
> +static void mmap_context_free(MmapContext *c) {
>          assert(c);
>  
> -        context_detach_window(c);
> +        mmap_context_detach_window(c);
>  
>          if (c->cache)
> -                assert_se(hashmap_remove(c->cache->contexts, UINT_TO_PTR(c->id + 1)));
> +                assert_se(hashmap_remove(c->cache->mmap_contexts, UINT_TO_PTR(c->id + 1)));
>  
>          free(c);
>  }
> @@ -302,15 +302,15 @@ static FileDescriptor* fd_add(MMapCache *m, int fd) {
>  }
>  
>  static void mmap_cache_free(MMapCache *m) {
> -        Context *c;
> +        MmapContext *c;
>          FileDescriptor *f;
>  
>          assert(m);
>  
> -        while ((c = hashmap_first(m->contexts)))
> -                context_free(c);
> +        while ((c = hashmap_first(m->mmap_contexts)))
> +                mmap_context_free(c);
>  
> -        hashmap_free(m->contexts);
> +        hashmap_free(m->mmap_contexts);
>  
>          while ((f = hashmap_first(m->fds)))
>                  fd_free(f);
> @@ -344,28 +344,28 @@ static int make_room(MMapCache *m) {
>          return 1;
>  }
>  
> -static int try_context(
> +static int try_mmap_context(
>                  MMapCache *m,
>                  int fd,
>                  int prot,
> -                unsigned context,
> +                unsigned mmap_context,
>                  bool keep_always,
>                  uint64_t offset,
>                  size_t size,
>                  void **ret) {
>  
> -        Context *c;
> +        MmapContext *c;
>  
>          assert(m);
>          assert(m->n_ref > 0);
>          assert(fd >= 0);
>          assert(size > 0);
>  
> -        c = hashmap_get(m->contexts, UINT_TO_PTR(context+1));
> +        c = hashmap_get(m->mmap_contexts, UINT_TO_PTR(mmap_context+1));
>          if (!c)
>                  return 0;
>  
> -        assert(c->id == context);
> +        assert(c->id == mmap_context);
>  
>          if (!c->window)
>                  return 0;
> @@ -373,7 +373,7 @@ static int try_context(
>          if (!window_matches(c->window, fd, prot, offset, size)) {
>  
>                  /* Drop the reference to the window, since it's unnecessary now */
> -                context_detach_window(c);
> +                mmap_context_detach_window(c);
>                  return 0;
>          }
>  
> @@ -388,7 +388,7 @@ static int find_mmap(
>                  MMapCache *m,
>                  int fd,
>                  int prot,
> -                unsigned context,
> +                unsigned mmap_context,
>                  bool keep_always,
>                  uint64_t offset,
>                  size_t size,
> @@ -396,7 +396,7 @@ static int find_mmap(
>  
>          FileDescriptor *f;
>          Window *w;
> -        Context *c;
> +        MmapContext *c;
>  
>          assert(m);
>          assert(m->n_ref > 0);
> @@ -416,11 +416,11 @@ static int find_mmap(
>          if (!w)
>                  return 0;
>  
> -        c = context_add(m, context);
> +        c = mmap_context_add(m, mmap_context);
>          if (!c)
>                  return -ENOMEM;
>  
> -        context_attach_window(c, w);
> +        mmap_context_attach_window(c, w);
>          w->keep_always += keep_always;
>  
>          if (ret)
> @@ -432,7 +432,7 @@ static int add_mmap(
>                  MMapCache *m,
>                  int fd,
>                  int prot,
> -                unsigned context,
> +                unsigned mmap_context,
>                  bool keep_always,
>                  uint64_t offset,
>                  size_t size,
> @@ -440,7 +440,7 @@ static int add_mmap(
>                  void **ret) {
>  
>          uint64_t woffset, wsize;
> -        Context *c;
> +        MmapContext *c;
>          FileDescriptor *f;
>          Window *w;
>          void *d;
> @@ -494,7 +494,7 @@ static int add_mmap(
>                          return -ENOMEM;
>          }
>  
> -        c = context_add(m, context);
> +        c = mmap_context_add(m, mmap_context);
>          if (!c)
>                  return -ENOMEM;
>  
> @@ -515,9 +515,9 @@ static int add_mmap(
>  
>          LIST_PREPEND(by_fd, f->windows, w);
>  
> -        context_detach_window(c);
> +        mmap_context_detach_window(c);
>          c->window = w;
> -        LIST_PREPEND(by_window, w->contexts, c);
> +        LIST_PREPEND(by_window, w->mmap_contexts, c);
>  
>          if (ret)
>                  *ret = (uint8_t*) w->ptr + (offset - w->offset);
> @@ -528,7 +528,7 @@ int mmap_cache_get(
>                  MMapCache *m,
>                  int fd,
>                  int prot,
> -                unsigned context,
> +                unsigned mmap_context,
>                  bool keep_always,
>                  uint64_t offset,
>                  size_t size,
> @@ -542,15 +542,15 @@ int mmap_cache_get(
>          assert(fd >= 0);
>          assert(size > 0);
>  
> -        /* Check whether the current context is the right one already */
> -        r = try_context(m, fd, prot, context, keep_always, offset, size, ret);
> +        /* Check whether the current mmap_context is the right one already */
> +        r = try_mmap_context(m, fd, prot, mmap_context, keep_always, offset, size, ret);
>          if (r != 0) {
>                  m->n_hit ++;
>                  return r;
>          }
>  
>          /* Search for a matching mmap */
> -        r = find_mmap(m, fd, prot, context, keep_always, offset, size, ret);
> +        r = find_mmap(m, fd, prot, mmap_context, keep_always, offset, size, ret);
>          if (r != 0) {
>                  m->n_hit ++;
>                  return r;
> @@ -559,14 +559,14 @@ int mmap_cache_get(
>          m->n_missed++;
>  
>          /* Create a new mmap */
> -        return add_mmap(m, fd, prot, context, keep_always, offset, size, st, ret);
> +        return add_mmap(m, fd, prot, mmap_context, keep_always, offset, size, st, ret);
>  }
>  
>  int mmap_cache_release(
>                  MMapCache *m,
>                  int fd,
>                  int prot,
> -                unsigned context,
> +                unsigned mmap_context,
>                  uint64_t offset,
>                  size_t size) {
>  
> @@ -611,16 +611,16 @@ void mmap_cache_close_fd(MMapCache *m, int fd) {
>          fd_free(f);
>  }
>  
> -void mmap_cache_close_context(MMapCache *m, unsigned context) {
> -        Context *c;
> +void mmap_cache_close_mmap_context(MMapCache *m, unsigned mmap_context) {
> +        MmapContext *c;
>  
>          assert(m);
>  
> -        c = hashmap_get(m->contexts, UINT_TO_PTR(context + 1));
> +        c = hashmap_get(m->mmap_contexts, UINT_TO_PTR(mmap_context + 1));
>          if (!c)
>                  return;
>  
> -        context_free(c);
> +        mmap_context_free(c);
>  }
>  
>  unsigned mmap_cache_get_hit(MMapCache *m) {
> diff --git a/src/journal/mmap-cache.h b/src/journal/mmap-cache.h
> index 647555a..4f7cd39 100644
> --- a/src/journal/mmap-cache.h
> +++ b/src/journal/mmap-cache.h
> @@ -49,7 +49,7 @@ int mmap_cache_release(
>          uint64_t offset,
>          size_t size);
>  void mmap_cache_close_fd(MMapCache *m, int fd);
> -void mmap_cache_close_context(MMapCache *m, unsigned context);
> +void mmap_cache_close_mmap_context(MMapCache *m, unsigned context);
>  
>  unsigned mmap_cache_get_hit(MMapCache *m);
>  unsigned mmap_cache_get_missed(MMapCache *m);
> diff --git a/src/locale/localed.c b/src/locale/localed.c
> index 508a000..67506d0 100644
> --- a/src/locale/localed.c
> +++ b/src/locale/localed.c
> @@ -78,7 +78,7 @@ static const char * const names[_LOCALE_MAX] = {
>          [LOCALE_LC_IDENTIFICATION] = "LC_IDENTIFICATION"
>  };
>  
> -typedef struct Context {
> +typedef struct LocaledContext {
>          char *locale[_LOCALE_MAX];
>  
>          char *x11_layout;
> @@ -90,7 +90,7 @@ typedef struct Context {
>          char *vc_keymap_toggle;
>  
>          Hashmap *polkit_registry;
> -} Context;
> +} LocaledContext;
>  
>  static int free_and_copy(char **s, const char *v) {
>          int r;
> @@ -113,34 +113,34 @@ static void free_and_replace(char **s, char *v) {
>          *s = v;
>  }
>  
> -static void context_free_x11(Context *c) {
> +static void localed_context_free_x11(LocaledContext *c) {
>          free_and_replace(&c->x11_layout, NULL);
>          free_and_replace(&c->x11_model, NULL);
>          free_and_replace(&c->x11_variant, NULL);
>          free_and_replace(&c->x11_options, NULL);
>  }
>  
> -static void context_free_vconsole(Context *c) {
> +static void localed_context_free_vconsole(LocaledContext *c) {
>          free_and_replace(&c->vc_keymap, NULL);
>          free_and_replace(&c->vc_keymap_toggle, NULL);
>  }
>  
> -static void context_free_locale(Context *c) {
> +static void localed_context_free_locale(LocaledContext *c) {
>          int p;
>  
>          for (p = 0; p < _LOCALE_MAX; p++)
>                  free_and_replace(&c->locale[p], NULL);
>  }
>  
> -static void context_free(Context *c) {
> -        context_free_locale(c);
> -        context_free_x11(c);
> -        context_free_vconsole(c);
> +static void localed_context_free(LocaledContext *c) {
> +        localed_context_free_locale(c);
> +        localed_context_free_x11(c);
> +        localed_context_free_vconsole(c);
>  
>          bus_verify_polkit_async_registry_free(c->polkit_registry);
>  };
>  
> -static void locale_simplify(Context *c) {
> +static void locale_simplify(LocaledContext *c) {
>          int p;
>  
>          for (p = LOCALE_LANG+1; p < _LOCALE_MAX; p++)
> @@ -150,10 +150,10 @@ static void locale_simplify(Context *c) {
>                  }
>  }
>  
> -static int locale_read_data(Context *c) {
> +static int locale_read_data(LocaledContext *c) {
>          int r;
>  
> -        context_free_locale(c);
> +        localed_context_free_locale(c);
>  
>          r = parse_env_file("/etc/locale.conf", NEWLINE,
>                             "LANG",              &c->locale[LOCALE_LANG],
> @@ -191,10 +191,10 @@ static int locale_read_data(Context *c) {
>          return r;
>  }
>  
> -static int vconsole_read_data(Context *c) {
> +static int vconsole_read_data(LocaledContext *c) {
>          int r;
>  
> -        context_free_vconsole(c);
> +        localed_context_free_vconsole(c);
>  
>          r = parse_env_file("/etc/vconsole.conf", NEWLINE,
>                             "KEYMAP",        &c->vc_keymap,
> @@ -207,13 +207,13 @@ static int vconsole_read_data(Context *c) {
>          return 0;
>  }
>  
> -static int x11_read_data(Context *c) {
> +static int x11_read_data(LocaledContext *c) {
>          FILE *f;
>          char line[LINE_MAX];
>          bool in_section = false;
>          int r;
>  
> -        context_free_x11(c);
> +        localed_context_free_x11(c);
>  
>          f = fopen("/etc/X11/xorg.conf.d/00-keyboard.conf", "re");
>          if (!f)
> @@ -277,7 +277,7 @@ static int x11_read_data(Context *c) {
>          return 0;
>  }
>  
> -static int context_read_data(Context *c) {
> +static int localed_context_read_data(LocaledContext *c) {
>          int r, q, p;
>  
>          r = locale_read_data(c);
> @@ -287,7 +287,7 @@ static int context_read_data(Context *c) {
>          return r < 0 ? r : q < 0 ? q : p;
>  }
>  
> -static int locale_write_data(Context *c) {
> +static int locale_write_data(LocaledContext *c) {
>          int r, p;
>          char **l = NULL;
>  
> @@ -335,7 +335,7 @@ static int locale_write_data(Context *c) {
>          return r;
>  }
>  
> -static int locale_update_system_manager(Context *c, sd_bus *bus) {
> +static int locale_update_system_manager(LocaledContext *c, sd_bus *bus) {
>          _cleanup_free_ char **l_unset = NULL;
>          _cleanup_strv_free_ char **l_set = NULL;
>          _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
> @@ -392,7 +392,7 @@ static int locale_update_system_manager(Context *c, sd_bus *bus) {
>          return 0;
>  }
>  
> -static int vconsole_write_data(Context *c) {
> +static int vconsole_write_data(LocaledContext *c) {
>          int r;
>          _cleanup_strv_free_ char **l = NULL;
>  
> @@ -449,7 +449,7 @@ static int vconsole_write_data(Context *c) {
>          return r;
>  }
>  
> -static int write_data_x11(Context *c) {
> +static int write_data_x11(LocaledContext *c) {
>          _cleanup_fclose_ FILE *f = NULL;
>          _cleanup_free_ char *temp_path = NULL;
>          int r;
> @@ -568,7 +568,7 @@ static int read_next_mapping(FILE *f, unsigned *n, char ***a) {
>          }
>  }
>  
> -static int vconsole_convert_to_x11(Context *c, sd_bus *bus) {
> +static int vconsole_convert_to_x11(LocaledContext *c, sd_bus *bus) {
>          bool modified = false;
>  
>          assert(bus);
> @@ -581,7 +581,7 @@ static int vconsole_convert_to_x11(Context *c, sd_bus *bus) {
>                          !isempty(c->x11_variant) ||
>                          !isempty(c->x11_options);
>  
> -                context_free_x11(c);
> +                localed_context_free_x11(c);
>          } else {
>                  _cleanup_fclose_ FILE *f = NULL;
>                  unsigned n = 0;
> @@ -637,7 +637,7 @@ static int vconsole_convert_to_x11(Context *c, sd_bus *bus) {
>          return 0;
>  }
>  
> -static int find_converted_keymap(Context *c, char **new_keymap) {
> +static int find_converted_keymap(LocaledContext *c, char **new_keymap) {
>          const char *dir;
>          _cleanup_free_ char *n;
>  
> @@ -666,7 +666,7 @@ static int find_converted_keymap(Context *c, char **new_keymap) {
>          return 0;
>  }
>  
> -static int find_legacy_keymap(Context *c, char **new_keymap) {
> +static int find_legacy_keymap(LocaledContext *c, char **new_keymap) {
>          _cleanup_fclose_ FILE *f;
>          unsigned n = 0;
>          unsigned best_matching = 0;
> @@ -743,7 +743,7 @@ static int find_legacy_keymap(Context *c, char **new_keymap) {
>          return 0;
>  }
>  
> -static int x11_convert_to_vconsole(Context *c, sd_bus *bus) {
> +static int x11_convert_to_vconsole(LocaledContext *c, sd_bus *bus) {
>          bool modified = false;
>          int r;
>  
> @@ -755,7 +755,7 @@ static int x11_convert_to_vconsole(Context *c, sd_bus *bus) {
>                          !isempty(c->vc_keymap) ||
>                          !isempty(c->vc_keymap_toggle);
>  
> -                context_free_x11(c);
> +                localed_context_free_x11(c);
>          } else {
>                  char *new_keymap = NULL;
>  
> @@ -801,7 +801,7 @@ static int property_get_locale(
>                  void *userdata,
>                  sd_bus_error *error) {
>  
> -        Context *c = userdata;
> +        LocaledContext *c = userdata;
>          _cleanup_strv_free_ char **l = NULL;
>          int p, q;
>  
> @@ -825,7 +825,7 @@ static int property_get_locale(
>  }
>  
>  static int method_set_locale(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) {
> -        Context *c = userdata;
> +        LocaledContext *c = userdata;
>          _cleanup_strv_free_ char **l = NULL;
>          char **i;
>          int interactive;
> @@ -931,7 +931,7 @@ static int method_set_locale(sd_bus *bus, sd_bus_message *m, void *userdata, sd_
>  }
>  
>  static int method_set_vc_keyboard(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) {
> -        Context *c = userdata;
> +        LocaledContext *c = userdata;
>          const char *keymap, *keymap_toggle;
>          int convert, interactive;
>          int r;
> @@ -991,7 +991,7 @@ static int method_set_vc_keyboard(sd_bus *bus, sd_bus_message *m, void *userdata
>  }
>  
>  static int method_set_x11_keyboard(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) {
> -        Context *c = userdata;
> +        LocaledContext *c = userdata;
>          const char *layout, *model, *variant, *options;
>          int convert, interactive;
>          int r;
> @@ -1061,19 +1061,19 @@ static int method_set_x11_keyboard(sd_bus *bus, sd_bus_message *m, void *userdat
>  static const sd_bus_vtable locale_vtable[] = {
>          SD_BUS_VTABLE_START(0),
>          SD_BUS_PROPERTY("Locale", "as", property_get_locale, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
> -        SD_BUS_PROPERTY("X11Layout", "s", NULL, offsetof(Context, x11_layout), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
> -        SD_BUS_PROPERTY("X11Model", "s", NULL, offsetof(Context, x11_model), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
> -        SD_BUS_PROPERTY("X11Variant", "s", NULL, offsetof(Context, x11_variant), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
> -        SD_BUS_PROPERTY("X11Options", "s", NULL, offsetof(Context, x11_options), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
> -        SD_BUS_PROPERTY("VConsoleKeymap", "s", NULL, offsetof(Context, vc_keymap), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
> -        SD_BUS_PROPERTY("VConsoleKeymapToggle", "s", NULL, offsetof(Context, vc_keymap_toggle), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
> +        SD_BUS_PROPERTY("X11Layout", "s", NULL, offsetof(LocaledContext, x11_layout), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
> +        SD_BUS_PROPERTY("X11Model", "s", NULL, offsetof(LocaledContext, x11_model), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
> +        SD_BUS_PROPERTY("X11Variant", "s", NULL, offsetof(LocaledContext, x11_variant), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
> +        SD_BUS_PROPERTY("X11Options", "s", NULL, offsetof(LocaledContext, x11_options), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
> +        SD_BUS_PROPERTY("VConsoleKeymap", "s", NULL, offsetof(LocaledContext, vc_keymap), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
> +        SD_BUS_PROPERTY("VConsoleKeymapToggle", "s", NULL, offsetof(LocaledContext, vc_keymap_toggle), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
>          SD_BUS_METHOD("SetLocale", "asb", NULL, method_set_locale, SD_BUS_VTABLE_UNPRIVILEGED),
>          SD_BUS_METHOD("SetVConsoleKeyboard", "ssbb", NULL, method_set_vc_keyboard, SD_BUS_VTABLE_UNPRIVILEGED),
>          SD_BUS_METHOD("SetX11Keyboard", "ssssbb", NULL, method_set_x11_keyboard, SD_BUS_VTABLE_UNPRIVILEGED),
>          SD_BUS_VTABLE_END
>  };
>  
> -static int connect_bus(Context *c, sd_event *event, sd_bus **_bus) {
> +static int connect_bus(LocaledContext *c, sd_event *event, sd_bus **_bus) {
>          _cleanup_bus_close_unref_ sd_bus *bus = NULL;
>          int r;
>  
> @@ -1112,7 +1112,7 @@ static int connect_bus(Context *c, sd_event *event, sd_bus **_bus) {
>  }
>  
>  int main(int argc, char *argv[]) {
> -        Context context = {};
> +        LocaledContext localed_context = {};
>          _cleanup_event_unref_ sd_event *event = NULL;
>          _cleanup_bus_close_unref_ sd_bus *bus = NULL;
>          int r;
> @@ -1138,11 +1138,11 @@ int main(int argc, char *argv[]) {
>  
>          sd_event_set_watchdog(event, true);
>  
> -        r = connect_bus(&context, event, &bus);
> +        r = connect_bus(&localed_context, event, &bus);
>          if (r < 0)
>                  goto finish;
>  
> -        r = context_read_data(&context);
> +        r = localed_context_read_data(&localed_context);
>          if (r < 0) {
>                  log_error("Failed to read locale data: %s", strerror(-r));
>                  goto finish;
> @@ -1155,7 +1155,7 @@ int main(int argc, char *argv[]) {
>          }
>  
>  finish:
> -        context_free(&context);
> +        localed_context_free(&localed_context);
>  
>          return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
>  }
> diff --git a/src/socket-proxy/socket-proxyd.c b/src/socket-proxy/socket-proxyd.c
> index f6e6672..89d5d58 100644
> --- a/src/socket-proxy/socket-proxyd.c
> +++ b/src/socket-proxy/socket-proxyd.c
> @@ -47,16 +47,16 @@
>  
>  static const char *arg_remote_host = NULL;
>  
> -typedef struct Context {
> +typedef struct ProxyContext {
>          sd_event *event;
>          sd_resolve *resolve;
>  
>          Set *listen;
>          Set *connections;
> -} Context;
> +} ProxyContext;
>  
>  typedef struct Connection {
> -        Context *context;
> +        ProxyContext *context;
>  
>          int server_fd, client_fd;
>          int server_to_client_buffer[2]; /* a pipe */
> @@ -90,7 +90,7 @@ static void connection_free(Connection *c) {
>          free(c);
>  }
>  
> -static void context_free(Context *context) {
> +static void proxy_context_free(ProxyContext *context) {
>          sd_event_source *es;
>          Connection *c;
>  
> @@ -460,7 +460,7 @@ fail:
>          return 0; /* ignore errors, continue serving */
>  }
>  
> -static int add_connection_socket(Context *context, int fd) {
> +static int add_connection_socket(ProxyContext *context, int fd) {
>          Connection *c;
>          int r;
>  
> @@ -503,7 +503,7 @@ static int add_connection_socket(Context *context, int fd) {
>  
>  static int accept_cb(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
>          _cleanup_free_ char *peer = NULL;
> -        Context *context = userdata;
> +        ProxyContext *context = userdata;
>          int nfd = -1, r;
>  
>          assert(s);
> @@ -536,7 +536,7 @@ static int accept_cb(sd_event_source *s, int fd, uint32_t revents, void *userdat
>          return 1;
>  }
>  
> -static int add_listen_socket(Context *context, int fd) {
> +static int add_listen_socket(ProxyContext *context, int fd) {
>          sd_event_source *source;
>          int r;
>  
> @@ -651,7 +651,7 @@ static int parse_argv(int argc, char *argv[]) {
>  }
>  
>  int main(int argc, char *argv[]) {
> -        Context context = {};
> +        ProxyContext context = {};
>          int r, n, fd;
>  
>          log_parse_environment();
> @@ -705,7 +705,7 @@ int main(int argc, char *argv[]) {
>          }
>  
>  finish:
> -        context_free(&context);
> +        proxy_context_free(&context);
>  
>          return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
>  }
> diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c
> index fa3f947..e96e4c3 100644
> --- a/src/timedate/timedated.c
> +++ b/src/timedate/timedated.c
> @@ -44,22 +44,22 @@
>  #define NULL_ADJTIME_UTC "0.0 0 0\n0\nUTC\n"
>  #define NULL_ADJTIME_LOCAL "0.0 0 0\n0\nLOCAL\n"
>  
> -typedef struct Context {
> +typedef struct TimedatedContext {
>          char *zone;
>          bool local_rtc;
>          bool can_ntp;
>          bool use_ntp;
>          Hashmap *polkit_registry;
> -} Context;
> +} TimedatedContext;
>  
> -static void context_free(Context *c) {
> +static void timedated_context_free(TimedatedContext *c) {
>          assert(c);
>  
>          free(c->zone);
>          bus_verify_polkit_async_registry_free(c->polkit_registry);
>  }
>  
> -static int context_read_data(Context *c) {
> +static int timedated_context_read_data(TimedatedContext *c) {
>          _cleanup_free_ char *t = NULL;
>          int r;
>  
> @@ -100,7 +100,7 @@ have_timezone:
>          return 0;
>  }
>  
> -static int context_write_data_timezone(Context *c) {
> +static int timedated_context_write_data_timezone(TimedatedContext *c) {
>          _cleanup_free_ char *p = NULL;
>          int r = 0;
>  
> @@ -124,7 +124,7 @@ static int context_write_data_timezone(Context *c) {
>          return 0;
>  }
>  
> -static int context_write_data_local_rtc(Context *c) {
> +static int timedated_context_write_data_local_rtc(TimedatedContext *c) {
>          int r;
>          _cleanup_free_ char *s = NULL, *w = NULL;
>  
> @@ -180,7 +180,7 @@ static int context_write_data_local_rtc(Context *c) {
>          return write_string_file_atomic_label("/etc/adjtime", w);
>  }
>  
> -static int context_read_ntp(Context *c, sd_bus *bus) {
> +static int timedated_context_read_ntp(TimedatedContext *c, sd_bus *bus) {
>          _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
>          sd_bus_message *reply = NULL;
>          const char *s;
> @@ -219,7 +219,7 @@ static int context_read_ntp(Context *c, sd_bus *bus) {
>          return 0;
>  }
>  
> -static int context_start_ntp(Context *c, sd_bus *bus, sd_bus_error *error) {
> +static int timedated_context_start_ntp(TimedatedContext *c, sd_bus *bus, sd_bus_error *error) {
>          int r;
>  
>          assert(c);
> @@ -265,7 +265,7 @@ static int context_start_ntp(Context *c, sd_bus *bus, sd_bus_error *error) {
>          return 0;
>  }
>  
> -static int context_enable_ntp(Context*c, sd_bus *bus, sd_bus_error *error) {
> +static int timedated_context_enable_ntp(TimedatedContext*c, sd_bus *bus, sd_bus_error *error) {
>          int r;
>  
>          assert(c);
> @@ -375,7 +375,7 @@ static int property_get_ntp_sync(
>  }
>  
>  static int method_set_timezone(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) {
> -        Context *c = userdata;
> +        TimedatedContext *c = userdata;
>          const char *z;
>          int interactive;
>          char *t;
> @@ -409,7 +409,7 @@ static int method_set_timezone(sd_bus *bus, sd_bus_message *m, void *userdata, s
>          c->zone = t;
>  
>          /* 1. Write new configuration file */
> -        r = context_write_data_timezone(c);
> +        r = timedated_context_write_data_timezone(c);
>          if (r < 0) {
>                  log_error("Failed to set time zone: %s", strerror(-r));
>                  return sd_bus_error_set_errnof(error, r, "Failed to set time zone: %s", strerror(-r));
> @@ -441,7 +441,7 @@ static int method_set_timezone(sd_bus *bus, sd_bus_message *m, void *userdata, s
>  
>  static int method_set_local_rtc(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) {
>          int lrtc, fix_system, interactive;
> -        Context *c = userdata;
> +        TimedatedContext *c = userdata;
>          struct timespec ts;
>          int r;
>  
> @@ -465,7 +465,7 @@ static int method_set_local_rtc(sd_bus *bus, sd_bus_message *m, void *userdata,
>          c->local_rtc = lrtc;
>  
>          /* 1. Write new configuration file */
> -        r = context_write_data_local_rtc(c);
> +        r = timedated_context_write_data_local_rtc(c);
>          if (r < 0) {
>                  log_error("Failed to set RTC to local/UTC: %s", strerror(-r));
>                  return sd_bus_error_set_errnof(error, r, "Failed to set RTC to local/UTC: %s", strerror(-r));
> @@ -524,7 +524,7 @@ static int method_set_local_rtc(sd_bus *bus, sd_bus_message *m, void *userdata,
>  
>  static int method_set_time(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) {
>          int relative, interactive;
> -        Context *c = userdata;
> +        TimedatedContext *c = userdata;
>          int64_t utc;
>          struct timespec ts;
>          struct tm* tm;
> @@ -591,7 +591,7 @@ static int method_set_time(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bu
>  
>  static int method_set_ntp(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) {
>          int ntp, interactive;
> -        Context *c = userdata;
> +        TimedatedContext *c = userdata;
>          int r;
>  
>          r = sd_bus_message_read(m, "bb", &ntp, &interactive);
> @@ -609,11 +609,11 @@ static int method_set_ntp(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus
>  
>          c->use_ntp = ntp;
>  
> -        r = context_enable_ntp(c, bus, error);
> +        r = timedated_context_enable_ntp(c, bus, error);
>          if (r < 0)
>                  return r;
>  
> -        r = context_start_ntp(c, bus, error);
> +        r = timedated_context_start_ntp(c, bus, error);
>          if (r < 0)
>                  return r;
>  
> @@ -626,10 +626,10 @@ static int method_set_ntp(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus
>  
>  static const sd_bus_vtable timedate_vtable[] = {
>          SD_BUS_VTABLE_START(0),
> -        SD_BUS_PROPERTY("Timezone", "s", NULL, offsetof(Context, zone), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
> -        SD_BUS_PROPERTY("LocalRTC", "b", bus_property_get_bool, offsetof(Context, local_rtc), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
> -        SD_BUS_PROPERTY("CanNTP", "b", bus_property_get_bool, offsetof(Context, can_ntp), 0),
> -        SD_BUS_PROPERTY("NTP", "b", bus_property_get_bool, offsetof(Context, use_ntp), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
> +        SD_BUS_PROPERTY("Timezone", "s", NULL, offsetof(TimedatedContext, zone), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
> +        SD_BUS_PROPERTY("LocalRTC", "b", bus_property_get_bool, offsetof(TimedatedContext, local_rtc), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
> +        SD_BUS_PROPERTY("CanNTP", "b", bus_property_get_bool, offsetof(TimedatedContext, can_ntp), 0),
> +        SD_BUS_PROPERTY("NTP", "b", bus_property_get_bool, offsetof(TimedatedContext, use_ntp), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
>          SD_BUS_PROPERTY("NTPSynchronized", "b", property_get_ntp_sync, 0, 0),
>          SD_BUS_PROPERTY("TimeUSec", "t", property_get_time, 0, 0),
>          SD_BUS_PROPERTY("RTCTimeUSec", "t", property_get_rtc_time, 0, 0),
> @@ -640,7 +640,7 @@ static const sd_bus_vtable timedate_vtable[] = {
>          SD_BUS_VTABLE_END,
>  };
>  
> -static int connect_bus(Context *c, sd_event *event, sd_bus **_bus) {
> +static int connect_bus(TimedatedContext *c, sd_event *event, sd_bus **_bus) {
>          _cleanup_bus_close_unref_ sd_bus *bus = NULL;
>          int r;
>  
> @@ -679,7 +679,7 @@ static int connect_bus(Context *c, sd_event *event, sd_bus **_bus) {
>  }
>  
>  int main(int argc, char *argv[]) {
> -        Context context = {};
> +        TimedatedContext timedated_context = {};
>          _cleanup_event_unref_ sd_event *event = NULL;
>          _cleanup_bus_close_unref_ sd_bus *bus = NULL;
>          int r;
> @@ -704,17 +704,17 @@ int main(int argc, char *argv[]) {
>  
>          sd_event_set_watchdog(event, true);
>  
> -        r = connect_bus(&context, event, &bus);
> +        r = connect_bus(&timedated_context, event, &bus);
>          if (r < 0)
>                  goto finish;
>  
> -        r = context_read_data(&context);
> +        r = timedated_context_read_data(&timedated_context);
>          if (r < 0) {
>                  log_error("Failed to read time zone data: %s", strerror(-r));
>                  goto finish;
>          }
>  
> -        r = context_read_ntp(&context, bus);
> +        r = timedated_context_read_ntp(&timedated_context, bus);
>          if (r < 0) {
>                  log_error("Failed to determine whether NTP is enabled: %s", strerror(-r));
>                  goto finish;
> @@ -727,7 +727,7 @@ int main(int argc, char *argv[]) {
>          }
>  
>  finish:
> -        context_free(&context);
> +        timedated_context_free(&timedated_context);
>  
>          return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
>  }


Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list