mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-12-27 15:16:03 +00:00
mdns_resp_add_service: simplify the max services guard.
This commit is contained in:
parent
224b884c1e
commit
156bb74d17
@ -2385,8 +2385,7 @@ mdns_resp_rename_netif(struct netif *netif, const char *hostname)
|
|||||||
s8_t
|
s8_t
|
||||||
mdns_resp_add_service(struct netif *netif, const char *name, const char *service, enum mdns_sd_proto proto, u16_t port, service_get_txt_fn_t txt_fn, void *txt_data)
|
mdns_resp_add_service(struct netif *netif, const char *name, const char *service, enum mdns_sd_proto proto, u16_t port, service_get_txt_fn_t txt_fn, void *txt_data)
|
||||||
{
|
{
|
||||||
s8_t i;
|
u8_t slot;
|
||||||
s8_t slot = -1;
|
|
||||||
struct mdns_service *srv;
|
struct mdns_service *srv;
|
||||||
struct mdns_host *mdns;
|
struct mdns_host *mdns;
|
||||||
|
|
||||||
@ -2399,13 +2398,12 @@ mdns_resp_add_service(struct netif *netif, const char *name, const char *service
|
|||||||
LWIP_ERROR("mdns_resp_add_service: Service too long", (strlen(service) <= MDNS_LABEL_MAXLEN), return ERR_VAL);
|
LWIP_ERROR("mdns_resp_add_service: Service too long", (strlen(service) <= MDNS_LABEL_MAXLEN), return ERR_VAL);
|
||||||
LWIP_ERROR("mdns_resp_add_service: Bad proto (need TCP or UDP)", (proto == DNSSD_PROTO_TCP || proto == DNSSD_PROTO_UDP), return ERR_VAL);
|
LWIP_ERROR("mdns_resp_add_service: Bad proto (need TCP or UDP)", (proto == DNSSD_PROTO_TCP || proto == DNSSD_PROTO_UDP), return ERR_VAL);
|
||||||
|
|
||||||
for (i = 0; i < MDNS_MAX_SERVICES; i++) {
|
for (slot = 0; slot < MDNS_MAX_SERVICES; slot++) {
|
||||||
if (mdns->services[i] == NULL) {
|
if (mdns->services[slot] == NULL) {
|
||||||
slot = i;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LWIP_ERROR("mdns_resp_add_service: Service list full (increase MDNS_MAX_SERVICES)", (slot >= 0), return ERR_MEM);
|
LWIP_ERROR("mdns_resp_add_service: Service list full (increase MDNS_MAX_SERVICES)", (slot < MDNS_MAX_SERVICES), return ERR_MEM);
|
||||||
|
|
||||||
srv = (struct mdns_service *)mem_calloc(1, sizeof(struct mdns_service));
|
srv = (struct mdns_service *)mem_calloc(1, sizeof(struct mdns_service));
|
||||||
LWIP_ERROR("mdns_resp_add_service: Alloc failed", (srv != NULL), return ERR_MEM);
|
LWIP_ERROR("mdns_resp_add_service: Alloc failed", (srv != NULL), return ERR_MEM);
|
||||||
|
Loading…
Reference in New Issue
Block a user