Module: xenomai-2.5
Branch: master
Commit: 13721bcc9a5d0bd64dc0826b1628cc5547a787e5
URL:    
http://git.xenomai.org/?p=xenomai-2.5.git;a=commit;h=13721bcc9a5d0bd64dc0826b1628cc5547a787e5

Author: Alexis Berlemont <alexis.berlem...@gmail.com>
Date:   Fri Jan 15 01:40:04 2010 +0100

analogy: fix a bug in the initialization of the user root descriptor

In the structure a4l_root, the field nb_leaf was left uninitialized by
the init routine.

---

 src/drvlib/analogy/descriptor.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/drvlib/analogy/descriptor.c b/src/drvlib/analogy/descriptor.c
index f841657..c5bb0bc 100644
--- a/src/drvlib/analogy/descriptor.c
+++ b/src/drvlib/analogy/descriptor.c
@@ -38,6 +38,7 @@ static void a4l_root_setup(a4l_root_t * rt,
        rt->offset = ((void *)rt + sizeof(a4l_root_t));
        rt->gsize = gsize;
        rt->id = 0xffffffff;
+       rt->nb_leaf = 0;
        rt->lfnxt = NULL;
        rt->lfchd = NULL;
 
@@ -142,8 +143,10 @@ static int __a4l_fill_desc(int fd, a4l_desc_t * dsc)
 
                /* For each subd, add a leaf for the channels even if
                   the subd does not own any channel */
-               a4l_leaf_add(rt, (a4l_leaf_t *) rt, &lfs,
+               ret = a4l_leaf_add(rt, (a4l_leaf_t *) rt, &lfs,
                             sbinfo[i].nb_chan * sizeof(a4l_chinfo_t));
+               if (ret < 0)
+                       return ret;
 
                /* If there is no channel, no need to go further */
                if(sbinfo[i].nb_chan == 0)
@@ -153,15 +156,19 @@ static int __a4l_fill_desc(int fd, a4l_desc_t * dsc)
 
                if ((ret = a4l_sys_chaninfo(fd, i, chinfo)) < 0)
                        return ret;
+
                for (j = 0; j < sbinfo[i].nb_chan; j++) {
                        a4l_leaf_t *lfc;
                        a4l_rnginfo_t *rnginfo;
 
                        /* For each channel, add a leaf for the ranges
                           even if no range descriptor is available */
-                       a4l_leaf_add(rt, lfs, &lfc,
+                       ret = a4l_leaf_add(rt, lfs, &lfc,
                                     chinfo[j].nb_rng *
                                     sizeof(a4l_rnginfo_t));
+                       if (ret < 0)
+                               return ret;
+
 
                        /* If there is no range, no need to go further */
                        if(chinfo[j].nb_rng ==0)
@@ -228,6 +235,7 @@ static int __a4l_fill_desc(int fd, a4l_desc_t * dsc)
 int a4l_sys_desc(int fd, a4l_desc_t * dsc, int pass)
 {
        int ret = 0;
+
        if (dsc == NULL ||
            (pass != A4L_BSC_DESC && dsc->magic != MAGIC_BSC_DESC))
                return -EINVAL;


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

Reply via email to