]> git.sur5r.net Git - openocd/commitdiff
cortex_m: Check return value from cortex_m_dcc_read.
authorAndreas Fritiofson <andreas.fritiofson@gmail.com>
Tue, 2 Sep 2014 19:51:51 +0000 (21:51 +0200)
committerSpencer Oliver <spen@spen-soft.co.uk>
Mon, 15 Sep 2014 08:22:56 +0000 (08:22 +0000)
Caught by clang.

Change-Id: I26d2b845aca431612862ef432b217ca397d9b893
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/2279
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
src/target/cortex_m.c

index aafc097a011792d714bdc0731a2f5766cbd194d3..72dbe9ee6085a2c5a83a69091ba125af1282d93a 100644 (file)
@@ -1910,7 +1910,9 @@ static int cortex_m_target_request_data(struct target *target,
        uint32_t i;
 
        for (i = 0; i < (size * 4); i++) {
-               cortex_m_dcc_read(target, &data, &ctrl);
+               int retval = cortex_m_dcc_read(target, &data, &ctrl);
+               if (retval != ERROR_OK)
+                       return retval;
                buffer[i] = data;
        }
 
@@ -1929,8 +1931,11 @@ static int cortex_m_handle_target_request(void *priv)
        if (target->state == TARGET_RUNNING) {
                uint8_t data;
                uint8_t ctrl;
+               int retval;
 
-               cortex_m_dcc_read(target, &data, &ctrl);
+               retval = cortex_m_dcc_read(target, &data, &ctrl);
+               if (retval != ERROR_OK)
+                       return retval;
 
                /* check if we have data */
                if (ctrl & (1 << 0)) {
@@ -1938,12 +1943,12 @@ static int cortex_m_handle_target_request(void *priv)
 
                        /* we assume target is quick enough */
                        request = data;
-                       cortex_m_dcc_read(target, &data, &ctrl);
-                       request |= (data << 8);
-                       cortex_m_dcc_read(target, &data, &ctrl);
-                       request |= (data << 16);
-                       cortex_m_dcc_read(target, &data, &ctrl);
-                       request |= (data << 24);
+                       for (int i = 1; i <= 3; i++) {
+                               retval = cortex_m_dcc_read(target, &data, &ctrl);
+                               if (retval != ERROR_OK)
+                                       return retval;
+                               request |= ((uint32_t)data << (i * 8));
+                       }
                        target_request(target, request);
                }
        }