qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 2/4] target-mips: add Unified Hosting Interface


From: Matthew Fortune
Subject: Re: [Qemu-devel] [PATCH 2/4] target-mips: add Unified Hosting Interface (UHI) support
Date: Mon, 2 Mar 2015 20:44:16 +0000

Leon Alrae <address@hidden> writes:
> On 01/03/2015 22:17, Matthew Fortune wrote:
> >> +    case UHI_plog:
> >> +        GET_TARGET_STRING(p, gpr[4]);
> >> +        p2 = strstr(p, "%d");
> >> +        if (p2) {
> >> +            int char_num = p2 - p;
> >> +            char *buf = g_malloc(char_num + 1);
> >> +            strncpy(buf, p, char_num);
> >> +            buf[char_num] = '\0';
> >> +            gpr[2] = printf("%s%d%s", buf, (int)gpr[5], p2 + 2);
> >> +            g_free(buf);
> >> +        } else {
> >> +            gpr[2] = printf("%s", p);
> >> +        }
> >
> > Is all this necessary vs just: printf(p, (int)gpr[5])? I guess you may
> > want to do the scan for %d and choose between that and just printf(p).
> 
> I don't think we should use p as a format string directly as it might
> contain more/different format specifiers. Presumably we would need
> additional logic for checking this and returning an error for such cases
> -- and this new implementation wouldn't be much simpler than current I
> believe.
> 
> Current implementation allows any string given by the guest to be
> printed out. If there are multiple format specifiers then only the first
> occurrence of %d will be replaced with the integer.

Good point. That makes sense.

Matthew



reply via email to

[Prev in Thread] Current Thread [Next in Thread]