summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@profusion.mobi>2012-04-26 13:36:02 -0300
committerKay Sievers <kay@vrfy.org>2012-04-29 19:15:08 +0200
commitb27ee00bf5e377a4b59b454c68c8617ea9666bc8 (patch)
treec4305be00b117607bdc0561d2a97dadc204107bb
parentc4326aa4af424ada8ab9e6fe77035db1cf222ffa (diff)
udev: use container_of() macro
-rw-r--r--src/libudev/libudev-list.c8
-rw-r--r--src/udev/collect/collect.c8
-rw-r--r--src/udev/udevd.c16
3 files changed, 8 insertions, 24 deletions
diff --git a/src/libudev/libudev-list.c b/src/libudev/libudev-list.c
index 1fe46f3f28..aec334bcfc 100644
--- a/src/libudev/libudev-list.c
+++ b/src/libudev/libudev-list.c
@@ -80,13 +80,9 @@ void udev_list_node_remove(struct udev_list_node *entry)
}
/* return list entry which embeds this node */
-static struct udev_list_entry *list_node_to_entry(struct udev_list_node *node)
+static inline struct udev_list_entry *list_node_to_entry(struct udev_list_node *node)
{
- char *list;
-
- list = (char *)node;
- list -= offsetof(struct udev_list_entry, node);
- return (struct udev_list_entry *)list;
+ return container_of(node, struct udev_list_entry, node);
}
void udev_list_init(struct udev *udev, struct udev_list *list, bool unique)
diff --git a/src/udev/collect/collect.c b/src/udev/collect/collect.c
index 882564a5f5..777542979a 100644
--- a/src/udev/collect/collect.c
+++ b/src/udev/collect/collect.c
@@ -55,13 +55,9 @@ static int debug;
/* This can increase dynamically */
static size_t bufsize = BUFSIZE;
-static struct _mate *node_to_mate(struct udev_list_node *node)
+static inline struct _mate *node_to_mate(struct udev_list_node *node)
{
- char *mate;
-
- mate = (char *)node;
- mate -= offsetof(struct _mate, node);
- return (struct _mate *)mate;
+ return container_of(node, struct _mate, node);
}
static void sig_alrm(int signo)
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 59e2cfac6b..0d85960e63 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -99,13 +99,9 @@ struct event {
int ifindex;
};
-static struct event *node_to_event(struct udev_list_node *node)
+static inline struct event *node_to_event(struct udev_list_node *node)
{
- char *event;
-
- event = (char *)node;
- event -= offsetof(struct event, node);
- return (struct event *)event;
+ return container_of(node, struct event, node);
}
static void event_queue_cleanup(struct udev *udev, enum event_state type);
@@ -134,13 +130,9 @@ struct worker_message {
int exitcode;
};
-static struct worker *node_to_worker(struct udev_list_node *node)
+static inline struct worker *node_to_worker(struct udev_list_node *node)
{
- char *worker;
-
- worker = (char *)node;
- worker -= offsetof(struct worker, node);
- return (struct worker *)worker;
+ return container_of(node, struct worker, node);
}
static void event_queue_delete(struct event *event, bool export)