]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: use container_of() macro
authorLucas De Marchi <lucas.demarchi@profusion.mobi>
Thu, 26 Apr 2012 16:36:02 +0000 (13:36 -0300)
committerKay Sievers <kay@vrfy.org>
Sun, 29 Apr 2012 17:15:08 +0000 (19:15 +0200)
src/libudev/libudev-list.c
src/udev/collect/collect.c
src/udev/udevd.c

index 1fe46f3f2838368ba459144e18757542c422ec2d..aec334bcfc52875b25a622ec27b7f33a7241c2e6 100644 (file)
@@ -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)
index 882564a5f52bb58310933fb37b21c64d934ff873..777542979a174ab37f7bb696d190b4c9dbb78b98 100644 (file)
@@ -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)
index 59e2cfac6b305661407c54e40d166be4eebcd696..0d85960e63c71ce6c2191286245f071fd73d3fc5 100644 (file)
@@ -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)