qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v5 5/9] qemu-log: support simple pid substitutio


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v5 5/9] qemu-log: support simple pid substitution in logfile
Date: Thu, 4 Feb 2016 16:32:20 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0

On 02/04/2016 03:26 PM, Richard Henderson wrote:
> On 02/05/2016 01:56 AM, Alex Bennée wrote:
>> +    if (g_strrstr(filename, "%d")) {
>> +        /* if we are going to format this we'd better validate first */
>> +        if (g_regex_match_simple("^[^%]+%d[^%]+$", filename, 0, 0)) {
> 
> Why g_strrstr instead of strstr?  There should be only one, so why look
> for the last?

For that matter, why use a heavyweight regex, when you can achieve the
same validation with the faster:

char *tmp = strchr(filename, '%');
if (tmp) {
    if (tmp[1] != 'd' || strchr(tmp + 2, '%')) {
        ...report invalid string
    }

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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