[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: |
Alex Bennée |
Subject: |
Re: [Qemu-devel] [PATCH v5 5/9] qemu-log: support simple pid substitution in logfile |
Date: |
Fri, 05 Feb 2016 13:34:53 +0000 |
User-agent: |
mu4e 0.9.17; emacs 25.0.90.1 |
Eric Blake <address@hidden> writes:
> 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?
Yeah, my fault for using the glib functions, I guess
g_strstr_len(filename, -1, "%d") would be the glib equivalent for
strstr.
> 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
> }
For option parsing I'm not too worried about speed. At least a regex
gives the explicit format we expect (for those that read regex). I guess
I can do it manually if preferred.
--
Alex Bennée
[Qemu-devel] [PATCH v5 7/9] qemu-log: dfilter-ise exec, out_asm, op and opt_op, Alex Bennée, 2016/02/04
[Qemu-devel] [PATCH v5 9/9] cputlb: modernise the debug support, Alex Bennée, 2016/02/04