[Spice-devel] [PATCH spice-server 20/33] replay: Force binary mode on input on Windows

Frediano Ziglio fziglio at redhat.com
Sat Dec 22 14:33:00 UTC 2018


> 
> On Fri, Dec 21, 2018 at 4:04 PM Frediano Ziglio <fziglio at redhat.com> wrote:
> >
> > If input contains the binary record we can't have it modified
> > during read.
> >
> > Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> 
> Or the more portable
> freopen(NULL, "rb", stdin);?
> 
> anyway
> Reviewed-by: Marc-André Lureau <marcandre.lureau at redhat.com>
> 

Unfortunately is not supported under Windows, at least according to
documentation. g_freopen suffers the same issue.
Also usually MingW uses an old CRT library which for compatibility
does not support much C99.

> 
> > ---
> >  server/tests/replay.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/server/tests/replay.c b/server/tests/replay.c
> > index cbb1c195..c8e10d0a 100644
> > --- a/server/tests/replay.c
> > +++ b/server/tests/replay.c
> > @@ -392,6 +392,9 @@ int main(int argc, char **argv)
> >
> >      if (strncmp(file[0], "-", 1) == 0) {
> >          fd = stdin;
> > +#ifdef _WIN32
> > +        _setmode(fileno(fd), _O_BINARY);
> > +#endif
> >      } else {
> >          fd = fopen(file[0], "r");
> >      }

Frediano


More information about the Spice-devel mailing list