From 87abd64793305b1664417c3b25f6c785d892e9c8 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer <eike@sf-mail.de> Date: Tue, 21 May 2013 23:25:11 +0200 Subject: [PATCH] SystemInformation: fix truncation warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit .../kwsys/SystemInformation.cxx: In member function ‘int cmsys::SystemInformationImplementation::GetFullyQualifiedDomainName(std::string&)’: .../kwsys/SystemInformation.cxx:1475:31: warning: conversion to ‘int’ from ‘long unsigned int’ may alter its value [-Wconversion] = (fam==AF_INET?sizeof(struct sockaddr_in):sizeof(struct sockaddr_in6)); ^ .../kwsys/SystemInformation.cxx:1475:58: warning: conversion to ‘int’ from ‘long unsigned int’ may alter its value [-Wconversion] = (fam==AF_INET?sizeof(struct sockaddr_in):sizeof(struct sockaddr_in6)); POSIX says the type of the second argument to getnameinfo() should be socklen_t so use that as the variable type here. Chances are high that this has the same size as size_t so the warning would go away. Change-Id: Ie2816b401a8fe7d615fa17a58b611e2cad14e4ea --- SystemInformation.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SystemInformation.cxx b/SystemInformation.cxx index 9e2a93d..8621d2e 100644 --- a/SystemInformation.cxx +++ b/SystemInformation.cxx @@ -1471,7 +1471,7 @@ int SystemInformationImplementation::GetFullyQualifiedDomainName( { char host[NI_MAXHOST]={'\0'}; - int addrlen + socklen_t addrlen = (fam==AF_INET?sizeof(struct sockaddr_in):sizeof(struct sockaddr_in6)); ierr=getnameinfo( -- GitLab