qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] linux-user: fix convertion of flock/flock64 l_t


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH] linux-user: fix convertion of flock/flock64 l_type field
Date: Tue, 8 May 2018 13:55:22 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0

On 05/08/2018 12:08 PM, Max Filippov wrote:
On Tue, May 8, 2018 at 9:36 AM, Laurent Vivier <address@hidden> wrote:

In the subject, s/convertion/conversion/

As l_type values (F_RDLCK, F_WRLCK, F_UNLCK, F_EXLCK, F_SHLCK)
are not bitmasks, we can't use target_to_host_bitmask() and
host_to_target_bitmask() to convert them.

Introduce target_to_host_flock() and host_to_target_flock()
to convert values between host and target.


+static unsigned int host_to_target_flock(unsigned int type)
+{
+    switch (type) {
+#define TRANSTBL_CONVERT(a) case a: return TARGET_##a;
+    TRANSTBL_CONVERT(F_RDLCK)
+    TRANSTBL_CONVERT(F_WRLCK)
+    TRANSTBL_CONVERT(F_UNLCK)
+    TRANSTBL_CONVERT(F_EXLCK)
+    TRANSTBL_CONVERT(F_SHLCK)
+#undef  TRANSTBL_CONVERT
+    }
+    return type;
+}


There's a duplication. Wouldn't it be better if it was done like the following:

#define FLOCK_TRANSTBL \
     switch (type) {
     TRANSTBL_CONVERT(F_RDLCK) \

If you do this, I'd lean towards omitting the trailing ; from TRANSTBL_CONVERT() and sticking it in FLOCK_TRANSTBL instead (it looks weird to see a statement-like macro called without a ';').

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



reply via email to

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