Commit dbc8fa1b authored by Rolf Eike Beer's avatar Rolf Eike Beer

SystemInformation: fix truncation warnings

Fixes the following truncation warnings from g++ 4.8:

kwsys/SystemInformation.cxx: In member function 'int cmsys::SystemInformationImplementation::GetFullyQualifiedDomainName(std::string&)':
kwsys/SystemInformation.cxx:1738:31: warning: conversion to 'socklen_t {aka unsigned int}' from 'long unsigned int' may alter its value [-Wconversion]
         = (fam==AF_INET?sizeof(struct sockaddr_in):sizeof(struct sockaddr_in6));
                               ^
kwsys/SystemInformation.cxx:1738:58: warning: conversion to 'socklen_t {aka unsigned int}' from 'long unsigned int' may alter its value [-Wconversion]
         = (fam==AF_INET?sizeof(struct sockaddr_in):sizeof(struct sockaddr_in6));
                                                          ^
kwsys/SystemInformation.cxx: In member function 'bool cmsys::SystemInformationImplementation::QueryLinuxMemory()':
kwsys/SystemInformation.cxx:3839:33: warning: conversion to 'int' from 'long unsigned int' may alter its value [-Wconversion]
     char *r=fgets(buffer, sizeof(buffer), fd); // Skip "total: used:..."
                                 ^

Change-Id: I1016a7e31325ee550322dde7a21ffc92d6ca49dc
parent deec6b8a
......@@ -1734,12 +1734,12 @@ int SystemInformationImplementation::GetFullyQualifiedDomainName(
{
char host[NI_MAXHOST]={'\0'};
socklen_t addrlen
const size_t addrlen
= (fam==AF_INET?sizeof(struct sockaddr_in):sizeof(struct sockaddr_in6));
ierr=getnameinfo(
ifa->ifa_addr,
addrlen,
static_cast<socklen_t>(addrlen),
host,
NI_MAXHOST,
NULL,
......@@ -3836,7 +3836,8 @@ bool SystemInformationImplementation::QueryLinuxMemory()
unsigned long temp;
unsigned long cachedMem;
unsigned long buffersMem;
char *r=fgets(buffer, sizeof(buffer), fd); // Skip "total: used:..."
// Skip "total: used:..."
char *r=fgets(buffer, static_cast<int>(sizeof(buffer)), fd);
int status=0;
if(r==buffer)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment