Skip to content

Format warning issued on ESP32 device in WebHandlers.cpp #352

@brawner

Description

@brawner

Platform

ESP32

IDE / Tooling

Platformio with esp arduino framework.

What happened?

If one has format warnings turned on, there is a new warning that occurs in versions 3.9.x for my ESP32 device. Like the 8266 a uint32_t is a standard unsigned int and just needs the %x formatter.

Code in question:
https://github.com/ESP32Async/ESPAsyncWebServer/blob/main/src/WebHandlers.cpp#L241

Stack Trace

.pio/libdeps/deployment/ESPAsyncWebServer/src/WebHandlers.cpp:241:34: error: format '%lx' expects argument of type 'long unsigned int', but argument 4 has type 'uint32_t' {aka 'unsigned int'} [-Werror=format=]
     snprintf(etag, sizeof(etag), "%08lx", etagValue);

Minimal Reproductible Example (MRE)

Add -Wformat=2 to the platformio.ini build_flags section

I confirm that:

  • I have read the documentation.
  • I have searched for similar discussions.
  • I have searched for similar issues.
  • I have looked at the examples.
  • I have upgraded to the lasted version of ESPAsyncWebServer (and AsyncTCP for ESP32).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions