Skip to content

Remove floating point from AT_CellularSMS #11396

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 2 commits into from
Sep 5, 2019
Merged

Remove floating point from AT_CellularSMS #11396

merged 2 commits into from
Sep 5, 2019

Conversation

gpsimenos
Copy link
Contributor

@gpsimenos gpsimenos commented Sep 2, 2019

Description

Replace unneccesary floating point operations in AT_CellularSMS with integers.

This is part of the requirements in IOTCLOUDPR-3289.

Pull request type

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

Reviewers

@evedon @hugueskamba @AnttiKauppila

Copy link
Collaborator

@hugueskamba hugueskamba left a comment

Choose a reason for hiding this comment

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

LGTM

@ciarmcom ciarmcom requested review from AnttiKauppila, evedon, hugueskamba and a team September 2, 2019 15:00
@ciarmcom
Copy link
Member

ciarmcom commented Sep 2, 2019

@gpsimenos, thank you for your changes.
@AnttiKauppila @hugueskamba @evedon @ARMmbed/mbed-os-wan @ARMmbed/mbed-os-maintainers please review.

@@ -1140,7 +1140,7 @@ bool AT_CellularSMS::create_time(const char *time_string, time_t *time)
&time_struct.tm_hour, &time_struct.tm_min, &time_struct.tm_sec, &sign, &gmt) == kNumberOfElements) {
*time = mktime(&time_struct);
// add timezone as seconds. gmt is in quarter of hours.
int x = 60 * 60 * gmt * 0.25;
int x = (60 / 4) * 60 * gmt;
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would make sense to have macros for these magic numbers too.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not convinced "60 seconds in a minute" is that magic. I don't like moving things off to macros elsewhere, unless it's a shared constant that's going to be reused.

If you want to spell it out, you could do so in the variable names themselves:

   &tz_quarter_hours

   int tz_minutes = tz_quarter_hours * 15;
   int tz_seconds = tz_minutes * 60;
   *time += tz_seconds;

(Using %c%d to grab the sign is also a bit weird - sscanf %d will handle + and - itself. Can't see a need to do it manually here).

@0xc0170
Copy link
Contributor

0xc0170 commented Sep 4, 2019

CI started

@mbed-ci
Copy link

mbed-ci commented Sep 4, 2019

Test run: FAILED

Summary: 2 of 4 test jobs failed
Build number : 1
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_build-IAR
  • jenkins-ci/mbed-os-ci_build-GCC_ARM

@0xc0170
Copy link
Contributor

0xc0170 commented Sep 5, 2019

CI started

@mbed-ci
Copy link

mbed-ci commented Sep 5, 2019

Test run: SUCCESS

Summary: 11 of 11 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