You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2017/02/01 19:18:21 UTC

[2/3] incubator-mynewt-core git commit: nordic/i2c: Fix for compiler warning

nordic/i2c: Fix for compiler warning

This patch solves issue which is visible when building with -Og option.

hal_i2c.c:251:9: error: 'rc' may be used uninitialized in this function [-Werror=maybe-uninitialized]


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/c10dcbac
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/c10dcbac
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/c10dcbac

Branch: refs/heads/develop
Commit: c10dcbac4879ea6177d5c4dc532c5edd91b08d95
Parents: 80ed11d
Author: \u0141ukasz Rymanowski <lu...@codecoup.pl>
Authored: Wed Feb 1 15:20:31 2017 +0100
Committer: \u0141ukasz Rymanowski <lu...@codecoup.pl>
Committed: Wed Feb 1 15:50:05 2017 +0100

----------------------------------------------------------------------
 hw/mcu/nordic/nrf51xxx/src/hal_i2c.c | 4 +---
 hw/mcu/nordic/nrf52xxx/src/hal_i2c.c | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c10dcbac/hw/mcu/nordic/nrf51xxx/src/hal_i2c.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/nrf51xxx/src/hal_i2c.c b/hw/mcu/nordic/nrf51xxx/src/hal_i2c.c
index 394a325..9fa09db 100644
--- a/hw/mcu/nordic/nrf51xxx/src/hal_i2c.c
+++ b/hw/mcu/nordic/nrf51xxx/src/hal_i2c.c
@@ -250,7 +250,7 @@ hal_i2c_master_write(uint8_t i2c_num, struct hal_i2c_master_data *pdata,
 {
     struct nrf51_hal_i2c *i2c;
     NRF_TWI_Type *regs = NULL;
-    int rc;
+    int rc = -1;
     int i;
     uint32_t start;
 
@@ -273,7 +273,6 @@ hal_i2c_master_write(uint8_t i2c_num, struct hal_i2c_master_data *pdata,
         regs->TXD = pdata->buffer[i];
         while (!regs->EVENTS_TXDSENT && !regs->EVENTS_ERROR) {
             if (os_time_get() - start > timo) {
-                rc = -1;
                 regs->TASKS_STOP = 1;
                 goto err;
             }
@@ -288,7 +287,6 @@ hal_i2c_master_write(uint8_t i2c_num, struct hal_i2c_master_data *pdata,
         regs->TASKS_STOP = 1;
         while (!regs->EVENTS_STOPPED && !regs->EVENTS_ERROR) {
             if (os_time_get() - start > timo) {
-                rc = -1;
                 goto err;
             }
         }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c10dcbac/hw/mcu/nordic/nrf52xxx/src/hal_i2c.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/nrf52xxx/src/hal_i2c.c b/hw/mcu/nordic/nrf52xxx/src/hal_i2c.c
index e300a5a..7054627 100644
--- a/hw/mcu/nordic/nrf52xxx/src/hal_i2c.c
+++ b/hw/mcu/nordic/nrf52xxx/src/hal_i2c.c
@@ -248,7 +248,7 @@ hal_i2c_master_write(uint8_t i2c_num, struct hal_i2c_master_data *pdata,
 {
     struct nrf52_hal_i2c *i2c;
     NRF_TWI_Type *regs = NULL;
-    int rc;
+    int rc = -1;
     int i;
     uint32_t start;
 
@@ -271,7 +271,6 @@ hal_i2c_master_write(uint8_t i2c_num, struct hal_i2c_master_data *pdata,
         regs->TXD = pdata->buffer[i];
         while (!regs->EVENTS_TXDSENT && !regs->EVENTS_ERROR) {
             if (os_time_get() - start > timo) {
-                rc = -1;
                 regs->TASKS_STOP = 1;
                 goto err;
             }
@@ -286,7 +285,6 @@ hal_i2c_master_write(uint8_t i2c_num, struct hal_i2c_master_data *pdata,
         regs->TASKS_STOP = 1;
         while (!regs->EVENTS_STOPPED && !regs->EVENTS_ERROR) {
             if (os_time_get() - start > timo) {
-                rc = -1;
                 goto err;
             }
         }