From: Date: Sun, 8 Dec 2013 23:21:29 +0000 (-0800) Subject: more error check X-Git-Url: https://diplodocus.org/git/flac-archive/commitdiff_plain/dc56eee9c5ea64152683f20cab5be14b8a13c8a5?ds=sidebyside;hp=3e5ac1b35b5e96d2e2e0570f163493fca75a00e3 more error check --- diff --git a/apic-read.cc b/apic-read.cc index 194e340..324450e 100644 --- a/apic-read.cc +++ b/apic-read.cc @@ -40,18 +40,23 @@ main(int argc, char **argv) AttachedPictureFrame *frame = (AttachedPictureFrame *)(*it); TagLib::ByteVector data = frame->picture(); int fd = open(argv[2], O_CREAT | O_WRONLY); + if (fd < 0) { + perror("open"); + return 2; + } ssize_t size = data.size(); ssize_t status = write(fd, data.data(), size); if (status < 0) { perror("write"); - return 2; + return 3; } if (status != size) { fprintf(stderr, "wrote only %d bytes out of %d\n", status, size); - return 3; + return 4; } if (close(fd) < 0) { perror("close"); + return 5; } }