airspy / airspyone_host

AirSpy's usemode driver and associated tools
http://airspy.com
247 stars 88 forks source link

airspy_set_linearity_gain out of bound value problem #52

Closed TLeconte closed 6 years ago

TLeconte commented 6 years ago

In _airspy_set_linearitygain (and _airspy_set_sensitivitygain), if an out of bound value is given (ex : 30) the minimum gain will bet set . Man could expect to get the maximum gain in this case ..

It's because the variable value is an unsigned int and so the computation : value = GAIN_COUNT - 1 - value; will not give a negative number and the following if (value < 0) is meaningless with an uint

Plus, the maximum allowed value (_GAINCOUNT) is not in airspy.h and so application could not know it.

bvernoux commented 6 years ago

1) It is wrote in API https://github.com/airspy/airspyone_host/blob/5c86e53c484140a4a5038a24e4f40f4fb8e6240d/libairspy/src/airspy.h#L200 / Parameter value: 0..21 / extern ADDAPI int ADDCALL airspy_set_sensitivity_gain(struct airspy_device* device, uint8_t value); So any developer using this API shall not exceed 21 But the best will be to explicitly move #define GAIN_COUNT (22) to this header

2) About the if (value < 0) yes it can be removed/fixed ...

You can do a pull request to cleanup those minor issues thanks for your contribution