Skip to content

Compilation issue with -Wformat= as used by esp32_arduino core #45

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

Closed
mazgch opened this issue May 29, 2024 · 1 comment
Closed

Compilation issue with -Wformat= as used by esp32_arduino core #45

mazgch opened this issue May 29, 2024 · 1 comment

Comments

@mazgch
Copy link
Contributor

mazgch commented May 29, 2024

Subject of the issue

Install arduino_esp32 version 3.0.0

Your workbench

Arduino IDE 2.3.2 with warnings enabled (Compiler Warnings set to ALL in Arduino IDE->Settings)

Steps to reproduce

Compile with warnings enabled (Compiler Warnings set to ALL in Arduino IDE->Settings)

Expected behaviour

Compiler should not create warnings for printfs or Scafs regrind type mismatches with uint32_t or int32_t types.

Actual behaviour

SparkFun_u-blox_SARA-R5_Arduino_Library.cpp: In member function 'SARA_R5_error_t SARA_R5::setUtimeConfiguration(int32_t, int32_t)':
SparkFun_u-blox_SARA-R5_Arduino_Library.cpp:1487:25: warning: format '%d' expects argument of type 'int', but argument 4 has type 'int32_t' {aka 'long int'} [-Wformat=]
 1487 |   sprintf(command, "%s=%d,%d", SARA_R5_GNSS_TIME_CONFIGURATION, offsetNanoseconds, offsetSeconds);
      |                        ~^                                       ~~~~~~~~~~~~~~~~~
      |                         |                                       |
      |                         int                                     int32_t {aka long int}
      |                        %ld
SparkFun_u-blox_SARA-R5_Arduino_Library.cpp:1487:28: warning: format '%d' expects argument of type 'int', but argument 5 has type 'int32_t' {aka 'long int'} [-Wformat=]
 1487 |   sprintf(command, "%s=%d,%d", SARA_R5_GNSS_TIME_CONFIGURATION, offsetNanoseconds, offsetSeconds);
      |                           ~^                                                       ~~~~~~~~~~~~~
      |                            |                                                       |
      |                            int                                                     int32_t {aka long int}
      |                           %ld
SparkFun_u-blox_SARA-R5_Arduino_Library.cpp: In member function 'SARA_R5_error_t SARA_R5::getUtimeConfiguration(int32_t*, int32_t*)':
SparkFun_u-blox_SARA-R5_Arduino_Library.cpp:1532:37: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'int32_t*' {aka 'long int*'} [-Wformat=]
 1532 |       scanned = sscanf(searchPtr, "%d,%d\r\n", &ons, &os);
      |                                    ~^          ~~~~
      |                                     |          |
      |                                     int*       int32_t* {aka long int*}
      |                                    %ld
SparkFun_u-blox_SARA-R5_Arduino_Library.cpp:1532:40: warning: format '%d' expects argument of type 'int*', but argument 4 has type 'int32_t*' {aka 'long int*'} [-Wformat=]
 1532 |       scanned = sscanf(searchPtr, "%d,%d\r\n", &ons, &os);
      |                                       ~^             ~~~
      |                                        |             |
      |                                        int*          int32_t* {aka long int*}
      |                                       %ld
SparkFun_u-blox_SARA-R5_Arduino_Library/src/SparkFun_u-blox_SARA-R5_Arduino_Library.cpp: In member function 'SARA_R5_error_t SARA_R5::gpsRequest(unsigned int, uint32_t, bool, unsigned int)':
SparkFun_u-blox_SARA-R5_Arduino_Library/src/SparkFun_u-blox_SARA-R5_Arduino_Library.cpp:5259:36: warning: format '%d' expects argument of type 'int', but argument 7 has type 'uint32_t' {aka 'long unsigned int'} [-Wformat=]
 5259 |   sprintf(command, "%s=2,%d,%d,%d,%d", SARA_R5_GNSS_REQUEST_LOCATION,
      |                                   ~^
      |                                    |
      |                                    int
      |                                   %ld
 5260 |           sensor, detailed ? 1 : 0, timeout, accuracy);
      |                                              ~~~~~~~~
      |                                              |
      |                                              uint32_t {aka long unsigned int}
SparkFun_u-blox_SARA-R5_Arduino_Library/src/SparkFun_u-blox_SARA-R5_Arduino_Library.cpp: In member function 'SARA_R5::SARA_R5_gpio_mode_t SARA_R5::getGpioMode(SARA_R5_gpio_t)':
SparkFun_u-blox_SARA-R5_Arduino_Library/src/SparkFun_u-blox_SARA-R5_Arduino_Library.cpp:2635:9: warning: pointer 'gpioStart' may be used after 'void free(void*)' [-Wuse-after-free]
 2635 |   sscanf(gpioStart, "%*d,%d\r\n", &gpioMode);
      |   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SparkFun_u-blox_SARA-R5_Arduino_Library/src/SparkFun_u-blox_SARA-R5_Arduino_Library.cpp:2631:7: note: call to 'void free(void*)' here
 2631 |   free(response);
      |   ~~~~^~~~~~~~~~```
mazgch added a commit to mazgch/SparkFun_u-blox_SARA-R5_Arduino_Library that referenced this issue May 29, 2024
fixes issue sparkfun#45

This is a manual backport,
@PaulZC
Copy link
Collaborator

PaulZC commented May 30, 2024

Resolved by #46 - thank you @mazgch

@PaulZC PaulZC closed this as completed May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants