Skip to content

Commit

Permalink
clang tidy check: replace NULL and 0 by nullptr
Browse files Browse the repository at this point in the history
  • Loading branch information
jcdr428 committed Aug 9, 2023
1 parent ebdd811 commit 2800bac
Show file tree
Hide file tree
Showing 44 changed files with 237 additions and 237 deletions.
4 changes: 2 additions & 2 deletions libmediation/fs/osdep/directory_win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ bool createDir(const std::string& dirName, bool createParentDirs)
(strStartWith(parentDir, "\\\\.\\") && parentDir[parentDir.size() - 1] == '}'); // UNC patch prefix
},
[](auto&& parentDir) {
if (CreateDirectory(toWide(parentDir).data(), 0) == 0)
if (CreateDirectory(toWide(parentDir).data(), nullptr) == 0)
{
if (GetLastError() != ERROR_ALREADY_EXISTS)
return false;
}
return true;
},
getDirSeparator(), dirName, createParentDirs);
return ok ? CreateDirectory(toWide(dirName).data(), 0) != 0 : false;
return ok ? CreateDirectory(toWide(dirName).data(), nullptr) != 0 : false;
}

bool deleteFile(const string& fileName)
Expand Down
16 changes: 8 additions & 8 deletions libmediation/fs/osdep/file_win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ void throwFileError()
LPVOID msgBuf = nullptr;
DWORD dw = GetLastError();

FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&msgBuf, 0, NULL);
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, nullptr, dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&msgBuf, 0, nullptr);

std::string str((char*)msgBuf);
throw std::runtime_error(str);
Expand Down Expand Up @@ -61,8 +61,8 @@ File::File(const char* fName, unsigned int oflag, unsigned int systemDependentFl
else
systemDependentFlags = FILE_FLAG_RANDOM_ACCESS;
}
m_impl = CreateFile(toWide(fName).data(), dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition,
systemDependentFlags, NULL);
m_impl = CreateFile(toWide(fName).data(), dwDesiredAccess, dwShareMode, nullptr, dwCreationDisposition,
systemDependentFlags, nullptr);
if (m_impl == INVALID_HANDLE_VALUE)
{
throwFileError();
Expand Down Expand Up @@ -106,8 +106,8 @@ bool File::open(const char* fName, unsigned int oflag, unsigned int systemDepend
{
createDir(extractFileDir(fName), true);
}
m_impl = CreateFile(toWide(fName).data(), dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition,
systemDependentFlags, NULL);
m_impl = CreateFile(toWide(fName).data(), dwDesiredAccess, dwShareMode, nullptr, dwCreationDisposition,
systemDependentFlags, nullptr);
if (m_impl == INVALID_HANDLE_VALUE)
{
return false;
Expand Down Expand Up @@ -140,7 +140,7 @@ int File::read(void* buffer, uint32_t count) const
return -1;

DWORD bytesRead = 0;
BOOL res = ReadFile(m_impl, buffer, count, &bytesRead, NULL);
BOOL res = ReadFile(m_impl, buffer, count, &bytesRead, nullptr);
if (!res)
return -1;

Expand All @@ -155,7 +155,7 @@ int File::write(const void* buffer, uint32_t count)
return -1;

DWORD bytesWritten = 0;
BOOL res = WriteFile(m_impl, buffer, count, &bytesWritten, NULL);
BOOL res = WriteFile(m_impl, buffer, count, &bytesWritten, nullptr);
if (!res)
{
throwFileError();
Expand Down
20 changes: 10 additions & 10 deletions libmediation/types/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,25 +78,25 @@ uint64_t strToInt64u(const char* const str)
#endif
}

int32_t strToInt32(const char* const str) { return strtol(str, 0, 10); }
int32_t strToInt32(const char* const str) { return strtol(str, nullptr, 10); }

int32_t strToInt32(const std::string& str) { return strToInt32(str.c_str()); }

int32_t strToInt32(const char* const str, int radix) { return strtol(str, 0, radix); }
int32_t strToInt32(const char* const str, int radix) { return strtol(str, nullptr, radix); }

uint32_t strToInt32u(const char* const str, int radix) { return static_cast<uint32_t>(strtoul(str, 0, radix)); }
uint32_t strToInt32u(const char* const str, int radix) { return static_cast<uint32_t>(strtoul(str, nullptr, radix)); }

int16_t strToInt16(const char* const str) { return (int16_t)strtol(str, 0, 10); }
int16_t strToInt16(const char* const str) { return (int16_t)strtol(str, nullptr, 10); }

uint16_t strToInt16u(const char* const str) { return (uint16_t)strtol(str, 0, 10); }
uint16_t strToInt16u(const char* const str) { return (uint16_t)strtol(str, nullptr, 10); }

int8_t strToInt8(const char* const str) { return (int8_t)strtol(str, 0, 10); }
int8_t strToInt8(const char* const str) { return (int8_t)strtol(str, nullptr, 10); }

uint8_t strToInt8u(const char* const str) { return (uint8_t)strtol(str, 0, 10); }
uint8_t strToInt8u(const char* const str) { return (uint8_t)strtol(str, nullptr, 10); }

double strToDouble(const char* const str) { return strtod(str, 0); }
double strToDouble(const char* const str) { return strtod(str, nullptr); }

float strToFloat(const char* const str) { return strtof(str, 0); }
float strToFloat(const char* const str) { return strtof(str, nullptr); }

bool strToBool(const char* const str)
{
Expand Down Expand Up @@ -464,7 +464,7 @@ char* strnstr(const char* s1, const char* s2, size_t len)
return (char*)s1;
s1++;
}
return NULL;
return nullptr;
}

uint32_t random32()
Expand Down
4 changes: 2 additions & 2 deletions tsMuxer/BufferedReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ struct ReaderData
m_allocSize(0),
m_readOffset(0)
{
m_nextBlock[0] = NULL;
m_nextBlock[1] = NULL;
m_nextBlock[0] = nullptr;
m_nextBlock[1] = nullptr;
}

virtual ~ReaderData()
Expand Down
2 changes: 1 addition & 1 deletion tsMuxer/aac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ uint8_t* AACCodec::findAacFrame(uint8_t* buffer, uint8_t* end)
else
curBuf++;
}
return 0;
return nullptr;
}

int AACCodec::getFrameSize(uint8_t* buffer) { return ((buffer[3] & 0x03) << 11) + (buffer[4] << 3) + (buffer[5] >> 5); }
Expand Down
2 changes: 1 addition & 1 deletion tsMuxer/abstractMuxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ AbstractMuxer::AbstractMuxer(MuxerManager* owner) : m_owner(owner)
{
m_interliaveBlockSize = 0;
m_sectorSize = 0;
m_fileFactory = 0;
m_fileFactory = nullptr;
}

void AbstractMuxer::setBlockMuxMode(int blockSize, int sectorSize)
Expand Down
6 changes: 3 additions & 3 deletions tsMuxer/ac3Codec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,8 @@ const std::string AC3Codec::getStreamInfo()

uint8_t *AC3Codec::findFrame(uint8_t *buffer, uint8_t *end)
{
if (buffer == 0)
return 0;
if (buffer == nullptr)
return nullptr;
uint8_t *curBuf = buffer;
while (curBuf < end - 1)
{
Expand All @@ -573,5 +573,5 @@ uint8_t *AC3Codec::findFrame(uint8_t *buffer, uint8_t *end)
else
curBuf++;
}
return 0;
return nullptr;
}
2 changes: 1 addition & 1 deletion tsMuxer/ac3StreamReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ int AC3StreamReader::getTSDescriptor(uint8_t* dstBuff, bool blurayMode, bool hdm
{
AC3Codec::setTestMode(true);
uint8_t* frame = findFrame(m_buffer, m_bufEnd);
if (frame == 0)
if (frame == nullptr)
return 0;
for (int i = 0; i < 2 && frame < m_bufEnd;)
{
Expand Down
8 changes: 4 additions & 4 deletions tsMuxer/blurayHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ bool writeBdMovieObjectData(const MuxerManager& muxer, AbstractOutputStream* fil

// ------------------------- BlurayHelper ---------------------------

BlurayHelper::BlurayHelper() : m_dt(), m_isoWriter(0) {}
BlurayHelper::BlurayHelper() : m_dt(), m_isoWriter(nullptr) {}

BlurayHelper::~BlurayHelper() { close(); }

Expand All @@ -276,7 +276,7 @@ void BlurayHelper::close()
{
LTRACE(LT_INFO, 2, "Finalize ISO disk");
delete m_isoWriter;
m_isoWriter = 0;
m_isoWriter = nullptr;
}
}

Expand Down Expand Up @@ -530,7 +530,7 @@ const PMTStreamInfo* streamByIndex(int index, const PIDListMap& pidList)
if (stream.m_codecReader->getStreamIndex() == index)
return &stream;
}
return 0;
return nullptr;
}

bool BlurayHelper::createMPLSFile(TSMuxer* mainMuxer, TSMuxer* subMuxer, int autoChapterLen,
Expand Down Expand Up @@ -704,7 +704,7 @@ AbstractOutputStream* BlurayHelper::createFile()
return new File();
}

bool BlurayHelper::isVirtualFS() const { return m_isoWriter != 0; }
bool BlurayHelper::isVirtualFS() const { return m_isoWriter != nullptr; }

void BlurayHelper::setVolumeLabel(const std::string& label)
{
Expand Down
6 changes: 3 additions & 3 deletions tsMuxer/bufferedFileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ bool FileReaderData::openStream()
LPVOID msgBuf = nullptr;
DWORD dw = GetLastError();

FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&msgBuf, 0, NULL);
FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, nullptr, dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&msgBuf, 0, nullptr);

string str((char*)msgBuf);
LTRACE(LT_ERROR, 0, str);
Expand All @@ -46,7 +46,7 @@ bool BufferedFileReader::openStream(uint32_t readerID, const char* streamName, i
{
auto data = (FileReaderData*)getReader(readerID);

if (data == 0)
if (data == nullptr)
{
LTRACE(LT_ERROR, 0, "Unknown readerID " << readerID);
return false;
Expand Down
8 changes: 4 additions & 4 deletions tsMuxer/bufferedReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ReaderData* BufferedReader::getReader(uint32_t readerID)
{
std::lock_guard<std::mutex> lock(m_readersMtx);
auto itr = m_readers.find(readerID);
return itr != m_readers.end() ? itr->second : 0;
return itr != m_readers.end() ? itr->second : nullptr;
}

bool BufferedReader::incSeek(uint32_t readerID, int64_t offset)
Expand Down Expand Up @@ -125,7 +125,7 @@ void BufferedReader::deleteReader(uint32_t readerID)

uint8_t* BufferedReader::readBlock(uint32_t readerID, uint32_t& readCnt, int& rez, bool* firstBlockVar)
{
ReaderData* data = 0;
ReaderData* data = nullptr;
{
std::lock_guard<std::mutex> lock(m_readersMtx);
auto itr = m_readers.find(readerID);
Expand All @@ -143,7 +143,7 @@ uint8_t* BufferedReader::readBlock(uint32_t readerID, uint32_t& readCnt, int& re
{
rez = UNKNOWN_READERID;
readCnt = 0;
return 0;
return nullptr;
}
}

Expand Down Expand Up @@ -172,7 +172,7 @@ void BufferedReader::terminate()
void BufferedReader::notify(uint32_t readerID, uint32_t dataReaded)
{
ReaderData* data = getReader(readerID);
if (data == 0)
if (data == nullptr)
return;
if (dataReaded >= m_prereadThreshold && !data->m_notified)
{
Expand Down
4 changes: 2 additions & 2 deletions tsMuxer/combinedH264Demuxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ CombinedH264Demuxer::CombinedH264Demuxer(const BufferedReaderManager& readManage
{
m_bufferedReader = (const_cast<BufferedReaderManager&>(m_readManager)).getReader(streamName);
m_readerID = m_bufferedReader->createReader(MAX_TMP_BUFFER_SIZE);
if (m_bufferedReader == 0)
if (m_bufferedReader == nullptr)
THROW(ERR_COMMON,
"TS demuxer can't accept reader because this reader does not support BufferedReader interface");
m_lastReadRez = 0;
Expand Down Expand Up @@ -248,7 +248,7 @@ void CombinedH264Demuxer::setFileIterator(FileNameIterator* itr)
auto br = dynamic_cast<BufferedFileReader*>(m_bufferedReader);
if (br)
br->setFileIterator(itr, m_readerID);
else if (itr != 0)
else if (itr != nullptr)
THROW(ERR_COMMON, "Can not set file iterator. Reader does not support bufferedReader interface.");
}

Expand Down
10 changes: 5 additions & 5 deletions tsMuxer/dtsStreamReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ using namespace std;
int DTSStreamReader::getTSDescriptor(uint8_t* dstBuff, bool blurayMode, bool hdmvDescriptors)
{
uint8_t* frame = findFrame(m_buffer, m_bufEnd);
if (frame == 0)
if (frame == nullptr)
return 0;
int skipBytes = 0;
int skipBeforeBytes = 0;
Expand Down Expand Up @@ -203,13 +203,13 @@ uint8_t* DTSStreamReader::findFrame(uint8_t* buff, uint8_t* end)
hdrType == NAVI_TBL || hdrType == TIMECODE || hdrType == DTSHDHDR)
{
if (hdrSize > (size_t)(end - buff))
return 0; // need more data
return nullptr; // need more data
buff += hdrSize;
}
else if (hdrType == AUPR_HDR)
{
if (buff + hdrSize > end)
return 0; // need more data
return nullptr; // need more data
// determine skipping frames amount
m_skippingSamples = (buff[35] << 8) + buff[36];
buff += hdrSize;
Expand Down Expand Up @@ -242,7 +242,7 @@ uint8_t* DTSStreamReader::findFrame(uint8_t* buff, uint8_t* end)
return p_buf;
}
}
return 0;
return nullptr;
}

for (uint8_t* p_buf = buff; p_buf < end - 4; p_buf++)
Expand Down Expand Up @@ -272,7 +272,7 @@ uint8_t* DTSStreamReader::findFrame(uint8_t* buff, uint8_t* end)
return p_buf;
}
}
return 0;
return nullptr;
}

int DTSStreamReader::decodeHdInfo(uint8_t* buff, uint8_t* end)
Expand Down
2 changes: 1 addition & 1 deletion tsMuxer/dvbSubStreamReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ int DVBSubStreamReader::intDecodeFrame(uint8_t* buff, uint8_t* end)

int pos, cmd, x1, y1, x2, y2, offset1, offset2, next_cmd_pos;
int cmd_pos, is_8bit = 0;
const uint8_t* yuv_palette = 0;
const uint8_t* yuv_palette = nullptr;
uint8_t colormap[4]{0}, alpha[256]{0};
int date;
int i;
Expand Down
Loading

0 comments on commit 2800bac

Please sign in to comment.