mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 06:50:02 +02:00
clang-tidy nullptr
This commit is contained in:
parent
f5160b0978
commit
265e96d675
@ -46,19 +46,19 @@ void BinaryFile::CreateFile() {
|
||||
currentFileName = os.str();
|
||||
|
||||
if (!(*overWriteEnable)) {
|
||||
if (NULL ==
|
||||
if (nullptr ==
|
||||
(filefd = fopen((const char *)currentFileName.c_str(), "wx"))) {
|
||||
filefd = 0;
|
||||
filefd = nullptr;
|
||||
throw sls::RuntimeError("Could not create/overwrite file " +
|
||||
currentFileName);
|
||||
}
|
||||
} else if (NULL ==
|
||||
} else if (nullptr ==
|
||||
(filefd = fopen((const char *)currentFileName.c_str(), "w"))) {
|
||||
filefd = 0;
|
||||
filefd = nullptr;
|
||||
throw sls::RuntimeError("Could not create file " + currentFileName);
|
||||
}
|
||||
// setting to no file buffering
|
||||
setvbuf(filefd, NULL, _IONBF, 0);
|
||||
setvbuf(filefd, nullptr, _IONBF, 0);
|
||||
|
||||
if (!(*silentMode)) {
|
||||
LOG(logINFO) << "[" << *udpPortNumber
|
||||
@ -69,7 +69,7 @@ void BinaryFile::CreateFile() {
|
||||
void BinaryFile::CloseCurrentFile() {
|
||||
if (filefd)
|
||||
fclose(filefd);
|
||||
filefd = 0;
|
||||
filefd = nullptr;
|
||||
}
|
||||
|
||||
void BinaryFile::CloseAllFiles() {
|
||||
@ -77,7 +77,7 @@ void BinaryFile::CloseAllFiles() {
|
||||
if (master) {
|
||||
if (masterfd)
|
||||
fclose(masterfd);
|
||||
masterfd = 0;
|
||||
masterfd = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -153,22 +153,22 @@ void BinaryFile::CreateMasterFile(bool masterFileWriteEnable,
|
||||
|
||||
// create master file
|
||||
if (!(*overWriteEnable)) {
|
||||
if (NULL == (masterfd = fopen((const char *)masterFileName.c_str(),
|
||||
if (nullptr == (masterfd = fopen((const char *)masterFileName.c_str(),
|
||||
"wx"))) {
|
||||
masterfd = 0;
|
||||
masterfd = nullptr;
|
||||
throw sls::RuntimeError("Could not create binary master file "
|
||||
"(without overwrite enable) " +
|
||||
masterFileName);
|
||||
}
|
||||
} else if (NULL == (masterfd = fopen(
|
||||
} else if (nullptr == (masterfd = fopen(
|
||||
(const char *)masterFileName.c_str(), "w"))) {
|
||||
masterfd = 0;
|
||||
masterfd = nullptr;
|
||||
throw sls::RuntimeError("Could not create binary master file "
|
||||
"(with overwrite enable) " +
|
||||
masterFileName);
|
||||
}
|
||||
// create master file data
|
||||
time_t t = time(0);
|
||||
time_t t = time(nullptr);
|
||||
char message[maxMasterFileSize];
|
||||
sprintf(message,
|
||||
"Version : %.1f\n"
|
||||
@ -252,6 +252,6 @@ void BinaryFile::CreateMasterFile(bool masterFileWriteEnable,
|
||||
}
|
||||
if (masterfd)
|
||||
fclose(masterfd);
|
||||
masterfd = 0;
|
||||
masterfd = nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -33,12 +33,12 @@ ZmqSocket::ZmqSocket(const char *const hostname_or_ip,
|
||||
|
||||
// create context
|
||||
sockfd.contextDescriptor = zmq_ctx_new();
|
||||
if (sockfd.contextDescriptor == 0)
|
||||
if (sockfd.contextDescriptor == nullptr)
|
||||
throw sls::ZmqSocketError("Could not create contextDescriptor");
|
||||
|
||||
// create publisher
|
||||
sockfd.socketDescriptor = zmq_socket(sockfd.contextDescriptor, ZMQ_SUB);
|
||||
if (sockfd.socketDescriptor == 0) {
|
||||
if (sockfd.socketDescriptor == nullptr) {
|
||||
PrintError();
|
||||
Close();
|
||||
throw sls::ZmqSocketError("Could not create socket");
|
||||
@ -73,11 +73,11 @@ ZmqSocket::ZmqSocket(const uint32_t portnumber, const char *ethip)
|
||||
|
||||
// create context
|
||||
sockfd.contextDescriptor = zmq_ctx_new();
|
||||
if (sockfd.contextDescriptor == 0)
|
||||
if (sockfd.contextDescriptor == nullptr)
|
||||
throw sls::ZmqSocketError("Could not create contextDescriptor");
|
||||
// create publisher
|
||||
sockfd.socketDescriptor = zmq_socket(sockfd.contextDescriptor, ZMQ_PUB);
|
||||
if (sockfd.socketDescriptor == 0) {
|
||||
if (sockfd.socketDescriptor == nullptr) {
|
||||
PrintError();
|
||||
Close();
|
||||
throw sls::ZmqSocketError("Could not create socket");
|
||||
@ -117,12 +117,12 @@ int ZmqSocket::ConvertHostnameToInternetAddress(const char *const hostname,
|
||||
hints.ai_family = AF_INET;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
// get host info into res
|
||||
int errcode = getaddrinfo(hostname, NULL, &hints, res);
|
||||
int errcode = getaddrinfo(hostname, nullptr, &hints, res);
|
||||
if (errcode != 0) {
|
||||
LOG(logERROR) << "Error: Could not convert hostname " << hostname
|
||||
<< " to internet address (zmq):" << gai_strerror(errcode);
|
||||
} else {
|
||||
if (*res == NULL) {
|
||||
if (*res == nullptr) {
|
||||
LOG(logERROR) << "Could not convert hostname " << hostname
|
||||
<< " to internet address (zmq): "
|
||||
"gettaddrinfo returned null";
|
||||
@ -138,7 +138,7 @@ int ZmqSocket::ConvertInternetAddresstoIpString(struct addrinfo *res, char *ip,
|
||||
const int ipsize) {
|
||||
if (inet_ntop(res->ai_family,
|
||||
&((struct sockaddr_in *)res->ai_addr)->sin_addr, ip,
|
||||
ipsize) != NULL) {
|
||||
ipsize) != nullptr) {
|
||||
freeaddrinfo(res);
|
||||
return 0;
|
||||
}
|
||||
@ -436,7 +436,7 @@ void ZmqSocket::PrintError() {
|
||||
|
||||
// Nested class to do RAII handling of socket descriptors
|
||||
ZmqSocket::mySocketDescriptors::mySocketDescriptors()
|
||||
: server(false), contextDescriptor(0), socketDescriptor(0){};
|
||||
: server(false), contextDescriptor(nullptr), socketDescriptor(nullptr){};
|
||||
ZmqSocket::mySocketDescriptors::~mySocketDescriptors() {
|
||||
Disconnect();
|
||||
Close();
|
||||
@ -448,13 +448,13 @@ void ZmqSocket::mySocketDescriptors::Disconnect() {
|
||||
zmq_disconnect(socketDescriptor, serverAddress);
|
||||
};
|
||||
void ZmqSocket::mySocketDescriptors::Close() {
|
||||
if (socketDescriptor != NULL) {
|
||||
if (socketDescriptor != nullptr) {
|
||||
zmq_close(socketDescriptor);
|
||||
socketDescriptor = NULL;
|
||||
socketDescriptor = nullptr;
|
||||
}
|
||||
|
||||
if (contextDescriptor != NULL) {
|
||||
if (contextDescriptor != nullptr) {
|
||||
zmq_ctx_destroy(contextDescriptor);
|
||||
contextDescriptor = NULL;
|
||||
contextDescriptor = nullptr;
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user