use nullptr instead of NULL
This commit is contained in:
+10
-10
@@ -52,7 +52,7 @@ Device::~Device() {
|
||||
}
|
||||
|
||||
Device* Device::create(const char* name, bool checkDevice, bool readOnly, bool initialSend) {
|
||||
if (strchr(name, '/') == NULL && strchr(name, ':') != NULL) {
|
||||
if (strchr(name, '/') == nullptr && strchr(name, ':') != nullptr) {
|
||||
char* in = strdup(name);
|
||||
bool udp = false;
|
||||
char* addrpos = in;
|
||||
@@ -61,24 +61,24 @@ Device* Device::create(const char* name, bool checkDevice, bool readOnly, bool i
|
||||
addrpos += 4;
|
||||
portpos = strchr(addrpos, ':');
|
||||
}
|
||||
if (portpos == NULL) {
|
||||
if (portpos == nullptr) {
|
||||
free(in);
|
||||
return NULL; // invalid protocol or missing port
|
||||
return nullptr; // invalid protocol or missing port
|
||||
}
|
||||
result_t result = RESULT_OK;
|
||||
unsigned int port = parseInt(portpos+1, 10, 1, 65535, &result);
|
||||
if (result != RESULT_OK) {
|
||||
free(in);
|
||||
return NULL; // invalid port
|
||||
return nullptr; // invalid port
|
||||
}
|
||||
struct sockaddr_in address;
|
||||
memset(reinterpret_cast<char*>(&address), 0, sizeof(address));
|
||||
*portpos = 0;
|
||||
if (inet_aton(addrpos, &address.sin_addr) == 0) {
|
||||
struct hostent* h = gethostbyname(addrpos);
|
||||
if (h == NULL) {
|
||||
if (h == nullptr) {
|
||||
free(in);
|
||||
return NULL; // invalid host
|
||||
return nullptr; // invalid host
|
||||
}
|
||||
memcpy(&address.sin_addr, h->h_addr_list[0], h->h_length);
|
||||
}
|
||||
@@ -114,7 +114,7 @@ result_t Device::send(symbol_t value) {
|
||||
if (m_readOnly || write(value) != 1) {
|
||||
return RESULT_ERR_SEND;
|
||||
}
|
||||
if (m_listener != NULL) {
|
||||
if (m_listener != nullptr) {
|
||||
m_listener->notifyDeviceData(value, false);
|
||||
}
|
||||
return RESULT_OK;
|
||||
@@ -140,7 +140,7 @@ result_t Device::recv(unsigned int timeout, symbol_t* value) {
|
||||
|
||||
fds[0].fd = m_fd;
|
||||
fds[0].events = POLLIN | POLLERR | POLLHUP | POLLRDHUP;
|
||||
ret = ppoll(fds, nfds, &tdiff, NULL);
|
||||
ret = ppoll(fds, nfds, &tdiff, nullptr);
|
||||
if (ret >= 0 && fds[0].revents & (POLLERR | POLLHUP | POLLRDHUP)) {
|
||||
ret = -1;
|
||||
}
|
||||
@@ -152,7 +152,7 @@ result_t Device::recv(unsigned int timeout, symbol_t* value) {
|
||||
FD_ZERO(&exceptfds);
|
||||
FD_SET(m_fd, &readfds);
|
||||
|
||||
ret = pselect(m_fd + 1, &readfds, NULL, &exceptfds, &tdiff, NULL);
|
||||
ret = pselect(m_fd + 1, &readfds, nullptr, &exceptfds, &tdiff, nullptr);
|
||||
if (ret >= 1 && FD_ISSET(m_fd, &exceptfds)) {
|
||||
ret = -1;
|
||||
}
|
||||
@@ -178,7 +178,7 @@ result_t Device::recv(unsigned int timeout, symbol_t* value) {
|
||||
close();
|
||||
return RESULT_ERR_DEVICE;
|
||||
}
|
||||
if (m_listener != NULL) {
|
||||
if (m_listener != nullptr) {
|
||||
m_listener->notifyDeviceData(*value, true);
|
||||
}
|
||||
return RESULT_OK;
|
||||
|
||||
Reference in New Issue
Block a user