qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 0/3] Fix NetBSD build (don't build ivshmem tools


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH 0/3] Fix NetBSD build (don't build ivshmem tools)
Date: Thu, 13 Jul 2017 15:12:26 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1

On 07/13/2017 01:40 PM, Kamil Rytarowski wrote:

>> MALLOC_PERTURB_=${MALLOC_PERTURB_:-$((RANDOM % 255 + 1))} gtester -k 
>> --verbose -m=quick tests/check-qdict
>> sh: arith: syntax error: "RANDOM % 255 + 1"
>>
>> likely because we're using a bashism there.

Yes, assuming that $RANDOM exists is a bashism.

>>
> 
> This is an extension to a POSIX shell. We were lately adding it as an
> extension to our sh(1) in the distribution. Were also thinking about
> prompting POSIX to standarize it.
> 
> $ echo $((RANDOM % 255))
> 52
> 
> As of now, one portable solution is to parse /dev/urandom, or use a 3rd
> party tool like awk(1).

It's also portable (although less random) to do:

$(( ${RANDOM:-0} + 1))

(the whole idea of MALLOC_PERTURB_ only works on glibc anyways, so it
really doesn't matter what you set it to on other systems).

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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