[PATCH 3/7] xfree86: Convert xf86InputDevs to nt_list_ macros.

Michal Suchanek hramrach at gmail.com
Tue Jul 17 07:41:21 PDT 2012


Signed-off-by: Michal Suchanek <hramrach at gmail.com>
---
 hw/xfree86/common/xf86Helper.c |    2 +-
 hw/xfree86/common/xf86Xinput.c |   23 ++++++-----------------
 2 files changed, 7 insertions(+), 18 deletions(-)

diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index f681a85..90484bb 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -153,7 +153,7 @@ xf86LookupInput(const char *name)
 {
     InputInfoPtr p;
 
-    for (p = xf86InputDevs; p != NULL; p = p->next) {
+    nt_list_for_each_entry(p, xf86InputDevs, next) {
         if (strcmp(name, p->name) == 0)
             return p;
     }
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index bee407b..7b368fe 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -725,15 +725,14 @@ xf86AllocateInput(void)
 static void
 xf86AddInput(InputDriverPtr drv, InputInfoPtr pInfo)
 {
-    InputInfoPtr *prev = NULL;
-
     pInfo->drv = drv;
     pInfo->module = DuplicateModule(drv->module, NULL);
 
-    for (prev = &xf86InputDevs; *prev; prev = &(*prev)->next);
-
-    *prev = pInfo;
-    pInfo->next = NULL;
+    /* the append macro is kind of useless */
+    if (xf86InputDevs)
+        nt_list_append(pInfo, xf86InputDevs, InputInfoRec, next);
+    else
+        xf86InputDevs = pInfo;
 
     xf86CollectInputOptions(pInfo, (const char **) drv->default_options);
     xf86OptionListReport(pInfo->options);
@@ -761,17 +760,7 @@ xf86DeleteInput(InputInfoPtr pInp, int flags)
     FreeInputAttributes(pInp->attrs);
 
     /* Remove the entry from the list. */
-    if (pInp == xf86InputDevs)
-        xf86InputDevs = pInp->next;
-    else {
-        InputInfoPtr p = xf86InputDevs;
-
-        while (p && p->next != pInp)
-            p = p->next;
-        if (p)
-            p->next = pInp->next;
-        /* Else the entry wasn't in the xf86InputDevs list (ignore this). */
-    }
+    nt_list_del(pInp, xf86InputDevs, InputInfoRec, next);
 
     free(pInp->driver);
     free(pInp->name);
-- 
1.7.10.4



More information about the xorg-devel mailing list