u-blox / ubxlib

Portable C libraries which provide APIs to build applications with u-blox products and services. Delivered as add-on to existing microcontroller and RTOS SDKs.
Apache License 2.0
303 stars 92 forks source link

Fix for uGnssPosGetStreamedStart: Return zero on success #153

Closed alonbl closed 11 months ago

alonbl commented 11 months ago

per documentation zero should be returned when success while nested uGnssMsgPrivateReceiveStart returns a handle.

 * @return               zero on success or negative error code on
 *                       failure.
alonbl commented 11 months ago

Hi @RobMeades,

I think this library should be rewritten from scratch with the cleanup pattern.

    if (whatever_fail) {
       goto cleanup;
    }

cleanup:

    if (x != NULL) {
        release;
    }

the nesting and resource management in each branch hides so many bugs... it already took me two days to trace these into the library... two days of mine == ~100 units of ublox... :)

RobMeades commented 11 months ago

two days of mine == ~100 units of ublox... :)

Surely you're not that cheap ;-). Or are we reassuringly expensive? Anyway, you make a good point, especially when the functions get rather out of hand as that one does.

Thanks again, will test and merge.