Skip to content

Commit

Permalink
Check the return value from posix_fadvise
Browse files Browse the repository at this point in the history
Static analysis determined that the return value
from posix_fadvise was not checked.  Check the
return, and log if failed (only debug level
logging, since fadvise should never fail in the
first place, and if it does fail it should not
matter (it is, after all, only a hint) but if
debugging, the failure might tell one something).

Fixes coverity 746748 and 746747

Fixes #11612.

Signed-off-by: Paul Harrison <pharrison@mythtv.org>
  • Loading branch information
garybuhrmaster authored and Paul Harrison committed Jul 1, 2013
1 parent 14bb408 commit 351c36a
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions mythtv/libs/libmythtv/fileringbuffer.cpp
Expand Up @@ -248,8 +248,20 @@ bool FileRingBuffer::OpenFile(const QString &lfilename, uint retry_ms)
{
if (0 == lseek(fd2, 0, SEEK_SET))
{
posix_fadvise(fd2, 0, 0, POSIX_FADV_SEQUENTIAL);
posix_fadvise(fd2, 0, 128*1024, POSIX_FADV_WILLNEED);
if (posix_fadvise(fd2, 0, 0,
POSIX_FADV_SEQUENTIAL) < 0)
{
LOG(VB_FILE, LOG_DEBUG, LOC +
QString("OpenFile(): fadvise sequential "
"failed: ") + ENO);
}
if (posix_fadvise(fd2, 0, 128*1024,
POSIX_FADV_WILLNEED) < 0)
{
LOG(VB_FILE, LOG_DEBUG, LOC +
QString("OpenFile(): fadvise willneed "
"failed: ") + ENO);
}
lasterror = 0;
break;
}
Expand Down Expand Up @@ -627,8 +639,13 @@ long long FileRingBuffer::Seek(long long pos, int whence, bool has_lock)
else
{
ret = lseek64(fd2, internalreadpos, SEEK_SET);
posix_fadvise(fd2, internalreadpos,
128*1024, POSIX_FADV_WILLNEED);
if (posix_fadvise(fd2, internalreadpos,
128*1024, POSIX_FADV_WILLNEED) < 0)
{
LOG(VB_FILE, LOG_DEBUG, LOC +
QString("Seek(): fadvise willneed "
"failed: ") + ENO);
}
}
LOG(VB_FILE, LOG_INFO, LOC +
QString("Seek to %1 from ignore pos %2 returned %3")
Expand Down

0 comments on commit 351c36a

Please sign in to comment.