mkulke / ftplibpp

Platform independent c++ library providing ftp client functionality.
GNU Lesser General Public License v2.1
291 stars 108 forks source link

Variable ret is never used - please suppress a warning #14

Closed Fojtik closed 5 years ago

Fojtik commented 7 years ago

function ftplib::Connect - Current code uses a variable ret in only one branch.

#if defined(_WIN32)
  if((sin.sin_addr.s_addr = inet_addr(lhost)) == -1)
#else
  ret = inet_aton(lhost, &sin.sin_addr);
  if(ret == 0)
#endif

Proposed fix No1 - variable ret is completelly useles and so it can be elliminated anyway:

#if defined(_WIN32)
  if((sin.sin_addr.s_addr = inet_addr(lhost)) == -1)
#else
  if(inet_aton(lhost, &sin.sin_addr) == 0)
#endif

Proposed alternative fix No2 - declare variable ret in one branch:

#if defined(_WIN32)
  if((sin.sin_addr.s_addr = inet_addr(lhost)) == -1)
#else
  int ret = inet_aton(lhost, &sin.sin_addr);
  if(ret == 0)
#endif
mkulke commented 5 years ago

thx incorporated those