Skip to content

Cellular: Fix plmn trace for IAR #10172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 21, 2019
Merged

Cellular: Fix plmn trace for IAR #10172

merged 1 commit into from
Mar 21, 2019

Conversation

kivaisan
Copy link
Contributor

Description

IAR compiler does not seem to like printing null strings. PLMN can be null depending on user configuration.

This is fix for ARMmbed/mbed-os-example-cellular#125.

Pull request type

[X] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change

Reviewers

@AriParkkila @mirelachirica @AnttiKauppila

Release Notes

IAR compiler does not seem to like printing null strings.
@AnttiKauppila
Copy link

@0xc0170 @adbridge This is targeted to next 5.12.rcX version

@@ -259,7 +259,7 @@ nsapi_error_t AT_CellularContext::set_blocking(bool blocking)

void AT_CellularContext::set_plmn(const char *plmn)
{
tr_info("CellularContext plmn %s", plmn);
tr_info("CellularContext plmn %s", (plmn ? plmn : "NULL"));
Copy link
Contributor

@0xc0170 0xc0170 Mar 20, 2019

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?

Copy link
Contributor

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. If set_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. JSON null 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.

Copy link
Contributor Author

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?

Copy link
Contributor

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 whether NULL 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.

@0xc0170 0xc0170 requested a review from kjbracey March 20, 2019 13:01
Copy link
Contributor

@0xc0170 0xc0170 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kjbracey-arm, clear now.

@adbridge
Copy link
Contributor

ci started

@mbed-ci
Copy link

mbed-ci commented Mar 20, 2019

Test run: FAILED

Summary: 1 of 9 test jobs failed
Build number : 1
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_build-IAR8

@cmonr
Copy link
Contributor

cmonr commented Mar 20, 2019

CI restarted, since the buld failure was actually a GitHob 502 timeout

@mbed-ci
Copy link

mbed-ci commented Mar 20, 2019

Test run: SUCCESS

Summary: 13 of 13 test jobs passed
Build number : 2
Build artifacts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants