[Spice-devel] [PATCH spice-server 04/33] Avoids %m in formatting for Windows

Marc-André Lureau marcandre.lureau at gmail.com
Sat Dec 22 14:25:38 UTC 2018


Hi

On Sat, Dec 22, 2018 at 5:49 PM Frediano Ziglio <fziglio at redhat.com> wrote:
>
> >
> > On Fri, Dec 21, 2018 at 4:03 PM Frediano Ziglio <fziglio at redhat.com> wrote:
> > >
> > > Not supported.
> > >
> > > Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> > > --
> > > TODO find a better solution
> >
> > May be unnecessary with __USE_MINGW_ANSI_STDIO (to check)
> >
>
> Not sure but this surely would limit the compiler(s?) to MingW only.

Probably, I don't care much about other compilers. I don't think you
can compile qemu for windows without mingw either, fwiw

In any case, if you adopt this patch, it should run the same code
instead of 2 code paths.

>
> >
> > > ---
> > >  server/reds.c | 7 +++++++
> > >  1 file changed, 7 insertions(+)
> > >
> > > diff --git a/server/reds.c b/server/reds.c
> > > index aa3f8ca7..2874bd4c 100644
> > > --- a/server/reds.c
> > > +++ b/server/reds.c
> > > @@ -3582,7 +3582,14 @@ static const char* parse_next_video_codec(const char
> > > *codecs, char **encoder,
> > >      }
> > >      int n;
> > >      *encoder = *codec = NULL;
> > > +#ifndef _WIN32
> > >      if (sscanf(codecs, "%m[0-9a-zA-Z_]:%m[0-9a-zA-Z_]%n", encoder, codec,
> > >      &n) == 2) {
> > > +#else
> > > +    char encoder_buf[130], codec_buf[130];
> > > +    if (sscanf(codecs, "%128[0-9a-zA-Z_]:%128[0-9a-zA-Z_]%n", encoder_buf,
> > > codec_buf, &n) == 2) {
> > > +        *encoder = strdup(encoder_buf);
> > > +        *codec = strdup(codec_buf);
> > > +#endif
> > >          // this avoids accepting "encoder:codec" followed by garbage like
> > >          "$%*"
> > >          if (codecs[n] != ';' && codecs[n] != '\0') {
> > >              free(*codec);
>
> Frediano



-- 
Marc-André Lureau


More information about the Spice-devel mailing list