comparison src/channel.c @ 20267:456c3b98d4c8 v8.2.0689

patch 8.2.0689: when using getaddrinfo() the error message is unclear Commit: https://github.com/vim/vim/commit/a38b2b737e244eb2e4f199e070b05f86f4d433d4 Author: Bram Moolenaar <Bram@vim.org> Date: Sun May 3 17:03:29 2020 +0200 patch 8.2.0689: when using getaddrinfo() the error message is unclear Problem: When using getaddrinfo() the error message is unclear. Solution: Use gai_strerror() to get the message. (Ozaki Kiichi, closes #6034)
author Bram Moolenaar <Bram@vim.org>
date Sun, 03 May 2020 17:15:04 +0200
parents 128963cd954f
children 8a694c9447d7
comparison
equal deleted inserted replaced
20266:cb107e572f1c 20267:456c3b98d4c8
953 void (*nb_close_cb)(void)) 953 void (*nb_close_cb)(void))
954 { 954 {
955 int sd = -1; 955 int sd = -1;
956 channel_T *channel = NULL; 956 channel_T *channel = NULL;
957 #ifdef FEAT_IPV6 957 #ifdef FEAT_IPV6
958 int err;
958 struct addrinfo hints; 959 struct addrinfo hints;
959 struct addrinfo *res = NULL; 960 struct addrinfo *res = NULL;
960 struct addrinfo *addr = NULL; 961 struct addrinfo *addr = NULL;
961 #else 962 #else
962 struct sockaddr_in server; 963 struct sockaddr_in server;
984 hints.ai_flags = AI_ADDRCONFIG; 985 hints.ai_flags = AI_ADDRCONFIG;
985 # endif 986 # endif
986 // Set port number manually in order to prevent name resolution services 987 // Set port number manually in order to prevent name resolution services
987 // from being invoked in the environment where AI_NUMERICSERV is not 988 // from being invoked in the environment where AI_NUMERICSERV is not
988 // defined. 989 // defined.
989 if (getaddrinfo(hostname, NULL, &hints, &res) != 0) 990 if ((err = getaddrinfo(hostname, NULL, &hints, &res)) != 0)
990 { 991 {
991 ch_error(channel, "in getaddrinfo() in channel_open()"); 992 ch_error(channel, "in getaddrinfo() in channel_open()");
992 PERROR(_("E901: getaddrinfo() in channel_open()")); 993 semsg(_("E901: getaddrinfo() in channel_open(): %s"),
994 gai_strerror(err));
993 channel_free(channel); 995 channel_free(channel);
994 return NULL; 996 return NULL;
995 } 997 }
996 998
997 for (addr = res; addr != NULL; addr = addr->ai_next) 999 for (addr = res; addr != NULL; addr = addr->ai_next)