ngscopeclient / scopehal

Test and measurement hardware abstraction library and protocol decodes. This is the library only. Most users should use scopehal-apps.
BSD 3-Clause "New" or "Revised" License
216 stars 97 forks source link

Change sample rate and depth conversions to use unsigned long longs #655

Closed TiltMeSenpai closed 2 years ago

TiltMeSenpai commented 2 years ago

For some godforsaken reason, Windows insists that longs should be 32 bits wide, and Linux (I think) thinks they should be 64 bits wide. I'm currently running the picoscope SCPI bridge in a WSL instance, and glscopeclient on the Windows side. This is introducing crashes, as the picoscope bridge is happy to serialize a long > 32 bits max, but glscopeclient freaks out and crashes since this is above it's perceived max long value. Changing the SCPI parsing functions to use stoull should fix this, since all systems look like they agree that unsigned long long's are 64 bits wide.

azonenberg commented 2 years ago

Please use uint64_t rather than unsigned long long (even if they're the same underlying type) to make "this is explicitly 64 bits" more obvious in the code.

Otherwise, good catch. I actually got some static analysis warnings about this recently and fixed some (but clearly not all) instances of similar behavior.

TiltMeSenpai commented 2 years ago

Are there "parse as unsigned 64 bit int" functions similar to stoull? I could have worded this clearer, but this is just a stol -> stoull swap.

azonenberg commented 2 years ago

Ah, OK. Not to my knowledge, this is probably good. Let me have a look.

TiltMeSenpai commented 2 years ago

Actually it's probably worth refactoring out the auto's and making uint64_t returns for stoull explicit, lemme do that