Shawn Walker writes: > http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/cmd/fs.d/ufs/repquota/repquota.c#197 > 197 (void) fclose(vfstab); > > ...and one which seems a bit drawn out, but more like the "right" solution: > http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/cmd/devfsadm/devfsadm.c#5879 > 5879 if (fclose(fp) == EOF) { > 5880 err_print(FCLOSE_FAILED, file, strerror(errno)); > 5881 } > > http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/cmd/devfsadm/message.h#124 > 124 #define FCLOSE_FAILED gettext("fclose failed: %s: %s\n") > > What is the "preferred" solution?
It depends on the situation. For repquota.c, we had opened vfstab as read-only, so there's no reasonable way that closing this file can fail (it ought to be little more than close(2) and free(3C)), and nothing particularly useful we could do if it did fail. Ignoring any error here seems right to me. For ordinary files, it's only if the stream was opened for writing that there's a chance that fclose invokes fflush under the covers, and that there'd be a useful error to report. In the devfsadm.c case, I don't know what the author was trying to do. 'fp' here is also opened read-only, so there doesn't seem to be a reason to check for errors. That line of code came from: D 1.61 04/09/21 14:18:19 jbeck 62 61 00005/00019/08126 MRs: COMMENTS: 5100830 repeating close(2) or fclose(3c) on EINTR not a good idea ... so it looks like he was yanking out some more substantial brokenness. -- James Carlson, Solaris Networking <[EMAIL PROTECTED]> Sun Microsystems / 1 Network Drive 71.232W Vox +1 781 442 2084 MS UBUR02-212 / Burlington MA 01803-2757 42.496N Fax +1 781 442 1677 _______________________________________________ opensolaris-code mailing list opensolaris-code@opensolaris.org http://mail.opensolaris.org/mailman/listinfo/opensolaris-code