From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.61]) by mx.groups.io with SMTP id smtpd.web10.7493.1593079832322647889 for ; Thu, 25 Jun 2020 03:10:32 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Cnl2o2x9; spf=pass (domain: redhat.com, ip: 205.139.110.61, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593079831; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kSQHyRGCS+GWFadp5SM3lO4whDHzmajUEvsCj03BXL4=; b=Cnl2o2x9y9eV6T1ZWrbjod5BgP+zfzCqzP41MGRCFEvO8b6G6z4Cx/8bNfY7RZd7iQa1J1 n1IMuA9Hb35EYdV6SdTL6wSnQVvs9RqbWA3unbRXN0/NvU8S0B8o+1XdFM2siF4k1yzIT6 M1bN874uSkuPulQKutkAZUPfiyH+H/Y= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-182-TwvJiSTpMrqmK1DtKaZCAg-1; Thu, 25 Jun 2020 06:10:28 -0400 X-MC-Unique: TwvJiSTpMrqmK1DtKaZCAg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 00611107ACCA; Thu, 25 Jun 2020 10:10:27 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-115-16.ams2.redhat.com [10.36.115.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE00010016DA; Thu, 25 Jun 2020 10:10:25 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH v1 1/1] ArmPkg/ArmMmuLibb: Fix implicit cast To: devel@edk2.groups.io, pierre.gondois@arm.com Cc: leif@nuviainc.com, ard.biesheuvel@arm.com, nd@arm.com References: <20200625075945.136532-1-pierre.gondois@arm.com> From: "Laszlo Ersek" Message-ID: <2f3d2e91-50c9-3a6e-41ab-d4916b5ab9e3@redhat.com> Date: Thu, 25 Jun 2020 12:10:24 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20200625075945.136532-1-pierre.gondois@arm.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 06/25/20 09:59, PierreGondois wrote: > From: Pierre Gondois > > While building with the following command line: > build -b DEBUG -a AARCH64 -t VS2017 -p > edk2\MdeModulePkg\MdeModulePkg.dsc > > A missing cast triggers the following warning, > then triggering an error: > edk2/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c(652): > warning C4152: nonstandard extension, function/data pointer > conversion in expression > > This patch adds a cast, removing the warning. > > Signed-off-by: Pierre Gondois > --- > > The changes can be seen at: https://github.com/PierreARM/edk2/commits/831_Fix_implicit_cast_v1 > > Notes: > v1: > - Add (void*) cast. [Pierre] > > ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c > index 222ff817956feb738325fc78fbaf064de98802a9..7df7c75d4a571403209e4fee0f0a06ed6e3513fa 100644 > --- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c > +++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c > @@ -649,7 +649,7 @@ ArmMmuBaseLibConstructor ( > // The ArmReplaceLiveTranslationEntry () helper function may be invoked > // with the MMU off so we have to ensure that it gets cleaned to the PoC > // > - WriteBackDataCacheRange (ArmReplaceLiveTranslationEntry, > + WriteBackDataCacheRange ((VOID*)ArmReplaceLiveTranslationEntry, > ArmReplaceLiveTranslationEntrySize); > > return RETURN_SUCCESS; > Converting a pointer-to-function to a pointer-to-void (or pointer-to-object, or pointer-to-incomplete-type) is not defined by the C standard. So if we want to fix this warning cleanly, we should convert first to UINTN, and then to (VOID*). Because (from C99, 6.3.2.3 Pointers): 6 Any pointer type may be converted to an integer type. Except as previously specified, the result is implementation-defined. If the result cannot be represented in the integer type, the behavior is undefined. The result need not be in the range of values of any integer type. and 5 An integer may be converted to any pointer type. Except as previously specified, the result is implementation-defined, might not be correctly aligned, might not point to an entity of the referenced type, and might be a trap representation. [56] Footnote 56: The mapping functions for converting a pointer to an integer or an integer to a pointer are intended to be consistent with the addressing structure of the execution environment. So when we write (VOID*)(UINTN)ArmReplaceLiveTranslationEntry, then we get a pass at least as "implementation-defined". Thanks, Laszlo