Skip to content

Commit

Permalink
tidy: Fix a couple of error checks on calls to posix_fadvise.
Browse files Browse the repository at this point in the history
The clang-tidy "posix return" checker pointed out a couple of places
where the return value of a function call is incorrectly tested for an
error.  The test is for a negative number, but the function returns
zero for success and a positive number on error.  Change these test
check for a non-zero value instead of a negative value.

https://clang.llvm.org/extra/clang-tidy/checks/bugprone-posix-return.html
  • Loading branch information
linuxdude42 committed Nov 23, 2019
1 parent 7c2b4b3 commit 20af35a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mythtv/libs/libmythtv/fileringbuffer.cpp
Expand Up @@ -258,14 +258,14 @@ bool FileRingBuffer::OpenFile(const QString &lfilename, uint retry_ms)
{
#ifndef _MSC_VER
if (posix_fadvise(m_fd2, 0, 0,
POSIX_FADV_SEQUENTIAL) < 0)
POSIX_FADV_SEQUENTIAL) != 0)
{
LOG(VB_FILE, LOG_DEBUG, LOC +
QString("OpenFile(): fadvise sequential "
"failed: ") + ENO);
}
if (posix_fadvise(m_fd2, 0, 128*1024,
POSIX_FADV_WILLNEED) < 0)
POSIX_FADV_WILLNEED) != 0)
{
LOG(VB_FILE, LOG_DEBUG, LOC +
QString("OpenFile(): fadvise willneed "
Expand Down Expand Up @@ -712,7 +712,7 @@ long long FileRingBuffer::SeekInternal(long long pos, int whence)
ret = lseek64(m_fd2, m_internalReadPos, SEEK_SET);
#ifndef _MSC_VER
if (posix_fadvise(m_fd2, m_internalReadPos,
128*1024, POSIX_FADV_WILLNEED) < 0)
128*1024, POSIX_FADV_WILLNEED) != 0)
{
LOG(VB_FILE, LOG_DEBUG, LOC +
QString("Seek(): fadvise willneed "
Expand Down

0 comments on commit 20af35a

Please sign in to comment.