zephyr/drivers/wifi/esp_at
Aleksandar Markovic 9b0a506cf0 wifi: esp_at: Fix Coverity issues related to ESP_MAX_DNS
If the preprocessor constant ESP_MAX_DNS is defined as 0,
Coverity reports a condition that can never be true, and some
dead code as well. This also violates MISRA rules on dead code.

This is caused by this segment in drivers/wifi/esp_at/esp.h:

 #if defined(CONFIG_WIFI_ESP_AT_DNS_USE)
 #define ESP_MAX_DNS	MIN(3, CONFIG_DNS_RESOLVER_MAX_SERVERS)
 #else
 #define ESP_MAX_DNS	0
 #endif

Fix this by never setting ESP_MAX_DNS to 0, as is the currently
case. Define ESP_MAX_DNS only if it is configured through
CONFIG_WIFI_ESP_AT_DNS_USE and CONFIG_DNS_RESOLVER_MAX_SERVERS:

 #if defined(CONFIG_WIFI_ESP_AT_DNS_USE)
 #define ESP_MAX_DNS	MIN(3, CONFIG_DNS_RESOLVER_MAX_SERVERS)
 #endif

Since CONFIG_DNS_RESOLVER_MAX_SERVERS is 1 or greater, ESP_MAX_DNS
will always be greater than 0.

If, on the other hand, ESP_MAX_DNS is not defined, relevant
functions will be reduced to empty stubs, since in that case
they do not make sense.

There could be a cleaner solution to this, but this one is the
least intrusive (involves less code changes).

Coverity-CID: 219490
Coverity-CID: 219513
Coverity-CID: 219520
Coverity-CID: 219524

Signed-off-by: Aleksandar Markovic <aleksandar.markovic.sa@gmail.com>
2022-07-04 16:06:41 +02:00
..
CMakeLists.txt
Kconfig.esp_at
esp.c wifi: esp_at: Fix Coverity issues related to ESP_MAX_DNS 2022-07-04 16:06:41 +02:00
esp.h wifi: esp_at: Fix Coverity issues related to ESP_MAX_DNS 2022-07-04 16:06:41 +02:00
esp_offload.c
esp_socket.c