You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Jeff Trawick <tr...@attglobal.net> on 2001/07/23 18:23:05 UTC

[PATCH] apr_file_t->fname for a pipe

apr_pipe_create() sets apr_file_t->fname to

  apr_pstrdup(p, "PIPE")

  (why not just "PIPE")

or   

  "\0" 

  (why not just "")

or

  ""

depending on the function.

Why not leave it NULL?  I don't see any code to retrieve it.
Presumably if somebody is looking at the structure in memory they'll
realize that NULL is okay since it is a pipe.

OS/2 seems to have a valid name so that code is unaffected.

Index: file_io/unix/pipe.c
===================================================================
RCS file: /home/cvspublic/apr/file_io/unix/pipe.c,v
retrieving revision 1.46
diff -u -r1.46 pipe.c
--- file_io/unix/pipe.c	2001/02/16 04:15:37	1.46
+++ file_io/unix/pipe.c	2001/07/23 16:23:11
@@ -166,7 +166,7 @@
     (*in)->cntxt = cont;
     (*in)->filedes = filedes[0];
     (*in)->pipe = 1;
-    (*in)->fname = apr_pstrdup(cont, "PIPE");
+    (*in)->fname = NULL;
     (*in)->buffered = 0;
     (*in)->blocking = BLK_ON;
     (*in)->timeout = -1;
@@ -179,7 +179,7 @@
     (*out)->cntxt = cont;
     (*out)->filedes = filedes[1];
     (*out)->pipe = 1;
-    (*out)->fname = apr_pstrdup(cont, "PIPE");
+    (*out)->fname = NULL;
     (*out)->buffered = 0;
     (*out)->blocking = BLK_ON;
     (*out)->timeout = -1;
Index: file_io/win32/pipe.c
===================================================================
RCS file: /home/cvspublic/apr/file_io/win32/pipe.c,v
retrieving revision 1.37
diff -u -r1.37 pipe.c
--- file_io/win32/pipe.c	2001/06/06 16:04:54	1.37
+++ file_io/win32/pipe.c	2001/07/23 16:23:11
@@ -91,7 +91,7 @@
 
     (*in) = (apr_file_t *)apr_pcalloc(p, sizeof(apr_file_t));
     (*in)->cntxt = p;
-    (*in)->fname = "\0"; // What was this??? : apr_pstrdup(p, "PIPE"); */
+    (*in)->fname = NULL;
     (*in)->pipe = 1;
     (*in)->timeout = -1;
     (*in)->ungetchar = -1;
@@ -103,7 +103,7 @@
 
     (*out) = (apr_file_t *)apr_pcalloc(p, sizeof(apr_file_t));
     (*out)->cntxt = p;
-    (*in)->fname = "\0"; // What was this??? : apr_pstrdup(p, "PIPE"); */
+    (*in)->fname = NULL;
     (*out)->pipe = 1;
     (*out)->timeout = -1;
     (*out)->ungetchar = -1;
@@ -161,7 +161,7 @@
 
     (*in) = (apr_file_t *)apr_pcalloc(p, sizeof(apr_file_t));
     (*in)->cntxt = p;
-    (*in)->fname = ""; // What was this??? : apr_pstrdup(p, "PIPE"); */
+    (*in)->fname = NULL;
     (*in)->pipe = 1;
     (*in)->timeout = -1;
     (*in)->ungetchar = -1;
@@ -174,7 +174,7 @@
 
     (*out) = (apr_file_t *)apr_pcalloc(p, sizeof(apr_file_t));
     (*out)->cntxt = p;
-    (*out)->fname = ""; // What was this??? : apr_pstrdup(p, "PIPE"); */
+    (*out)->fname = NULL;
     (*out)->pipe = 1;
     (*out)->timeout = -1;
     (*out)->ungetchar = -1;

-- 
Jeff Trawick | trawick@attglobal.net | PGP public key at web site:
       http://www.geocities.com/SiliconValley/Park/9289/
             Born in Roswell... married an alien...

Re: [PATCH] apr_file_t->fname for a pipe

Posted by Jeff Trawick <tr...@attglobal.net>.
(repeating the msg, Bill, since I inadvertently sent it direct to you
the first time)

"William A. Rowe, Jr." <wr...@rowe-clan.net> writes:

> From: "Jeff Trawick" <tr...@attglobal.net>
> Sent: Monday, July 23, 2001 11:23 AM
> ;dev
> 
> > apr_pipe_create() sets apr_file_t->fname to
> > 
> >   apr_pstrdup(p, "PIPE")
> > 
> >   (why not just "")
> > 
> > Why not leave it NULL?  I don't see any code to retrieve it.
> > Presumably if somebody is looking at the structure in memory they'll
> > realize that NULL is okay since it is a pipe.
> 
> I made this change to the win32 code some time back.  No adverse affects :)
> Feel free to just port that change forward, it's silly to put a string
> identifier that is so out-of-context and invalid.

but why port the "" forward?  why shouldn't it be NULL everywhere?

-- 
Jeff Trawick | trawick@attglobal.net | PGP public key at web site:
       http://www.geocities.com/SiliconValley/Park/9289/
             Born in Roswell... married an alien...

Re: [PATCH] apr_file_t->fname for a pipe

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
From: "Jeff Trawick" <tr...@attglobal.net>
Sent: Monday, July 23, 2001 12:07 PM


> "William A. Rowe, Jr." <wr...@rowe-clan.net> writes:
> 
> > From: "Jeff Trawick" <tr...@attglobal.net>
> > Sent: Monday, July 23, 2001 11:23 AM
> > ;dev
> > 
> > > apr_pipe_create() sets apr_file_t->fname to
> > > 
> > >   apr_pstrdup(p, "PIPE")
> > > 
> > >   (why not just "")
> > > 
> > > Why not leave it NULL?  I don't see any code to retrieve it.
> > > Presumably if somebody is looking at the structure in memory they'll
> > > realize that NULL is okay since it is a pipe.
> > 
> > I made this change to the win32 code some time back.  No adverse affects :)
> > Feel free to just port that change forward, it's silly to put a string
> > identifier that is so out-of-context and invalid.
> 
> Why did you make it "" instead of NULL?
> 
> I don't see any reason why it shouldn't be NULL.

Because it could cause a segfault if the user doesn't expect to receive a ...



... uh, ok, make them all NULL :)



Re: [PATCH] apr_file_t->fname for a pipe

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
From: "Jeff Trawick" <tr...@attglobal.net>
Sent: Monday, July 23, 2001 11:23 AM
;dev

> apr_pipe_create() sets apr_file_t->fname to
> 
>   apr_pstrdup(p, "PIPE")
> 
>   (why not just "")
> 
> Why not leave it NULL?  I don't see any code to retrieve it.
> Presumably if somebody is looking at the structure in memory they'll
> realize that NULL is okay since it is a pipe.

I made this change to the win32 code some time back.  No adverse affects :)
Feel free to just port that change forward, it's silly to put a string
identifier that is so out-of-context and invalid.

Bill