sparkfun / SparkFun_Ublox_Arduino_Library

Library to control UBX binary protocol and NMEA over I2C on Ublox GPS modules
Other
144 stars 84 forks source link

Value never used #149

Closed rubienr closed 3 years ago

rubienr commented 4 years ago

Vale is never used: https://github.com/sparkfun/SparkFun_Ublox_Arduino_Library/blob/97bd455b0e7a05b92bfe5a528c28cc47f2e2d289/src/SparkFun_Ublox_Arduino_Library.cpp#L2313

Suggested fix:

  //payloadCfg is now loaded with current bytes. Get what we need
  uint16_t measurementRate {extractInt(0)}; //Pull from payloadCfg at measRate LSB

  measurementRate = 1000 / measurementRate; //This may return an int when it's a float, but I'd rather not return 4 bytes
  return (measurementRate);
}
PaulZC commented 4 years ago

Hi @rubienr , I think the original code is OK? It creates measurementRate, sets it to zero and then loads it with the 0'th byte of payloadCfg using extractInt. Please check. Best wishes, Paul

rubienr commented 4 years ago

The code is okay. Clang claims that the initialization value 0 is never used but then is overwritten in L 2316 with assignment of extractInt(0). The measurementRate initialization could go from L 2313 to L 2316 as uint16_t measurementRate {extractInt(0)}; and clang would be happy again. I don't want to be picky, but I would like to compile with -Wall -Werror :)

PaulZC commented 4 years ago

Hi @rubienr , OK. However I fear that life is really much too short to make every piece of code 100% clang-compatible! Especially retrospectively... Let me know if this commit fixes it. Best wishes, Paul