Module: xenomai-abe
Branch: analogy
Commit: e5135e55fdc9ceab6831bfce4b0d81a9fb513e2b
URL:    
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=e5135e55fdc9ceab6831bfce4b0d81a9fb513e2b

Author: Alexis Berlemont <alexis.berlem...@gmail.com>
Date:   Sun Nov  8 02:10:20 2009 +0100

analogy: fix a bug in the attach procedure

The options to be sent to the driver at attach time were badly handled
if the values were hexadecimal-based.

---

 src/utils/analogy/analogy_config.c |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/utils/analogy/analogy_config.c 
b/src/utils/analogy/analogy_config.c
index 316dcd4..1482322 100644
--- a/src/utils/analogy/analogy_config.c
+++ b/src/utils/analogy/analogy_config.c
@@ -50,7 +50,7 @@ struct option a4l_conf_opts[] = {
        {0},
 };
 
-int compute_opts(char *opts, unsigned int *nb, unsigned int *res)
+int compute_opts(char *opts, unsigned int *nb, unsigned long *res)
 {
 
        int ret = 0, len, ofs;
@@ -60,19 +60,26 @@ int compute_opts(char *opts, unsigned int *nb, unsigned int 
*res)
                return -EINVAL;
        *nb = 0;
 
+       /* We set errno to 0 so as to be sure that 
+          strtoul did not fail */
+       errno = 0;
+
        do {
                (*nb)++;
                len = strlen(opts);
                ofs = strcspn(opts, __OPTS_DELIMITER);
-               if (res != NULL && sscanf(opts, "%u", &res[(*nb) - 1]) == 0) {
-                       ret = -EINVAL;
-                       goto out_compute_opts;
+               if (res != NULL) {
+                       res[(*nb) - 1] = strtoul(opts, NULL, 0);
+                       if (errno != 0) {
+                               ret = -errno;
+                               goto out_compute_opts;
+                       }                               
                }
                opts += ofs + 1;
        } while (len != ofs);
 
 out_compute_opts:
-       (*nb) *= sizeof(unsigned int);
+       (*nb) *= sizeof(unsigned long);
        return ret;
 }
 
@@ -85,7 +92,8 @@ void do_print_version(void)
 void do_print_usage(void)
 {
        fprintf(stdout,
-               "usage:\tanalogy_config [OPTS] <device file> <driver>\n");
+               "usage:\tanalogy_config [OPTS] devfile driver "
+               "<driver options, ex: 0x378,7>\n");
        fprintf(stdout, "\tOPTS:\t -v, --verbose: verbose output\n");
        fprintf(stdout, "\t\t -q, --quiet: quiet output\n");
        fprintf(stdout, "\t\t -V, --version: print program version\n");


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

Reply via email to