[PATCH 6/8] nss: aiforaf: Drop unused buffer 'port'

Peter Krempa pkrempa at redhat.com
Wed Aug 30 11:59:20 UTC 2023


The 'port' buffer is passed to 'getnameinfo' which is supposed to fill
it but it's not actually later used. Drop the buffer as 'getnameinfo'
allows NULL arguments if they are not needed.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 tools/nss/libvirt_nss.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/nss/libvirt_nss.c b/tools/nss/libvirt_nss.c
index faa44e78df..37720bf4ae 100644
--- a/tools/nss/libvirt_nss.c
+++ b/tools/nss/libvirt_nss.c
@@ -493,7 +493,6 @@ aiforaf(const char *name,
         socklen_t salen;
         void *address = *addrList;
         char host[NI_MAXHOST];
-        char port[NI_MAXSERV];

         if (resolved.h_addrtype == AF_INET) {
             sa.sin.sin_family = AF_INET;
@@ -511,7 +510,7 @@ aiforaf(const char *name,

         if ((err = getnameinfo(&sa.sa, salen,
                                host, sizeof(host),
-                               port, sizeof(port),
+                               NULL, 0,
                                NI_NUMERICHOST | NI_NUMERICSERV)) != 0) {
             ERROR("Cannot convert socket address to string: %s",
                   gai_strerror(err));
-- 
2.41.0



More information about the libvir-list mailing list