[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] linux-user: Let user specify random seed
From: |
Magnus Reftel |
Subject: |
Re: [Qemu-devel] [PATCH] linux-user: Let user specify random seed |
Date: |
Thu, 9 Oct 2014 21:10:32 +0200 |
Hi,
Thank you for your patience! I will send a third version.
On Thu, Oct 9, 2014 at 5:27 PM, Eric Blake <address@hidden> wrote:
> On 10/09/2014 02:36 AM, Magnus Reftel wrote:
>> + char* end;
> Style: we prefer:
> char *end;
Done.
>> + if (end==arg || *end!='\0' || seed > UINT_MAX) {
> Style: spaces around operators:
Done.
> Bug: strtoul() sometimes reports error via errno; the only safe way to
> use it is to first prime errno = 0, then do strtoul, then check if errno
> was changed.
>
> Reimplementation: util/cutils.c already provides parse_uint() that takes
> care of calling strtoul safely (hmm, that version only parses 64-bit
> numbers; maybe we should expand it to also parse 32-bit numbers?)
Solved both by switching to parse_uint.
>> + {"seed", "QEMU_RAND_SEED", true, handle_arg_randseed,
>> + "", "Seed for pseudo-random number generator"},
...
>> + if (getenv("QEMU_RAND_SEED")) {
>> + handle_arg_randseed(getenv("QEMU_RAND_SEED"));
>> + }
>
> Now that you have exactly one caller of the static function, it might
> make sense to just inline the body of that function here.
No, it may be called using the function pointer in the argument table, above.
Best Regards
Magnus reftel