From e3736acebadcff363afc37788c86266b703d9153 Mon Sep 17 00:00:00 2001 From: Gordon Williams <gw@pur3.co.uk> Date: Thu, 25 Jan 2024 11:51:44 +0000 Subject: [PATCH] fix build warning, if jswrap_i2c_readReg called on an undefined parent it could return an undefined value --- src/jswrap_spi_i2c.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/jswrap_spi_i2c.c b/src/jswrap_spi_i2c.c index 1f0beed534..3f6a3387d1 100644 --- a/src/jswrap_spi_i2c.c +++ b/src/jswrap_spi_i2c.c @@ -761,10 +761,10 @@ I2C.readReg = function(address, reg, quantity) { ``` */ JsVar *jswrap_i2c_readReg(JsVar *parent, int address, int reg, int nBytes) { - if (!jsvIsObject(parent)) return; + if (!jsvIsObject(parent)) return 0; IOEventFlags device = jsiGetDeviceFromClass(parent); bool sendStop = false; unsigned char i2cReg = (unsigned char)reg; _jswrap_i2c_writeTo(parent, device, address, sendStop, 1, &i2cReg); return _jswrap_i2c_readFrom(parent, device, address, sendStop, nBytes); -} \ No newline at end of file +}