On Fri, Oct 08, 2021 at 05:49:24PM +0200, Jacopo Mondi wrote: > > 166 msg[1].buf = buf; > > 167 > > 168 /* > > 169 * If return value of this function is < 0, it means error, else, > > 170 * below 16bit is valid data. > > 171 */ > > 172 ret = i2c_transfer(client->adapter, msg, 2); > > 173 if (ret < 0) > > 174 return ret; > > 175 > > --> 176 memcpy(&ret, buf, 2); > > ^^^^ > > And this is ugly as all heck. I would have fixed it but there were > > so many other endian bugs and I can't test it. > > Is this an endianess issue or just a complaint about the difference in > size between the number of copied bytes and the destination ? On big endian systems this would translate the value from buf into a very large value but on little endian systems it should work okay. (I think). But all the swap16 stuff are endian bugs as well. regards, dan carpenter > > Thanks > j > > > > > 177 > > 178 return swab16(ret); > > 179 } > > > > regards, > > dan carpenter