[FFmpeg-cvslog] tools: Check the return value of write().
Diego Biurrun
git at videolan.org
Tue May 17 05:19:50 CEST 2011
ffmpeg | branch: master | Diego Biurrun <diego at biurrun.de> | Sun May 15 18:34:11 2011 +0200| [d39facc783c270227e5b7c75db3dec406ed19018] | committer: Diego Biurrun
tools: Check the return value of write().
This fixes several warnings of the type:
warning: ignoring return value of ‘write’, declared with attribute warn_unused_result
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d39facc783c270227e5b7c75db3dec406ed19018
---
tools/cws2fws.c | 15 ++++++++++++---
tools/pktdumper.c | 6 +++++-
2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/tools/cws2fws.c b/tools/cws2fws.c
index aa7d690..5fa5147 100644
--- a/tools/cws2fws.c
+++ b/tools/cws2fws.c
@@ -69,7 +69,10 @@ int main(int argc, char *argv[])
// write out modified header
buf_in[0] = 'F';
- write(fd_out, &buf_in, 8);
+ if (write(fd_out, &buf_in, 8) < 8) {
+ perror("Error writing output file");
+ exit(1);
+ }
zstream.zalloc = NULL;
zstream.zfree = NULL;
@@ -101,7 +104,10 @@ int main(int argc, char *argv[])
zstream.avail_in, zstream.total_in, zstream.avail_out, zstream.total_out,
zstream.total_out-last_out);
- write(fd_out, &buf_out, zstream.total_out-last_out);
+ if (write(fd_out, &buf_out, zstream.total_out - last_out) < zstream.total_out - last_out) {
+ perror("Error writing output file");
+ exit(1);
+ }
i += len;
@@ -120,7 +126,10 @@ int main(int argc, char *argv[])
buf_in[3] = ((zstream.total_out+8) >> 24) & 0xff;
lseek(fd_out, 4, SEEK_SET);
- write(fd_out, &buf_in, 4);
+ if (write(fd_out, &buf_in, 4) < 4) {
+ perror("Error writing output file");
+ exit(1);
+ }
}
inflateEnd(&zstream);
diff --git a/tools/pktdumper.c b/tools/pktdumper.c
index 3ab39ee..80816d2 100644
--- a/tools/pktdumper.c
+++ b/tools/pktdumper.c
@@ -104,7 +104,11 @@ int main(int argc, char **argv)
//printf("open(\"%s\")\n", pktfilename);
if (!nowrite) {
fd = open(pktfilename, O_WRONLY|O_CREAT, 0644);
- write(fd, pkt.data, pkt.size);
+ err = write(fd, pkt.data, pkt.size);
+ if (err < 0) {
+ fprintf(stderr, "write: error %d\n", err);
+ return 1;
+ }
close(fd);
}
av_free_packet(&pkt);
More information about the ffmpeg-cvslog
mailing list