Allow ATHandler::read_int to return 0 successfully #11248
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Currently,
ATHandler::read_int
is documented to return a positive integer on success, -1 on error. In cases wherestd::strtol
fails to parse a value, 0 is returned - and it is impossible to determine whether that 0 means "parsing failed" or "parsed 0 successfully".Most places in
mbed-os
that actually do error checking depend on 0 meaning success, e.g.:mbed-os/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularStack.cpp
Line 114 in 818c1d6
mbed-os/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularContext.cpp
Line 137 in 818c1d6
mbed-os/features/cellular/framework/targets/UBLOX/N2XX/UBLOX_N2XX_CellularStack.cpp
Line 96 in 60d047c
mbed-os/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.cpp
Line 361 in 8767ab4
This pull request updates
ATHandler::read_int
so that it only returns 0 on success, and updates the method comment appropriately.Pull request type