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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be regular use, do we need to do this condition for every
const char*
for trace msg ? Is this a place to fix it, not tr_ module?@kjbracey-arm what do you think about this bugfix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's definitely needed in any situation where NULL is a valid value. So if
set_plmn(NULL)
is legal, this is a necessary change. Ifset_plmn(NULL)
is illegal, it's debatable.It's generally nice if your trace doesn't blow stuff up with illegal values, so it is handy when the C library catches it for you. (Up until the point you port to another library that isn't nice).
But I'm not generally in favour of hiding illegal conditions. If in this case
set_plmn(NULL)
is illegal, it's helped us just catch that illegal use.There's some second-order oddity here in the example that they're literally doing
"plmn": 0
in the JSON, rather than"plmn": null
, which is triggering the passing of 0 in the C code. JSONnull
would not define the macro.Trace code can't do this itself - it's not parsing the format string or handling the parameters - they just go straight to a C library
printf
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case we also needs to be careful not to break any API. Cellular-example mbed_app.json has had "null" values defined as 0 for long time, so I don't think we want to change the behaviour anymore. Right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aside from the JSON, the actual
CellularInterface
API is unclear on whetherNULL
is legal or not for the various config APIs, but I'd guess it's supposed to be, meaning "reset to none" (or default if APN database?). So I think this particular check is required.