Module: xenomai-head
Branch: master
Commit: 94d0d902ba39ff402ff4a7c5f13710d092781e53
URL:    
http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=94d0d902ba39ff402ff4a7c5f13710d092781e53

Author: Jan Kiszka <jan.kis...@siemens.com>
Date:   Thu Oct  7 09:07:11 2010 +0200

RTDM: Fix iterations for vfile device listings

The last lines were dumped twice as the seek-forward loops did not
account for the initial header skip.

Signed-off-by: Jan Kiszka <jan.kis...@siemens.com>

---

 ksrc/skins/rtdm/proc.c |   30 ++++++++++++++++--------------
 1 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/ksrc/skins/rtdm/proc.c b/ksrc/skins/rtdm/proc.c
index 4c91368..b88b8ce 100644
--- a/ksrc/skins/rtdm/proc.c
+++ b/ksrc/skins/rtdm/proc.c
@@ -88,24 +88,25 @@ out:
 static void *named_begin(struct xnvfile_regular_iterator *it)
 {
        struct vfile_device_data *priv = xnvfile_iterator_priv(it);
+       struct list_head *devlist;
        loff_t pos = 0;
 
        priv->devmap = rtdm_named_devices;
        priv->hmax = devname_hashtab_size;
        priv->h = 0;
 
-       priv->curr = next_devlist(priv);
-       if (priv->curr == NULL)
+       devlist = next_devlist(priv);
+       if (devlist == NULL)
                return NULL;    /* All devlists empty. */
 
+       priv->curr = devlist->next;     /* Skip head. */
+
        /*
-        * priv->curr now points to the first populated device list
-        * attached to a hash slot; advance to the requested position
-        * from there.
+        * priv->curr now points to the first device; advance to the requested
+        * position from there.
         */
-       do
+       while (priv->curr && pos++ < it->pos)
                priv->curr = next_dev(it);
-       while (priv->curr && ++pos < it->pos);
 
        if (pos == 1)
                /* Output the header once, only if some device follows. */
@@ -145,24 +146,25 @@ static void *proto_begin(struct xnvfile_regular_iterator 
*it)
 {
 
        struct vfile_device_data *priv = xnvfile_iterator_priv(it);
+       struct list_head *devlist;
        loff_t pos = 0;
 
        priv->devmap = rtdm_protocol_devices;
        priv->hmax = protocol_hashtab_size;
        priv->h = 0;
 
-       priv->curr = next_devlist(priv);
-       if (priv->curr == NULL)
+       devlist = next_devlist(priv);
+       if (devlist == NULL)
                return NULL;    /* All devlists empty. */
 
+       priv->curr = devlist->next;     /* Skip head. */
+
        /*
-        * priv->curr now points to the first populated device list
-        * attached to a hash slot; advance to the requested position
-        * from there.
+        * priv->curr now points to the first device; advance to the requested
+        * position from there.
         */
-       do
+       while (priv->curr && pos++ < it->pos)
                priv->curr = next_dev(it);
-       while (priv->curr && ++pos < it->pos);
 
        if (pos == 1)
                /* Output the header once, only if some device follows. */


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to