From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id B928074003A for ; Wed, 7 Feb 2024 19:59:23 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=lhR6Qk7W1c9XIym8U60B/zIYd8fgzBMEoT7f0HVabgo=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1707335962; v=1; b=cLzRxQtYZ3b28lmlNwhZMXZ35lC3aHbdvsTXH7qfP+IxfE1Mosv50ZPcr4wesWQ06MzVxPBH j8sZM8H7Sdbpm75l7wc03iE9faIU6q0zmhBRlUOVhsdwb7w8nmn2n7hC7D8eMksLh95vNijoCqo 2oL3u5g1FhKyGrnHMKrj1qnc= X-Received: by 127.0.0.2 with SMTP id orr4YY7687511xhcPVtIfwlm; Wed, 07 Feb 2024 11:59:22 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web10.8143.1707335961306839477 for ; Wed, 07 Feb 2024 11:59:21 -0800 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-608-kjYTA01TOVuPYmH2RhASlQ-1; Wed, 07 Feb 2024 14:59:18 -0500 X-MC-Unique: kjYTA01TOVuPYmH2RhASlQ-1 X-Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3E64E85A599; Wed, 7 Feb 2024 19:59:17 +0000 (UTC) X-Received: from [10.39.195.126] (unknown [10.39.195.126]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AFDC17595; Wed, 7 Feb 2024 19:59:15 +0000 (UTC) Message-ID: <017b4577-62cb-6f94-be2f-f54cdc98494d@redhat.com> Date: Wed, 7 Feb 2024 20:59:14 +0100 MIME-Version: 1.0 Subject: Re: [edk2-devel] [edk2 Patch 1/1] EmbeddedPkg: Fix compiler errors due to implicit conversions To: Jayaprakash N , devel@edk2.groups.io Cc: Rebecca Cran , Michael D Kinney , Leif Lindholm , Ard Biesheuvel , Abner Chang References: <20240206162311.1321-1-n.jayaprakash@intel.com> <20240206162311.1321-2-n.jayaprakash@intel.com> From: "Laszlo Ersek" In-Reply-To: <20240206162311.1321-2-n.jayaprakash@intel.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: SqQ7OSacAiQPIoMLK9cE7CWLx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=cLzRxQtY; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=redhat.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io On 2/6/24 17:23, Jayaprakash N wrote: > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4669 >=20 > This commit fixes compilation issues reported through BZ4669. > There were several compilation errors due to implicit type > conversions in EmbeddedPkg. Fixed all the issues with the > correct usage of explicit type conversions based on the > context. >=20 > Cc: Rebecca Cran > Cc: Michael D Kinney > Cc: Laszlo Ersek > Cc: Leif Lindholm > Cc: Ard Biesheuvel > Cc: Abner Chang > Cc: Jayaprakash N > Signed-off-by: Jayaprakash N > --- > EmbeddedPkg/GdbStub/X64/Processor.c | 36 +++++++++---------- > EmbeddedPkg/Include/libfdt_env.h | 8 ++--- > EmbeddedPkg/Library/FdtLib/fdt.c | 9 ++--- > EmbeddedPkg/Library/FdtLib/fdt_overlay.c | 20 +++++------ > EmbeddedPkg/Library/FdtLib/fdt_ro.c | 32 ++++++++--------- > EmbeddedPkg/Library/FdtLib/fdt_rw.c | 24 ++++++------- > EmbeddedPkg/Library/FdtLib/fdt_strerror.c | 2 +- > EmbeddedPkg/Library/FdtLib/fdt_strtoul.c | 2 +- > EmbeddedPkg/Library/FdtLib/fdt_sw.c | 10 +++--- > EmbeddedPkg/Library/FdtLib/fdt_wip.c | 4 +-- > .../MemoryAllocationLib.c | 2 +- > EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c | 8 ++--- > .../Universal/MmcDxe/MmcIdentification.c | 22 ++++++------ > 13 files changed, 90 insertions(+), 89 deletions(-) This patch does way too many things at once. Please, minimally, split it into multiple patches, at module boundaries. Second, I'm unsure if edk2 considers FdtLib a completely detached fork of libfdt, at this point. If so, then fixing the warnings in the edk2 tree is valid (but should still be likely structured with finer granularity). If not (i.e., if we still intend to update FdtLib to more recent libfdt versions in the future), then these fixes don't belong in edk2 (we'd have to redo them after every update); they should be upstreamed to libfdt. Laszlo >=20 > diff --git a/EmbeddedPkg/GdbStub/X64/Processor.c b/EmbeddedPkg/GdbStub/X6= 4/Processor.c > index 4ff79abe42..b03d15938c 100644 > --- a/EmbeddedPkg/GdbStub/X64/Processor.c > +++ b/EmbeddedPkg/GdbStub/X64/Processor.c > @@ -599,31 +599,31 @@ EnableDebugRegister ( > Dr7.UintN =3D SystemContext.SystemContextIa32->Dr7; > =20 > if (Register =3D=3D 0) { > - SystemContext.SystemContextIa32->Dr0 =3D Address; > + SystemContext.SystemContextIa32->Dr0 =3D (UINT32)Address; > Dr7.Bits.G0 =3D 1; > - Dr7.Bits.RW0 =3D Type; > - Dr7.Bits.LEN0 =3D Length; > + Dr7.Bits.RW0 =3D (UINT32)Type; > + Dr7.Bits.LEN0 =3D (UINT32)Length; > } else if (Register =3D=3D 1) { > - SystemContext.SystemContextIa32->Dr1 =3D Address; > + SystemContext.SystemContextIa32->Dr1 =3D (UINT32)Address; > Dr7.Bits.G1 =3D 1; > - Dr7.Bits.RW1 =3D Type; > - Dr7.Bits.LEN1 =3D Length; > + Dr7.Bits.RW1 =3D (UINT32)Type; > + Dr7.Bits.LEN1 =3D (UINT32)Length; > } else if (Register =3D=3D 2) { > - SystemContext.SystemContextIa32->Dr2 =3D Address; > + SystemContext.SystemContextIa32->Dr2 =3D (UINT32)Address; > Dr7.Bits.G2 =3D 1; > - Dr7.Bits.RW2 =3D Type; > - Dr7.Bits.LEN2 =3D Length; > + Dr7.Bits.RW2 =3D (UINT32)Type; > + Dr7.Bits.LEN2 =3D (UINT32)Length; > } else if (Register =3D=3D 3) { > - SystemContext.SystemContextIa32->Dr3 =3D Address; > + SystemContext.SystemContextIa32->Dr3 =3D (UINT32)Address; > Dr7.Bits.G3 =3D 1; > - Dr7.Bits.RW3 =3D Type; > - Dr7.Bits.LEN3 =3D Length; > + Dr7.Bits.RW3 =3D (UINT32)Type; > + Dr7.Bits.LEN3 =3D (UINT32)Length; > } else { > return EFI_INVALID_PARAMETER; > } > =20 > // Update Dr7 with appropriate Gn, RWn and LENn bits > - SystemContext.SystemContextIa32->Dr7 =3D Dr7.UintN; > + SystemContext.SystemContextIa32->Dr7 =3D (UINT32)(Dr7.UintN); > =20 > return EFI_SUCCESS; > } > @@ -722,22 +722,22 @@ DisableDebugRegister ( > Dr7.UintN =3D SystemContext.SystemContextIa32->Dr7; > =20 > if (Register =3D=3D 0) { > - SystemContext.SystemContextIa32->Dr0 =3D Address; > + SystemContext.SystemContextIa32->Dr0 =3D (UINT32)Address; > Dr7.Bits.G0 =3D 0; > Dr7.Bits.RW0 =3D 0; > Dr7.Bits.LEN0 =3D 0; > } else if (Register =3D=3D 1) { > - SystemContext.SystemContextIa32->Dr1 =3D Address; > + SystemContext.SystemContextIa32->Dr1 =3D (UINT32)Address; > Dr7.Bits.G1 =3D 0; > Dr7.Bits.RW1 =3D 0; > Dr7.Bits.LEN1 =3D 0; > } else if (Register =3D=3D 2) { > - SystemContext.SystemContextIa32->Dr2 =3D Address; > + SystemContext.SystemContextIa32->Dr2 =3D (UINT32)Address; > Dr7.Bits.G2 =3D 0; > Dr7.Bits.RW2 =3D 0; > Dr7.Bits.LEN2 =3D 0; > } else if (Register =3D=3D 3) { > - SystemContext.SystemContextIa32->Dr3 =3D Address; > + SystemContext.SystemContextIa32->Dr3 =3D (UINT32)Address; > Dr7.Bits.G3 =3D 0; > Dr7.Bits.RW3 =3D 0; > Dr7.Bits.LEN3 =3D 0; > @@ -746,7 +746,7 @@ DisableDebugRegister ( > } > =20 > // Update DR7 register so appropriate Gn, RWn and LENn bits can be tur= ned off. > - SystemContext.SystemContextIa32->Dr7 =3D Dr7.UintN; > + SystemContext.SystemContextIa32->Dr7 =3D (UINT32)(Dr7.UintN); > =20 > return EFI_SUCCESS; > } > diff --git a/EmbeddedPkg/Include/libfdt_env.h b/EmbeddedPkg/Include/libfd= t_env.h > index dfd3bac01f..1b08727a12 100644 > --- a/EmbeddedPkg/Include/libfdt_env.h > +++ b/EmbeddedPkg/Include/libfdt_env.h > @@ -80,7 +80,7 @@ memset ( > size_t n > ) > { > - return SetMem (s, n, c); > + return SetMem (s, n, (UINT8)c); > } > =20 > static inline int > @@ -90,7 +90,7 @@ memcmp ( > int len > ) > { > - return CompareMem (dest, src, len); > + return (int) CompareMem (dest, src, len); > } > =20 > static inline void * > @@ -100,7 +100,7 @@ memchr ( > size_t n > ) > { > - return ScanMem8 (s, n, c); > + return ScanMem8 (s, n, (UINT8)c); > } > =20 > static inline size_t > @@ -119,7 +119,7 @@ strchr ( > { > char pattern[2]; > =20 > - pattern[0] =3D c; > + pattern[0] =3D (char)c; > pattern[1] =3D 0; > return AsciiStrStr (s, pattern); > } > diff --git a/EmbeddedPkg/Library/FdtLib/fdt.c b/EmbeddedPkg/Library/FdtLi= b/fdt.c > index 56a9787cd0..e7dc86b46c 100644 > --- a/EmbeddedPkg/Library/FdtLib/fdt.c > +++ b/EmbeddedPkg/Library/FdtLib/fdt.c > @@ -90,7 +90,8 @@ fdt_offset_ptr ( > { > unsigned absoffset =3D offset + fdt_off_dt_struct (fdt); > =20 > - if ( (absoffset < offset) > + if ( (offset < 0) > + || (absoffset < (unsigned int)offset) > || ((absoffset + len) < absoffset) > || ((absoffset + len) > fdt_totalsize (fdt))) > { > @@ -98,7 +99,7 @@ fdt_offset_ptr ( > } > =20 > if (fdt_version (fdt) >=3D 0x11) { > - if ( ((offset + len) < offset) > + if ( ((offset + len) < (unsigned int)offset) > || ((offset + len) > fdt_size_dt_struct (fdt))) > { > return NULL; > @@ -299,7 +300,7 @@ _fdt_find_string ( > const char *s > ) > { > - int len =3D strlen (s) + 1; > + int len =3D (int) strlen (s) + 1; > const char *last =3D strtab + tabsize - len; > const char *p; > =20 > @@ -321,7 +322,7 @@ fdt_move ( > { > FDT_CHECK_HEADER (fdt); > =20 > - if (fdt_totalsize (fdt) > bufsize) { > + if ((bufsize < 0) || (fdt_totalsize (fdt) > (unsigned int)bufsize)) { > return -FDT_ERR_NOSPACE; > } > =20 > diff --git a/EmbeddedPkg/Library/FdtLib/fdt_overlay.c b/EmbeddedPkg/Libra= ry/FdtLib/fdt_overlay.c > index 0e6b8715e4..1828e7afd9 100644 > --- a/EmbeddedPkg/Library/FdtLib/fdt_overlay.c > +++ b/EmbeddedPkg/Library/FdtLib/fdt_overlay.c > @@ -362,7 +362,7 @@ overlay_update_local_node_references ( > fdto, > tree_node, > name, > - strlen (name), > + (int)strlen (name), > poffset, > &adj_val, > sizeof (adj_val) > @@ -610,7 +610,7 @@ overlay_fixup_phandle ( > return -FDT_ERR_BADOVERLAY; > } > =20 > - fixup_len =3D fixup_end - fixup_str; > + fixup_len =3D (uint32_t)(fixup_end - fixup_str); > =20 > len -=3D fixup_len + 1; > value +=3D fixup_len + 1; > @@ -621,7 +621,7 @@ overlay_fixup_phandle ( > return -FDT_ERR_BADOVERLAY; > } > =20 > - path_len =3D sep - path; > + path_len =3D (uint32_t)(sep - path); > if (path_len =3D=3D (fixup_len - 1)) { > return -FDT_ERR_BADOVERLAY; > } > @@ -633,7 +633,7 @@ overlay_fixup_phandle ( > return -FDT_ERR_BADOVERLAY; > } > =20 > - name_len =3D sep - name; > + name_len =3D (uint32_t)(sep - name); > if (!name_len) { > return -FDT_ERR_BADOVERLAY; > } > @@ -971,7 +971,7 @@ overlay_symbol_update ( > } > =20 > frag_name =3D path + 1; > - frag_name_len =3D s - path - 1; > + frag_name_len =3D (int)(s - path - 1); > =20 > /* verify format; safe since "s" lies in \0 terminated prop */ > len =3D sizeof ("/__overlay__/") - 1; > @@ -980,7 +980,7 @@ overlay_symbol_update ( > } > =20 > rel_path =3D s + len; > - rel_path_len =3D e - rel_path; > + rel_path_len =3D (int)(e - rel_path); > =20 > /* find the fragment index in which the symbol lies */ > ret =3D fdt_subnode_offset_namelen ( > @@ -1019,7 +1019,7 @@ overlay_symbol_update ( > =20 > len =3D ret; > } else { > - len =3D strlen (target_path); > + len =3D (int)strlen (target_path); > } > =20 > ret =3D fdt_setprop_placeholder ( > @@ -1106,7 +1106,7 @@ fdt_overlay_apply ( > /* > * The overlay has been damaged, erase its magic. > */ > - fdt_set_magic (fdto, ~0); > + fdt_set_magic (fdto, (uint32_t)~0); > =20 > return 0; > =20 > @@ -1115,13 +1115,13 @@ err: > /* > * The overlay might have been damaged, erase its magic. > */ > - fdt_set_magic (fdto, ~0); > + fdt_set_magic (fdto, (uint32_t)~0); > =20 > /* > * The base device tree might have been damaged, erase its > * magic. > */ > - fdt_set_magic (fdt, ~0); > + fdt_set_magic (fdt, (uint32_t)~0); > =20 > return ret; > } > diff --git a/EmbeddedPkg/Library/FdtLib/fdt_ro.c b/EmbeddedPkg/Library/Fd= tLib/fdt_ro.c > index 30aac37958..1f2aee3405 100644 > --- a/EmbeddedPkg/Library/FdtLib/fdt_ro.c > +++ b/EmbeddedPkg/Library/FdtLib/fdt_ro.c > @@ -234,7 +234,7 @@ fdt_subnode_offset ( > const char *name > ) > { > - return fdt_subnode_offset_namelen (fdt, parentoffset, name, strlen (na= me)); > + return fdt_subnode_offset_namelen (fdt, parentoffset, name, (int)strle= n (name)); > } > =20 > int > @@ -258,7 +258,7 @@ fdt_path_offset_namelen ( > q =3D end; > } > =20 > - p =3D fdt_get_alias_namelen (fdt, p, q - p); > + p =3D fdt_get_alias_namelen (fdt, p, (int)(q - p)); > if (!p) { > return -FDT_ERR_BADPATH; > } > @@ -283,7 +283,7 @@ fdt_path_offset_namelen ( > q =3D end; > } > =20 > - offset =3D fdt_subnode_offset_namelen (fdt, offset, p, q-p); > + offset =3D fdt_subnode_offset_namelen (fdt, offset, p, (int)(q-p)); > if (offset < 0) { > return offset; > } > @@ -300,7 +300,7 @@ fdt_path_offset ( > const char *path > ) > { > - return fdt_path_offset_namelen (fdt, path, strlen (path)); > + return fdt_path_offset_namelen (fdt, path, (int)strlen (path)); > } > =20 > const char * > @@ -320,7 +320,7 @@ fdt_get_name ( > } > =20 > if (len) { > - *len =3D strlen (nh->name); > + *len =3D (int)strlen (nh->name); > } > =20 > return nh->name; > @@ -402,8 +402,8 @@ fdt_get_property_namelen ( > (offset =3D fdt_next_property_offset (fdt, offset))) > { > const struct fdt_property *prop; > - > - if (!(prop =3D fdt_get_property_by_offset (fdt, offset, lenp))) { > + prop =3D fdt_get_property_by_offset (fdt, offset, lenp); > + if (!prop) { > offset =3D -FDT_ERR_INTERNAL; > break; > } > @@ -438,7 +438,7 @@ fdt_get_property ( > fdt, > nodeoffset, > name, > - strlen (name), > + (int)strlen (name), > lenp > ); > } > @@ -492,7 +492,7 @@ fdt_getprop ( > int *lenp > ) > { > - return fdt_getprop_namelen (fdt, nodeoffset, name, strlen (name), lenp= ); > + return fdt_getprop_namelen (fdt, nodeoffset, name, (int)strlen (name),= lenp); > } > =20 > uint32_t > @@ -540,7 +540,7 @@ fdt_get_alias ( > const char *name > ) > { > - return fdt_get_alias_namelen (fdt, name, strlen (name)); > + return fdt_get_alias_namelen (fdt, name, (int)strlen (name)); > } > =20 > int > @@ -769,7 +769,7 @@ fdt_stringlist_contains ( > const char *str > ) > { > - int len =3D strlen (str); > + int len =3D (int)strlen (str); > const char *p; > =20 > while (listlen >=3D len) { > @@ -782,7 +782,7 @@ fdt_stringlist_contains ( > return 0; /* malformed strlist.. */ > } > =20 > - listlen -=3D (p-strlist) + 1; > + listlen -=3D (int)(p-strlist) + 1; > strlist =3D p + 1; > } > =20 > @@ -807,7 +807,7 @@ fdt_stringlist_count ( > end =3D list + length; > =20 > while (list < end) { > - length =3D strnlen (list, end - list) + 1; > + length =3D (int)strnlen (list, end - list) + 1; > =20 > /* Abort if the last string isn't properly NUL-terminated. */ > if (list + length > end) { > @@ -837,11 +837,11 @@ fdt_stringlist_search ( > return length; > } > =20 > - len =3D strlen (string) + 1; > + len =3D (int)strlen (string) + 1; > end =3D list + length; > =20 > while (list < end) { > - length =3D strnlen (list, end - list) + 1; > + length =3D (int)strnlen (list, end - list) + 1; > =20 > /* Abort if the last string isn't properly NUL-terminated. */ > if (list + length > end) { > @@ -883,7 +883,7 @@ fdt_stringlist_get ( > end =3D list + length; > =20 > while (list < end) { > - length =3D strnlen (list, end - list) + 1; > + length =3D (int)strnlen (list, end - list) + 1; > =20 > /* Abort if the last string isn't properly NUL-terminated. */ > if (list + length > end) { > diff --git a/EmbeddedPkg/Library/FdtLib/fdt_rw.c b/EmbeddedPkg/Library/Fd= tLib/fdt_rw.c > index cb5088a3af..5d172127e4 100644 > --- a/EmbeddedPkg/Library/FdtLib/fdt_rw.c > +++ b/EmbeddedPkg/Library/FdtLib/fdt_rw.c > @@ -171,8 +171,8 @@ _fdt_splice_struct ( > { > int delta =3D newlen - oldlen; > int err; > - > - if ((err =3D _fdt_splice (fdt, p, oldlen, newlen))) { > + err =3D _fdt_splice (fdt, p, oldlen, newlen); > + if (err) { > return err; > } > =20 > @@ -190,8 +190,8 @@ _fdt_splice_string ( > void *p =3D (char *)fdt > + fdt_off_dt_strings (fdt) + fdt_size_dt_strings (fdt); > int err; > - > - if ((err =3D _fdt_splice (fdt, p, 0, newlen))) { > + err =3D _fdt_splice (fdt, p, 0, newlen); > + if (err) { > return err; > } > =20 > @@ -208,13 +208,13 @@ _fdt_find_add_string ( > char *strtab =3D (char *)fdt + fdt_off_dt_strings (fdt); > const char *p; > char *new; > - int len =3D strlen (s) + 1; > + int len =3D (int)strlen (s) + 1; > int err; > =20 > p =3D _fdt_find_string (strtab, fdt_size_dt_strings (fdt), s); > if (p) { > /* found it */ > - return (p - strtab); > + return (int)(p - strtab); > } > =20 > new =3D strtab + fdt_size_dt_strings (fdt); > @@ -224,7 +224,7 @@ _fdt_find_add_string ( > } > =20 > memcpy (new, s, len); > - return (new - strtab); > + return (int)(new - strtab); > } > =20 > int > @@ -283,13 +283,13 @@ _fdt_resize_property ( > if (!*prop) { > return oldlen; > } > - > - if ((err =3D _fdt_splice_struct ( > + err =3D _fdt_splice_struct ( > fdt, > (*prop)->data, > FDT_TAGALIGN (oldlen), > FDT_TAGALIGN (len) > - ))) > + ); > + if (err) > { > return err; > } > @@ -353,7 +353,7 @@ fdt_set_name ( > return oldlen; > } > =20 > - newlen =3D strlen (name); > + newlen =3D (int)strlen (name); > =20 > err =3D _fdt_splice_struct ( > fdt, > @@ -537,7 +537,7 @@ fdt_add_subnode ( > const char *name > ) > { > - return fdt_add_subnode_namelen (fdt, parentoffset, name, strlen (name)= ); > + return fdt_add_subnode_namelen (fdt, parentoffset, name, (int)strlen (= name)); > } > =20 > int > diff --git a/EmbeddedPkg/Library/FdtLib/fdt_strerror.c b/EmbeddedPkg/Libr= ary/FdtLib/fdt_strerror.c > index cb07f6166e..36e2613b43 100644 > --- a/EmbeddedPkg/Library/FdtLib/fdt_strerror.c > +++ b/EmbeddedPkg/Library/FdtLib/fdt_strerror.c > @@ -94,7 +94,7 @@ fdt_strerror ( > return ""; > } else if (errval =3D=3D 0) { > return ""; > - } else if (errval > -FDT_ERRTABSIZE) { > + } else if (errval > (-1 * FDT_ERRTABSIZE)) { > const char *s =3D fdt_errtable[-errval].str; > =20 > if (s) { > diff --git a/EmbeddedPkg/Library/FdtLib/fdt_strtoul.c b/EmbeddedPkg/Libra= ry/FdtLib/fdt_strtoul.c > index e615d6f4c0..c340771918 100644 > --- a/EmbeddedPkg/Library/FdtLib/fdt_strtoul.c > +++ b/EmbeddedPkg/Library/FdtLib/fdt_strtoul.c > @@ -33,5 +33,5 @@ strtoul ( > return MAX_UINTN; > } > =20 > - return ReturnValue; > + return (unsigned long)ReturnValue; > } > diff --git a/EmbeddedPkg/Library/FdtLib/fdt_sw.c b/EmbeddedPkg/Library/Fd= tLib/fdt_sw.c > index 6bcdd1fc7b..1fb47776cb 100644 > --- a/EmbeddedPkg/Library/FdtLib/fdt_sw.c > +++ b/EmbeddedPkg/Library/FdtLib/fdt_sw.c > @@ -91,7 +91,7 @@ _fdt_grab_space ( > return NULL; > } > =20 > - fdt_set_size_dt_struct (fdt, offset + len); > + fdt_set_size_dt_struct (fdt, offset + (int)len); > return _fdt_offset_ptr_w (fdt, offset); > } > =20 > @@ -210,7 +210,7 @@ fdt_begin_node ( > ) > { > struct fdt_node_header *nh; > - int namelen =3D strlen (name) + 1; > + int namelen =3D (int)strlen (name) + 1; > =20 > FDT_SW_CHECK_HEADER (fdt); > =20 > @@ -251,18 +251,18 @@ _fdt_find_add_string ( > char *strtab =3D (char *)fdt + fdt_totalsize (fdt); > const char *p; > int strtabsize =3D fdt_size_dt_strings (fdt); > - int len =3D strlen (s) + 1; > + int len =3D (int)strlen (s) + 1; > int struct_top, offset; > =20 > p =3D _fdt_find_string (strtab - strtabsize, strtabsize, s); > if (p) { > - return p - strtab; > + return (int)(p - strtab); > } > =20 > /* Add it */ > offset =3D -strtabsize - len; > struct_top =3D fdt_off_dt_struct (fdt) + fdt_size_dt_struct (fdt); > - if (fdt_totalsize (fdt) + offset < struct_top) { > + if (fdt_totalsize (fdt) + offset < (uint32_t)struct_top) { > return 0; /* no more room :( */ > } > =20 > diff --git a/EmbeddedPkg/Library/FdtLib/fdt_wip.c b/EmbeddedPkg/Library/F= dtLib/fdt_wip.c > index 8447706919..2f822fce61 100644 > --- a/EmbeddedPkg/Library/FdtLib/fdt_wip.c > +++ b/EmbeddedPkg/Library/FdtLib/fdt_wip.c > @@ -80,7 +80,7 @@ fdt_setprop_inplace_namelen_partial ( > return proplen; > } > =20 > - if (proplen < (len + idx)) { > + if ((proplen < 0) || ((uint32_t)proplen < (len + idx))) { > return -FDT_ERR_NOSPACE; > } > =20 > @@ -113,7 +113,7 @@ fdt_setprop_inplace ( > fdt, > nodeoffset, > name, > - strlen (name), > + (int)strlen (name), > 0, > val, > len > diff --git a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocatio= nLib.c b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c > index fa81cc9d59..11566cf57f 100644 > --- a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c > +++ b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c > @@ -308,7 +308,7 @@ ReallocatePool ( > if (OldBuffer !=3D NULL) { > HandOffHob =3D GetHobList (); > ASSERT (((EFI_PHYSICAL_ADDRESS)(UINTN)OldBuffer >=3D HandOffHob->Efi= MemoryBottom)); > - ASSERT (((EFI_PHYSICAL_ADDRESS)(UINTN)(OldBuffer + OldSize) <=3D Han= dOffHob->EfiFreeMemoryBottom)); > + ASSERT (((EFI_PHYSICAL_ADDRESS)(UINTN)((UINTN)OldBuffer + OldSize) <= =3D HandOffHob->EfiFreeMemoryBottom)); > } > =20 > DEBUG_CODE_END (); > diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c b/EmbeddedPkg/Univ= ersal/MmcDxe/MmcBlockIo.c > index d695e25571..c234f41f02 100644 > --- a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c > +++ b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c > @@ -42,7 +42,7 @@ MmcGetCardStatus ( > if (MmcHostInstance->State !=3D MmcHwInitializationState) { > // Get the Status of the card. > CmdArg =3D MmcHostInstance->CardInfo.RCA << 16; > - Status =3D MmcHost->SendCommand (MmcHost, MMC_CMD13, CmdArg); > + Status =3D MmcHost->SendCommand (MmcHost, MMC_CMD13, (UINT32)CmdArg)= ; > if (EFI_ERROR (Status)) { > DEBUG ((DEBUG_ERROR, "MmcGetCardStatus(MMC_CMD13): Error and Statu= s =3D %r\n", Status)); > return Status; > @@ -165,7 +165,7 @@ MmcTransferBlock ( > } > } > =20 > - Status =3D MmcHost->SendCommand (MmcHost, Cmd, CmdArg); > + Status =3D MmcHost->SendCommand (MmcHost, (MMC_CMD)Cmd, (UINT32)CmdArg= ); > if (EFI_ERROR (Status)) { > DEBUG ((DEBUG_ERROR, "%a(MMC_CMD%d): Error %r\n", __func__, Cmd, Sta= tus)); > return Status; > @@ -203,7 +203,7 @@ MmcTransferBlock ( > && (MMC_R0_CURRENTSTATE (Response) !=3D MMC_R0_STATE_TRAN) > && Timeout--) > { > - Status =3D MmcHost->SendCommand (MmcHost, MMC_CMD13, CmdArg); > + Status =3D MmcHost->SendCommand (MmcHost, MMC_CMD13, (UINT32)CmdArg)= ; > if (!EFI_ERROR (Status)) { > MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1, Response)= ; > if (Response[0] & MMC_R0_READY_FOR_DATA) { > @@ -319,7 +319,7 @@ MmcIoBlocks ( > && (MMC_R0_CURRENTSTATE (Response) !=3D MMC_R0_STATE_TRAN) > && Timeout--) > { > - Status =3D MmcHost->SendCommand (MmcHost, MMC_CMD13, CmdArg); > + Status =3D MmcHost->SendCommand (MmcHost, MMC_CMD13, (UINT32)CmdAr= g); > if (!EFI_ERROR (Status)) { > MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1, Respons= e); > } > diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c b/EmbeddedP= kg/Universal/MmcDxe/MmcIdentification.c > index 57388d9f46..d0bf59c79d 100755 > --- a/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c > +++ b/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c > @@ -166,7 +166,7 @@ EmmcIdentificationMode ( > } > =20 > // Assign a relative address value to the card > - MmcHostInstance->CardInfo.RCA =3D ++mEmmcRcaCount; // TODO: might need= a more sophisticated way of doing this > + MmcHostInstance->CardInfo.RCA =3D (UINT16)++mEmmcRcaCount; // TODO: mi= ght need a more sophisticated way of doing this > RCA =3D MmcHostInstance->CardInfo.RCA << RCA= _SHIFT_OFFSET; > Status =3D Host->SendCommand (Host, MMC_CMD3, R= CA); > if (EFI_ERROR (Status)) { > @@ -386,21 +386,21 @@ InitializeSdMmcDevice ( > if (MmcHostInstance->CardInfo.CardType =3D=3D SD_CARD_2_HIGH) { > CardSize =3D HC_MMC_CSD_GET_DEVICESIZE (Response); > NumBlocks =3D ((CardSize + 1) * 1024); > - BlockSize =3D 1 << MMC_CSD_GET_READBLLEN (Response); > + BlockSize =3D (UINTN)(1 << MMC_CSD_GET_READBLLEN (Response)); > } else { > CardSize =3D MMC_CSD_GET_DEVICESIZE (Response); > - NumBlocks =3D (CardSize + 1) * (1 << (MMC_CSD_GET_DEVICESIZEMULT (Re= sponse) + 2)); > - BlockSize =3D 1 << MMC_CSD_GET_READBLLEN (Response); > + NumBlocks =3D (CardSize + 1) * (UINTN)(1 << (MMC_CSD_GET_DEVICESIZEM= ULT (Response) + 2)); > + BlockSize =3D (UINTN)(1 << MMC_CSD_GET_READBLLEN (Response)); > } > =20 > // For >=3D2G card, BlockSize may be 1K, but the transfer size is 512 = bytes. > if (BlockSize > 512) { > - NumBlocks =3D MultU64x32 (NumBlocks, BlockSize / 512); > + NumBlocks =3D MultU64x32 (NumBlocks, (UINT32)(BlockSize / 512)); > BlockSize =3D 512; > } > =20 > MmcHostInstance->BlockIo.Media->LastBlock =3D (NumBlocks - 1); > - MmcHostInstance->BlockIo.Media->BlockSize =3D BlockSize; > + MmcHostInstance->BlockIo.Media->BlockSize =3D (UINT32)BlockSize; > MmcHostInstance->BlockIo.Media->ReadOnly =3D MmcHost->IsReadOnly (= MmcHost); > MmcHostInstance->BlockIo.Media->MediaPresent =3D TRUE; > MmcHostInstance->BlockIo.Media->MediaId++; > @@ -629,7 +629,7 @@ MmcIdentificationMode ( > =20 > // Check which kind of card we are using. Ver2.00 or later SD Memory C= ard (PL180 is SD v1.1) > CmdArg =3D (0x0UL << 12 | BIT8 | 0xCEUL << 0); > - Status =3D MmcHost->SendCommand (MmcHost, MMC_CMD8, CmdArg); > + Status =3D MmcHost->SendCommand (MmcHost, MMC_CMD8, (UINT32)CmdArg); > if (Status =3D=3D EFI_SUCCESS) { > DEBUG ((DEBUG_ERROR, "Card is SD2.0 =3D> Supports high capacity\n"))= ; > IsHCS =3D TRUE; > @@ -668,7 +668,7 @@ MmcIdentificationMode ( > CmdArg |=3D BIT30; > } > =20 > - Status =3D MmcHost->SendCommand (MmcHost, MMC_ACMD41, CmdArg); > + Status =3D MmcHost->SendCommand (MmcHost, MMC_ACMD41, (UINT32)CmdA= rg); > if (!EFI_ERROR (Status)) { > Status =3D MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_= OCR, Response); > if (EFI_ERROR (Status)) { > @@ -751,7 +751,7 @@ MmcIdentificationMode ( > // The status returned for this CMD3 will be 2 - identification > // > CmdArg =3D 1; > - Status =3D MmcHost->SendCommand (MmcHost, MMC_CMD3, CmdArg); > + Status =3D MmcHost->SendCommand (MmcHost, MMC_CMD3, (UINT32)CmdArg); > if (EFI_ERROR (Status)) { > DEBUG ((DEBUG_ERROR, "MmcIdentificationMode(MMC_CMD3): Error\n")); > return Status; > @@ -769,7 +769,7 @@ MmcIdentificationMode ( > if (MmcHostInstance->CardInfo.CardType !=3D MMC_CARD) { > MmcHostInstance->CardInfo.RCA =3D Response[0] >> 16; > } else { > - MmcHostInstance->CardInfo.RCA =3D CmdArg; > + MmcHostInstance->CardInfo.RCA =3D (UINT16)CmdArg; > } > =20 > Status =3D MmcNotifyState (MmcHostInstance, MmcStandByState); > @@ -829,7 +829,7 @@ InitializeMmcDevice ( > =20 > // Block Count (not used). Could return an error for SD card > if (MmcHostInstance->CardInfo.CardType =3D=3D MMC_CARD) { > - Status =3D MmcHost->SendCommand (MmcHost, MMC_CMD23, BlockCount); > + Status =3D MmcHost->SendCommand (MmcHost, MMC_CMD23, (UINT32)BlockCo= unt); > if (EFI_ERROR (Status)) { > DEBUG ((DEBUG_ERROR, "InitializeMmcDevice(MMC_CMD23): Error, Statu= s=3D%r\n", Status)); > return Status; -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#115245): https://edk2.groups.io/g/devel/message/115245 Mute This Topic: https://groups.io/mt/104200931/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-