19 wrz 2015 12:25 AM "Aurelien Jacobs" <au...@gnuage.org> napisaĆ(a): > > On Fri, Sep 18, 2015 at 08:09:53PM +0200, Uwe Hermann wrote: > > Hi, > > > > On Thu, Sep 17, 2015 at 11:59:42AM +0200, Bartosz Golaszewski wrote: > > > http://git.baylibre.com/pub/acme/libsigrok/ revB > > > > Merged, thanks! > > > > Looks good, one minor improvement you could do is use g_ntohl() instead > > of ntohl(), which also avoids the inet.h include. > > Or maybe you should not use ntohl() at all. > But more importantly, you can't map the eeprom content directly > to a struct whose size will vary depending on the target arch, and you > probably shouldn't rely on a packed struct which is not standard C (even > though it is probably supported by all sigrok relevant compilers).
Hi Aurelien, this is a very stupid bug using int and unsigned long from my side. Especially when I actually use uint32 etc. in the program creating the EEPROM contents. Tell me if I'm wrong but simply changing these to appropriate fixed-size types should be enough in this case right? Best regards, Bartosz Golaszewski > I suggest you just read the whole eeprom to a simple byte buffer and > extract the fields you want depending on their formats with something > like this: > > rd = read(fd, buf, len); > eeprom->type = RB32(buf + 0); > eeprom->rev = RB32(buf + 4); > eeprom->shunt = RB64(buf + 8); > memcpy(eeprom->serial, buf + 17, EEPROM_SERIAL_SIZE); > > This way, you stay fully standard and portable. > > Aurel
------------------------------------------------------------------------------
_______________________________________________ sigrok-devel mailing list sigrok-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sigrok-devel