summaryrefslogtreecommitdiff
path: root/dvbapi.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2002-03-23 16:17:39 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2002-03-23 16:17:39 +0100
commitc751c195c1a57e6738d402f5b4d42357b8e580d0 (patch)
treede7c66bb18cc0772d36fa9642ed7afc215f4538c /dvbapi.c
parentef91debc4d181be5c34207cf32d127b3058f4697 (diff)
downloadvdr-c751c195c1a57e6738d402f5b4d42357b8e580d0.tar.gz
vdr-c751c195c1a57e6738d402f5b4d42357b8e580d0.tar.bz2
Improved usage of 'safe_write()'
Diffstat (limited to 'dvbapi.c')
-rw-r--r--dvbapi.c37
1 files changed, 15 insertions, 22 deletions
diff --git a/dvbapi.c b/dvbapi.c
index 9b96d31d..973ad54b 100644
--- a/dvbapi.c
+++ b/dvbapi.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: dvbapi.c 1.164 2002/03/23 14:14:03 kls Exp $
+ * $Id: dvbapi.c 1.165 2002/03/23 16:15:00 kls Exp $
*/
#include "dvbapi.h"
@@ -98,7 +98,7 @@ class cIndexFile {
private:
struct tIndex { int offset; uchar type; uchar number; short reserved; };
int f;
- char *fileName, *pFileExt;
+ char *fileName;
int size, last;
tIndex *index;
cResumeFile resumeFile;
@@ -120,7 +120,7 @@ cIndexFile::cIndexFile(const char *FileName, bool Record)
:resumeFile(FileName)
{
f = -1;
- fileName = pFileExt = NULL;
+ fileName = NULL;
size = 0;
last = -1;
index = NULL;
@@ -128,7 +128,7 @@ cIndexFile::cIndexFile(const char *FileName, bool Record)
fileName = new char[strlen(FileName) + strlen(INDEXFILESUFFIX) + 1];
if (fileName) {
strcpy(fileName, FileName);
- pFileExt = fileName + strlen(fileName);
+ char *pFileExt = fileName + strlen(fileName);
strcpy(pFileExt, INDEXFILESUFFIX);
int delta = 0;
if (access(fileName, R_OK) == 0) {
@@ -177,8 +177,6 @@ cIndexFile::cIndexFile(const char *FileName, bool Record)
}
else
LOG_ERROR_STR(fileName);
- delete fileName;
- fileName = pFileExt = NULL;
}
}
else
@@ -223,14 +221,14 @@ bool cIndexFile::CatchUp(int Index)
last = newLast;
}
else
- LOG_ERROR;
+ LOG_ERROR_STR(fileName);
}
else
esyslog(LOG_ERR, "ERROR: can't realloc() index");
}
}
else
- LOG_ERROR;
+ LOG_ERROR_STR(fileName);
if (Index >= last)
sleep(1);
else
@@ -244,8 +242,8 @@ bool cIndexFile::Write(uchar PictureType, uchar FileNumber, int FileOffset)
{
if (f >= 0) {
tIndex i = { FileOffset, PictureType, FileNumber, 0 };
- if (safe_write(f, &i, sizeof(i)) != sizeof(i)) {
- esyslog(LOG_ERR, "ERROR: can't write to index file");
+ if (safe_write(f, &i, sizeof(i)) < 0) {
+ LOG_ERROR_STR(fileName);
close(f);
f = -1;
return false;
@@ -579,17 +577,12 @@ void cRecordBuffer::Output(void)
if (NextFile()) {
if (index && pictureType != NO_PICTURE)
index->Write(pictureType, fileName.Number(), fileSize);
- while (Result > 0) {
- int w = safe_write(recordFile, p, Result);
- if (w < 0) {
- LOG_ERROR_STR(fileName.Name());
- recording = false;
- return;
- }
- p += w;
- Result -= w;
- fileSize += w;
- }
+ if (safe_write(recordFile, p, Result) < 0) {
+ LOG_ERROR_STR(fileName.Name());
+ recording = false;
+ return;
+ }
+ fileSize += Result;
}
else
break;
@@ -1557,7 +1550,7 @@ void cCuttingBuffer::Action(void)
}
LastIFrame = 0;
}
- if (safe_write(toFile, buffer, Length) != Length) {
+ if (safe_write(toFile, buffer, Length) < 0) {
error = "safe_write";
break;
}