[Mplayer-cvslog] CVS: main/osdep vbelib.c,1.24,1.25

D Richard Felker III dalias at aerifal.cx
Thu Sep 16 18:05:09 CEST 2004


On Thu, Sep 16, 2004 at 10:12:08AM +0200, Sascha Sommer CVS wrote:
> CVS change done by Sascha Sommer CVS
> 
> Update of /cvsroot/mplayer/main/osdep
> In directory mail:/var2/tmp/cvs-serv17493/osdep
> 
> Modified Files:
> 	vbelib.c 
> Log Message:
> stdout and stderr are macros --- you can't assign to them. Assignment doesn't make sense anyway, because freopen will always return the same FILE * structure that it got in parameter. patch by Mikulas Patocka <mikulas at artax.karlin.mff.cuni.cz>
> 
> Index: vbelib.c
> ===================================================================
> RCS file: /cvsroot/mplayer/main/osdep/vbelib.c,v
> retrieving revision 1.24
> retrieving revision 1.25
> diff -u -r1.24 -r1.25
> --- vbelib.c	25 Jun 2004 17:29:18 -0000	1.24
> +++ vbelib.c	16 Sep 2004 08:12:05 -0000	1.25
> @@ -111,8 +111,8 @@
>    my_stderr = fopen(ttyname(fileno(stderr)),"w");
>    __set_cursor_type(stdout,0);
>  /*if(isatty(fileno(stdin ))) stdin =freopen("/dev/null","r",stdin );*/
> -  if(isatty(fileno(stdout))) stdout=freopen("/dev/null","w",stdout);
> -  if(isatty(fileno(stderr))) stderr=freopen("/dev/null","w",stderr);
> +  if(isatty(fileno(stdout))) freopen("/dev/null","w",stdout);
> +  if(isatty(fileno(stderr))) freopen("/dev/null","w",stderr);
>  }

use of freopen is incorrect anyway. it can use the wrong file
descriptor numbers and break everything if there's any code that does
writes via fds. (note: this includes running any child process!)
instead you need to use open() and dup2() to put things on the right
fd's. gcc should issue warnings about freopen, imo (similar to the
gets warning).

rich




More information about the MPlayer-cvslog mailing list