Coverity:
CID 739618 (#1 of 1): Unchecked return value (CHECKED_RETURN)
At (4): Calling function "fcntl(fd, 4, 1)" without checking return value.
This library function may fail and return an error code.
At (5): No check of the return value of "fcntl(fd, 4, 1)".
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
int fd = open(the_fifoname, O_WRONLY | O_NONBLOCK);
if (0 <= fd) {
/*
- * Change to blocking, otherwhise expect fprintf errors
+ * Change to blocking, otherwise expect fprintf errors
*/
- fcntl(fd, F_SETFL, O_WRONLY);
- fout = fdopen(fd, "w");
- if (0 != fout) {
- mapwrite_work(fout);
- fclose(fout);
- /* Give pipe reader cpu slot to detect EOF */
- usleep(1);
- } else {
+ if (fcntl(fd, F_SETFL, O_WRONLY) == -1) {
close(fd);
+ } else {
+ fout = fdopen(fd, "w");
+ if (0 != fout) {
+ mapwrite_work(fout);
+ fclose(fout);
+ /* Give pipe reader cpu slot to detect EOF */
+ usleep(1);
+ } else {
+ close(fd);
+ }
}
}
}