Skip to content

Commit 9537721

Browse files
committed
fix(mdns): Fixed complier warning if MDNS_MAX_SERVICES==0
Closes #611
1 parent 4394f84 commit 9537721

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

components/mdns/mdns.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -334,6 +334,9 @@ static mdns_host_item_t *mdns_get_host_item(const char *hostname)
334334

335335
static bool _mdns_can_add_more_services(void)
336336
{
337+
#if MDNS_MAX_SERVICES == 0
338+
return false;
339+
#else
337340
mdns_srv_item_t *s = _mdns_server->services;
338341
uint16_t service_num = 0;
339342
while (s) {
@@ -343,8 +346,8 @@ static bool _mdns_can_add_more_services(void)
343346
return false;
344347
}
345348
}
346-
347349
return true;
350+
#endif
348351
}
349352

350353
esp_err_t _mdns_send_rx_action(mdns_rx_packet_t *packet)
@@ -5901,7 +5904,8 @@ esp_err_t mdns_service_add_for_host(const char *instance, const char *service, c
59015904
const char *hostname = host ? host : _mdns_server->hostname;
59025905
mdns_service_t *s = NULL;
59035906

5904-
ESP_GOTO_ON_FALSE(_mdns_can_add_more_services(), ESP_ERR_NO_MEM, err, TAG, "Cannot add more services");
5907+
ESP_GOTO_ON_FALSE(_mdns_can_add_more_services(), ESP_ERR_NO_MEM, err, TAG,
5908+
"Cannot add more services, please increase CONFIG_MDNS_MAX_SERVICES (%d)", CONFIG_MDNS_MAX_SERVICES);
59055909

59065910
mdns_srv_item_t *item = _mdns_get_service_item_instance(instance, service, proto, hostname);
59075911
ESP_GOTO_ON_FALSE(!item, ESP_ERR_INVALID_ARG, err, TAG, "Service already exists");

0 commit comments

Comments
 (0)