Subject: nitpickey comment patch: libc/stdio/funopen.c
To: None <tech-userlevel@netbsd.org>
From: Bruce Korb <bkorb@veritas.com>
List: tech-userlevel
Date: 02/14/2004 12:09:03
This is mostly a mail test.  I'm re-implementing an "fmemopen"
'cuz I think it ought to get into POSIX.  So, I'm grubbing around
in this code....

Index: funopen.c
===================================================================
RCS file: /cvs/src/lib/libc/stdio/funopen.c,v
retrieving revision 1.6
diff -u -p -r1.6 funopen.c
--- funopen.c   2 Jun 2003 20:18:37 -0000       1.6
+++ funopen.c   14 Feb 2004 20:02:45 -0000
@@ -52,17 +54,18 @@ funopen(const void *cookie, int (*readfn
                        return (NULL);
                } else
                        flags = __SWR;          /* write only */
-       } else {
-               if (writefn == NULL)
-                       flags = __SRD;          /* read only */
-               else
-                       flags = __SRW;          /* read-write */
-       }
+
+       } else if (writefn == NULL)
+               flags = __SRD;          /* read only */
+
+       else
+               flags = __SRW;          /* read-write */
+
        if ((fp = __sfp()) == NULL)
                return (NULL);
        fp->_flags = flags;
        fp->_file = -1;
-       fp->_cookie = (void *)cookie;           /* SAFE: cookie not modified */
+       fp->_cookie = (void *)cookie;           /* SAFE: cookie not dereferenced */
        fp->_read = readfn;
        fp->_write = writefn;
        fp->_seek = seekfn;