From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46498) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a4rYB-0004aJ-9g for qemu-devel@nongnu.org; Fri, 04 Dec 2015 09:41:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a4rY6-0001PR-Vy for qemu-devel@nongnu.org; Fri, 04 Dec 2015 09:41:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53399) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a4rY6-0001Oy-QQ for qemu-devel@nongnu.org; Fri, 04 Dec 2015 09:41:26 -0500 References: <1448900541-19939-1-git-send-email-asmetanin@virtuozzo.com> <1448900541-19939-2-git-send-email-asmetanin@virtuozzo.com> <565EE292.7010004@redhat.com> <5661A44E.1040503@openvz.org> From: Paolo Bonzini Message-ID: <5661A610.5050401@redhat.com> Date: Fri, 4 Dec 2015 15:41:20 +0100 MIME-Version: 1.0 In-Reply-To: <5661A44E.1040503@openvz.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2 1/9] drivers/hv: replace enum hv_message_type by u32 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Denis V. Lunev" , Andrey Smetanin , kvm@vger.kernel.org, Vitaly Kuznetsov Cc: Gleb Natapov , Haiyang Zhang , "K. Y. Srinivasan" , Roman Kagan , qemu-devel@nongnu.org On 04/12/2015 15:33, Denis V. Lunev wrote: > On 12/02/2015 03:22 PM, Paolo Bonzini wrote: >> >> On 30/11/2015 17:22, Andrey Smetanin wrote: >>> enum hv_message_type inside struct hv_message, hv_post_message >>> is not size portable. Replace enum by u32. >> It's only non-portable inside structs. Okay to apply just these: >> >> @@ -172,7 +174,7 @@ union hv_message_flags { >> >> /* Define synthetic interrupt controller message header. */ >> struct hv_message_header { >> - u32 message_type; >> + enum hv_message_type message_type; >> u8 payload_size; >> union hv_message_flags message_flags; >> u8 reserved[2]; >> @@ -345,7 +347,7 @@ enum hv_call_code { >> struct hv_input_post_message { >> union hv_connection_id connectionid; >> u32 reserved; >> - u32 message_type; >> + enum hv_message_type message_type; >> u32 payload_size; >> u64 payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT]; >> }; >> >> ? >> >> Paolo > sorry for the delay. >=20 > Andrey is on vacation till the end of the week. >=20 > This could be not enough for some compilers as this exact > enum could be signed and unsigned depends upon the > implementation of the compiler and if it is signed we > can face signed/unsigned comparison in ifs. But why is that a problem? The issue is pre-existing anyway; the only one that can cause bugs when moving code to uapi/ (i.e. which means it can be used on non-x86 platforms) is the size of the enum, not the signedness. Paolo > Vitaly, by the way, this code is a bit rotten. The only caller of > hv_post_message calls it with message type exactly written > as "1", which is not defined in the enum. >=20 > /* > * vmbus_post_msg - Send a msg on the vmbus's message connection > */ > int vmbus_post_msg(void *buffer, size_t buflen) > { > ... > ret =3D hv_post_message(conn_id, 1, buffer, buflen); >=20 > Den