Skip to content
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

i2c: fix format string specifiers #6746

Merged
merged 1 commit into from
May 15, 2024
Merged

Conversation

ius
Copy link
Contributor

@ius ius commented May 14, 2024

What does this implement/fix?

Building for ESP32-C6 using esp-idf and toolchain-riscv32-esp @ 12.2.0+20230208 fails:

In file included from src/esphome/components/sensor/sensor.h:3,
                 from src/esphome/core/application.h:16,
                 from src/esphome/components/i2c/i2c_bus_esp_idf.cpp:6:
src/esphome/components/i2c/i2c_bus_esp_idf.cpp: In member function 'virtual void esphome::i2c::IDFI2CBus::setup()':
src/esphome/components/i2c/i2c_bus_esp_idf.cpp:59:21: error: format '%d' expects argument of type 'int', but argument 5 has type 'long unsigned int' [-Werror=format=]
   59 |       ESP_LOGV(TAG, "i2c_timeout set to %d ticks (%d us)", timeout_ * 80, timeout_);
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/esphome/components/i2c/i2c_bus_esp_idf.cpp:59:21: error: format '%d' expects argument of type 'int', but argument 6 has type 'uint32_t' {aka 'long unsigned int'} [-Werror=format=]
   59 |       ESP_LOGV(TAG, "i2c_timeout set to %d ticks (%d us)", timeout_ * 80, timeout_);
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This might be a RISC-V'ism - in any case the format string on line 50 uses the PRIu32 macro to format timeout_ - so let's just follow along.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Other

Related issue or feature (if applicable): introduced in #4614

Checklist:

  • The code change is tested and works locally.
  • Tests have been added to verify that the new code works (under tests/ folder).

If user exposed functionality or configuration variables are added/changed:

@probot-esphome
Copy link

Hey there @esphome/core, mind taking a look at this pull request as it has been labeled with an integration (i2c) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

@codecov-commenter
Copy link

codecov-commenter commented May 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 54.21%. Comparing base (4d8b5ed) to head (a69670f).
Report is 588 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #6746      +/-   ##
==========================================
+ Coverage   53.70%   54.21%   +0.50%     
==========================================
  Files          50       50              
  Lines        9408     9594     +186     
  Branches     1654     1691      +37     
==========================================
+ Hits         5053     5201     +148     
- Misses       4056     4069      +13     
- Partials      299      324      +25     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jesserockz jesserockz merged commit 073fb4c into esphome:dev May 15, 2024
65 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators May 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants