You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/11/22 20:18:45 UTC

[GitHub] andrzej-kaczmarek closed pull request #1530: hw/drivers/lp5523: Fixes for set_n_regs

andrzej-kaczmarek closed pull request #1530: hw/drivers/lp5523: Fixes for set_n_regs
URL: https://github.com/apache/mynewt-core/pull/1530
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/hw/drivers/led/lp5523/src/lp5523.c b/hw/drivers/led/lp5523/src/lp5523.c
index 894a5fc057..8ef7907fb0 100644
--- a/hw/drivers/led/lp5523/src/lp5523.c
+++ b/hw/drivers/led/lp5523/src/lp5523.c
@@ -129,17 +129,20 @@ lp5523_set_n_regs(struct led_itf *itf, enum lp5523_registers addr,
     uint8_t *vals, uint8_t len)
 {
     int rc;
-    uint8_t regs[LP5523_MAX_PAYLOAD] = {0};
+    uint8_t payload[LP5523_MAX_PAYLOAD] = {0};
 
     struct hal_i2c_master_data data_struct = {
         .address = itf->li_addr,
         .len = len + 1,
-        .buffer = regs
+        .buffer = payload,
     };
 
-    memcpy(regs, vals, len + 1);
+    if (len >= LP5523_MAX_PAYLOAD) {
+        return -1;
+    }
 
-    regs[0] = addr;
+    payload[0] = addr;
+    memcpy(&payload[1], vals, len);
 
     rc = led_itf_lock(itf, MYNEWT_VAL(LP5523_ITF_LOCK_TMO));
     if (rc) {
@@ -151,7 +154,7 @@ lp5523_set_n_regs(struct led_itf *itf, enum lp5523_registers addr,
 
     if (rc) {
         LP5523_LOG(ERROR, "Failed to write to 0x%02X:0x%02X\n", itf->li_addr,
-                   regs[0]);
+                   addr);
         STATS_INC(g_lp5523stats, read_errors);
     }
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services