From 87506f46e2922710f48a6b96ca75e53543ff45c4 Mon Sep 17 00:00:00 2001 From: caffreyfans Date: Thu, 16 Dec 2021 14:10:52 +0800 Subject: [PATCH 1/2] unified errno format --- components/mdns/mdns_networking_socket.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/components/mdns/mdns_networking_socket.c b/components/mdns/mdns_networking_socket.c index 55533a9f7f..af07c912e7 100644 --- a/components/mdns/mdns_networking_socket.c +++ b/components/mdns/mdns_networking_socket.c @@ -210,7 +210,7 @@ size_t _mdns_udp_pcb_write(mdns_if_t tcpip_if, mdns_ip_protocol_t ip_protocol, c ESP_LOGD(TAG, "[sock=%d]: Sending to IP %s port %d", sock, get_string_address(&in_addr), port); ssize_t actual_len = sendto(sock, data, len, 0, (struct sockaddr *)&in_addr, ss_size); if (actual_len < 0) { - ESP_LOGE(TAG, "[sock=%d]: _mdns_udp_pcb_write sendto() has failed\n error=%d: %s", sock, errno, strerror(errno)); + ESP_LOGE(TAG, "[sock=%d]: _mdns_udp_pcb_write sendto() has failed\n errno=%d: %s", sock, errno, strerror(errno)); } return actual_len; } @@ -396,7 +396,7 @@ static int create_socket(esp_netif_t *netif) int sock = socket(PF_INET, SOCK_DGRAM, 0); #endif if (sock < 0) { - ESP_LOGE(TAG, "Failed to create socket. Error %d", errno); + ESP_LOGE(TAG, "Failed to create socket. errno %d", errno); return -1; } @@ -412,7 +412,7 @@ static int create_socket(esp_netif_t *netif) bzero(&saddr.sin6_addr.s6_addr, sizeof(saddr.sin6_addr.s6_addr)); int err = bind(sock, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in6)); if (err < 0) { - ESP_LOGE(TAG, "Failed to bind socket. Error %d", errno); + ESP_LOGE(TAG, "Failed to bind socket. errno %d", errno); goto err; } #else @@ -422,7 +422,7 @@ static int create_socket(esp_netif_t *netif) bzero(&saddr.sin_addr.s_addr, sizeof(saddr.sin_addr.s_addr)); int err = bind(sock, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in)); if (err < 0) { - ESP_LOGE(TAG, "Failed to bind socket. Error %d", errno); + ESP_LOGE(TAG, "Failed to bind socket. errno %d", errno); goto err; } #endif // CONFIG_LWIP_IPV6 @@ -447,7 +447,7 @@ static int socket_add_ipv6_multicast_group(int sock, esp_netif_t *netif) int ifindex = esp_netif_get_netif_impl_index(netif); int err = setsockopt(sock, IPPROTO_IPV6, IPV6_MULTICAST_IF, &ifindex, sizeof(ifindex)); if (err < 0) { - ESP_LOGE(TAG, "Failed to set IPV6_MULTICAST_IF. Error %d", errno); + ESP_LOGE(TAG, "Failed to set IPV6_MULTICAST_IF. errno %d", errno); return err; } @@ -457,7 +457,7 @@ static int socket_add_ipv6_multicast_group(int sock, esp_netif_t *netif) v6imreq.ipv6mr_interface = ifindex; err = setsockopt(sock, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, &v6imreq, sizeof(struct ipv6_mreq)); if (err < 0) { - ESP_LOGE(TAG, "Failed to set IPV6_ADD_MEMBERSHIP. Error %d", errno); + ESP_LOGE(TAG, "Failed to set IPV6_ADD_MEMBERSHIP. errno %d", errno); return err; } return err; @@ -482,7 +482,7 @@ static int socket_add_ipv4_multicast_group(int sock, esp_netif_t *netif) err = setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, &imreq, sizeof(struct ip_mreq)); if (err < 0) { ESP_LOGE(TAG, "%d %s", sock, strerror(errno)); - ESP_LOGE(TAG, "Failed to set IP_ADD_MEMBERSHIP. Error %d", errno); + ESP_LOGE(TAG, "Failed to set IP_ADD_MEMBERSHIP. errno %d", errno); goto err; } From f1b8f5c1023df7d649161bc76f2bcc9a8f8f4d8b Mon Sep 17 00:00:00 2001 From: David Cermak Date: Thu, 16 Dec 2021 16:00:44 +0100 Subject: [PATCH 2/2] mdns: Minor err print fix in socket-networking layer --- components/mdns/mdns_networking_socket.c | 39 +++++++++--------------- tools/ci/check_copyright_ignore.txt | 1 - 2 files changed, 15 insertions(+), 25 deletions(-) diff --git a/components/mdns/mdns_networking_socket.c b/components/mdns/mdns_networking_socket.c index af07c912e7..45ad83dec3 100644 --- a/components/mdns/mdns_networking_socket.c +++ b/components/mdns/mdns_networking_socket.c @@ -1,16 +1,8 @@ -// Copyright 2021 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ /** * @brief MDNS Server Networking module implemented using BSD sockets @@ -272,7 +264,7 @@ void sock_recv_task(void* arg) int s = select(max_sock + 1, &rfds, NULL, NULL, &tv); if (s < 0) { - ESP_LOGE(TAG, "Select failed: errno %d", errno); + ESP_LOGE(TAG, "Select failed. errno=%d: %s", errno, strerror(errno)); break; } else if (s > 0) { for (int tcpip_if=0; tcpip_if