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

Some SDK headers not compatible with -Wsign-conversion (IDFGH-2901) #4946

Closed
hb-kaertech opened this issue Mar 17, 2020 · 0 comments
Closed
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally

Comments

@hb-kaertech
Copy link

Environment

  • IDF version: v4.2-dev-701-g0ae960f2fe
  • Build System: idf.py
  • Compiler version: (crosstool-NG esp-2019r2) 8.2.0
  • Operating System: Linux

Problem Description

I would like to compile my own code with the -Wsign-conversion cflag. Unfortunately, some of ESP-IDF headers are not compatible with this option and generate some warnings.

components/esp_http_server/include/esp_http_server.h:

@@ -1039,7 +1039,7 @@ esp_err_t httpd_resp_send_chunk(httpd_req_t *r, const char *buf, ssize_t buf_len
  *  - ESP_ERR_HTTPD_INVALID_REQ : Invalid request
  */
 static inline esp_err_t httpd_resp_sendstr(httpd_req_t *r, const char *str) {
-    return httpd_resp_send(r, str, (str == NULL) ? 0 : strlen(str));
+    return httpd_resp_send(r, str, (str == NULL) ? 0 : HTTPD_RESP_USE_STRLEN);
 }
 
 /**
@@ -1060,7 +1060,7 @@ static inline esp_err_t httpd_resp_sendstr(httpd_req_t *r, const char *str) {
  *  - ESP_ERR_HTTPD_INVALID_REQ : Invalid request
  */
 static inline esp_err_t httpd_resp_sendstr_chunk(httpd_req_t *r, const char *str) {
-    return httpd_resp_send_chunk(r, str, (str == NULL) ? 0 : strlen(str));
+    return httpd_resp_send_chunk(r, str, (str == NULL) ? 0 : HTTPD_RESP_USE_STRLEN);
 }
 
 /* Some commonly used status codes */

components/freertos/include/freertos/portable.h:
(maybe the right fix is changing the return type of cpu_hal_get_core_id ? Internally, cpu_hal_get_core_id uses an uint32_t.)

@@ -202,7 +202,7 @@ BaseType_t xPortInterruptedFromISRContext(void);
 
 /* Multi-core: get current core ID */
 static inline uint32_t IRAM_ATTR xPortGetCoreID(void) {
-    return cpu_hal_get_core_id();
+    return (uint32_t) cpu_hal_get_core_id();
 }
 
 /* Get tick rate per second */

components/xtensa/include/xtensa/xtruntime.h:

@@ -158,12 +158,12 @@ extern unsigned int       _xtos_ints_on( unsigned int mask );
 /* Newer functions to enable/disable the specified interrupt.  */
 static inline void _xtos_interrupt_enable(unsigned int intnum)
 {
-    _xtos_ints_on(1 << intnum);
+    _xtos_ints_on(1U << intnum);
 }
 
 static inline void _xtos_interrupt_disable(unsigned int intnum)
 {
-    _xtos_ints_off(1 << intnum);
+    _xtos_ints_off(1U << intnum);
 }
 
 extern unsigned                _xtos_set_intlevel( int intlevel );

Could you fix these? Thank you!

Code to reproduce this issue

  1. Patch on the SDK examples to include the headers mentioned above.
  2. Add this after idf_component_register(): target_compile_options(${COMPONENT_LIB} PRIVATE "-Wsign-conversion")
@github-actions github-actions bot changed the title Some SDK headers not compatible with -Wsign-conversion Some SDK headers not compatible with -Wsign-conversion (IDFGH-2901) Mar 17, 2020
@espressif-bot espressif-bot added the Status: In Progress Work is in progress label Sep 22, 2021
@espressif-bot espressif-bot added Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Resolution: Done Issue is done internally and removed Status: In Progress Work is in progress Resolution: NA Issue resolution is unavailable labels Dec 27, 2021
dskulina pushed a commit to playable-tech/esp-idf that referenced this issue Feb 4, 2022
dskulina pushed a commit to playable-tech/esp-idf that referenced this issue Feb 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally
Projects
None yet
Development

No branches or pull requests

2 participants