i have to admit, this is not a bug, just a pedantic micro-optimization

the code is executed only once per analog segment
for example once every 10K samples

in libsigrok/src/analog.c in the function
SR_API int sr_analog_to_float(const struct sr_datafeed_analog *analog,
float *outbuf)

around like 290 there is
```
        if (analog->encoding->unitsize == sizeof(float)
                        && analog->encoding->is_bigendian == bigendian
                        && analog->encoding->scale.p == 1
                        && analog->encoding->scale.q == 1
                        && analog->encoding->offset.p /
(float)analog->encoding->offset.q == 0) {
```

which can be reduced to
```
        if (analog->encoding->unitsize == sizeof(float)
                        && analog->encoding->is_bigendian == bigendian
                        && analog->encoding->scale.p ==
analog->encoding->scale.q
                        && analog->encoding->offset.p == 0) {
```

offset.p is of type int



2020-08-20 20:22 GMT+02:00, Gerhard Sittig <gerhard.sit...@gmx.net>:
> On Sun, 2020-08-02 at 19:44 +0200, milan hauth wrote:
>>
>> here is a micro bug in libsigrok/src/analog.c
>>
>> --
>>
>> analog->encoding->offset.p / (float)analog->encoding->offset.q == 0
>>
>> is the same as
>>
>> analog->encoding->offset.p == 0
>>
>> cos q is an integer and can never be infinity
>>
>> --
>>
>> and
>>
>> analog->encoding->scale.p == 1
>> && analog->encoding->scale.q == 1
>>
>> should be
>>
>> analog->encoding->scale.p == analog->encoding->scale.q
>
> Would have been nice if you could provide more context. Not sure
> if I have looked at the spots that you meant to refer to in that
> file. The mail content was not "the patch" which the subject has
> promised.
>
> Why do you consider these instances "a bug" (regardless how
> micro)? Sure you can consider them an inefficiency if you will.
> But is the operation of the code in question flawed, or was the
> implementation just unexpected to you? Got more information?
>
>
> virtually yours
> Gerhard Sittig
> --
>      If you don't understand or are scared by any of the above
>              ask your parents or an adult to help you.
>
>
> _______________________________________________
> sigrok-devel mailing list
> sigrok-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sigrok-devel
>


_______________________________________________
sigrok-devel mailing list
sigrok-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sigrok-devel

Reply via email to