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

Author: Alexis Berlemont <alexis.berlem...@gmail.com>
Date:   Mon Sep 20 11:36:34 2010 +0200

analogy: fix compilation warnings with gcc-4.4.1

---

 src/drvlib/analogy/sync.c     |   44 ++++++++++++++++++++++++++--------------
 src/utils/analogy/insn_bits.c |    9 ++++++-
 2 files changed, 35 insertions(+), 18 deletions(-)

diff --git a/src/drvlib/analogy/sync.c b/src/drvlib/analogy/sync.c
index 4bcde62..d7c8ba9 100644
--- a/src/drvlib/analogy/sync.c
+++ b/src/drvlib/analogy/sync.c
@@ -296,21 +296,27 @@ int a4l_sync_dio(a4l_desc_t *dsc,
        size = a4l_sizeof_subd(subd);
 
        switch(size) {
-       case 4:
-               ((uint32_t *)values)[0] = *((uint32_t *)mask);
-               ((uint32_t *)values)[1] = *((uint32_t *)buf);
+       case sizeof(uint32_t): {
+               uint32_t *tmp = (uint32_t *)values;
+               tmp[0] = *((uint32_t *)mask);
+               tmp[1] = *((uint32_t *)buf);
                insn.data_size = 2 * sizeof(uint32_t);
                break;
-       case 2: 
-               ((uint16_t *)values)[0] = *((uint16_t *)mask);
-               ((uint16_t *)values)[1] = *((uint16_t *)buf);
+       }
+       case sizeof(uint16_t): {
+               uint16_t *tmp = (uint16_t *)values;
+               tmp[0] = *((uint16_t *)mask);
+               tmp[1] = *((uint16_t *)buf);
                insn.data_size = 2 * sizeof(uint16_t);
                break;
-       case 1: 
-               ((uint8_t *)values)[0] = *((uint8_t *)mask);
-               ((uint8_t *)values)[1] = *((uint8_t *)buf);
+       }
+       case sizeof(uint8_t): {
+               uint8_t *tmp = (uint8_t *)values;
+               tmp[0] = *((uint8_t *)mask);
+               tmp[1] = *((uint8_t *)buf);
                insn.data_size = 2 * sizeof(uint8_t);
                break;
+       }
        default:
                return -EINVAL;
        }
@@ -320,16 +326,22 @@ int a4l_sync_dio(a4l_desc_t *dsc,
 
        /* Update the buffer if need be */
        switch(size) {
-       case 4:
-               *((uint32_t *)buf) = ((uint32_t *)values)[1];
+       case sizeof(uint32_t): {
+               uint32_t *tmp = (uint32_t *)buf;
+               *tmp = ((uint32_t *)values)[1];
                break;
-       case 2: 
-               *((uint16_t *)buf) = ((uint16_t *)values)[1];
+       }
+       case sizeof(uint16_t): {
+               uint16_t *tmp = (uint16_t *)buf;
+               *tmp = ((uint16_t *)values)[1];
                break;
-       case 1: 
-               *((uint8_t *)buf) = ((uint8_t *)values)[1];
+       }
+       case sizeof(uint8_t): {
+               uint8_t *tmp = (uint8_t *)buf;
+               *tmp = ((uint8_t *)values)[1];
                break;
-       }       
+       }
+       }
        
        return ret;
 }
diff --git a/src/utils/analogy/insn_bits.c b/src/utils/analogy/insn_bits.c
index 192f897..eb7e43a 100644
--- a/src/utils/analogy/insn_bits.c
+++ b/src/utils/analogy/insn_bits.c
@@ -26,6 +26,7 @@
 #include <sys/mman.h>
 #include <errno.h>
 #include <getopt.h>
+#include <string.h>
 
 #include <analogy/analogy.h>
 
@@ -200,10 +201,14 @@ int main(int argc, char *argv[])
        }
 
        if (scan_size == sizeof(uint8_t)) {
-               value = *((uint8_t *)&value);
+               uint8_t tmp;
+               memcpy(&tmp, &value, sizeof(uint8_t));
+               value = (int)tmp;
        }
        else if (scan_size == sizeof(uint16_t)) {
-               value = *((uint16_t *)&value);
+               uint16_t tmp;
+               memcpy(&tmp, &value, sizeof(uint16_t));         
+               value = (int)tmp;
        }
 
        if ((sbinfo->flags & A4L_SUBD_TYPES) != A4L_SUBD_DO)


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

Reply via email to