Skip to content

Commit 31f6107

Browse files
authored
Get rid of _fd member variable in fnTcpClient which was shadowing fd() method (#1037)
1 parent 672c0a0 commit 31f6107

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

lib/tcpip/fnTcpClient.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,8 @@ class fnTcpClientSocketHandle
5757

5858
fnTcpClient::fnTcpClient(int fd)
5959
{
60-
_fd = fd;
6160
_connected = true;
62-
_clientSocketHandle.reset(new fnTcpClientSocketHandle(_fd));
61+
_clientSocketHandle.reset(new fnTcpClientSocketHandle(fd));
6362
_rxBuffer.clear();
6463
}
6564

@@ -432,23 +431,24 @@ void fnTcpClient::updateFIFO()
432431

433432
#if defined(_WIN32)
434433
unsigned long count;
435-
int res = ioctlsocket(_fd, FIONREAD, &count);
434+
int res = ioctlsocket(fd(), FIONREAD, &count);
436435
res = res != 0 ? -1 : count;
437436
#else
438437
int count;
439-
int res = ioctl(_fd, FIONREAD, &count);
438+
int res = ioctl(fd(), FIONREAD, &count);
440439
res = res < 0 ? -1 : count;
441440
#endif
442441

443442
if (res > 0)
444443
{
445444
ssize_t result;
445+
unsigned count;
446446

447447
for (count = res; count; count -= result)
448448
{
449449
size_t old_len = _rxBuffer.size();
450450
_rxBuffer.resize(old_len + count);
451-
result = recv(_fd, &_rxBuffer[old_len], count, 0);
451+
result = recv(fd(), &_rxBuffer[old_len], count, 0);
452452
if (result < 0)
453453
result = 0;
454454
_rxBuffer.resize(old_len + result);
@@ -484,7 +484,7 @@ void fnTcpClient::flush()
484484
res = recv(fd(), (char *)buf, toRead, MSG_DONTWAIT);
485485
if (res < 0)
486486
{
487-
Debug_printf("fail on fd %d, errno: %d, \"%s\"\r\n",
487+
Debug_printf("fail on fd %d, errno: %d, \"%s\"\r\n",
488488
fd(), compat_getsockerr(), compat_sockstrerror(compat_getsockerr()));
489489
stop();
490490
break;

lib/tcpip/fnTcpClient.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ class fnTcpClient
1414
{
1515
protected:
1616
std::string _rxBuffer;
17-
int _fd;
1817
std::shared_ptr<fnTcpClientSocketHandle> _clientSocketHandle;
1918
bool _connected = false;
2019

0 commit comments

Comments
 (0)