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 D048394194A for ; Tue, 6 Feb 2024 16:23:30 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=G0/NJ1gd2TO+AoX6hJ4txVkmX4o++IBcdYQqJ3g6R74=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1707236609; v=1; b=Eufzcp39TjKyBqDH0c5oqfDaMbXNqc8Ff9AimicumK6CQFNxRl66Bn5COQ3GxJtK3Pd0ZX86 bZ86XUQukbCv2+6Oywvx142yqmcEMIAEC6l5blh8DsFQeY5C4mV/NAwTDBEn+d7GJ6TiwGd8pYg mH4HXHRi/2qp9ohk7I8TbbDI= X-Received: by 127.0.0.2 with SMTP id S9DGYY7687511xypTgZRXn4H; Tue, 06 Feb 2024 08:23:29 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) by mx.groups.io with SMTP id smtpd.web10.25868.1707236608964285966 for ; Tue, 06 Feb 2024 08:23:28 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10976"; a="4572502" X-IronPort-AV: E=Sophos;i="6.05,247,1701158400"; d="scan'208";a="4572502" X-Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Feb 2024 08:23:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,247,1701158400"; d="scan'208";a="1405562" X-Received: from njayapra-mobl.gar.corp.intel.com ([10.213.98.126]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Feb 2024 08:23:22 -0800 From: "Jayaprakash, N" To: devel@edk2.groups.io Cc: Jayaprakash N , Rebecca Cran , Michael D Kinney , Laszlo Ersek , Leif Lindholm , Ard Biesheuvel , Abner Chang Subject: [edk2-devel] [edk2 Patch 1/1] EmbeddedPkg: Fix compiler errors due to implicit conversions Date: Tue, 6 Feb 2024 21:53:11 +0530 Message-Id: <20240206162311.1321-2-n.jayaprakash@intel.com> In-Reply-To: <20240206162311.1321-1-n.jayaprakash@intel.com> References: <20240206162311.1321-1-n.jayaprakash@intel.com> MIME-Version: 1.0 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,n.jayaprakash@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: RxAncrKhk5OgaX21ZSfSmWopx7686176AA= Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=Eufzcp39; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.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 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4669 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. 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(-) diff --git a/EmbeddedPkg/GdbStub/X64/Processor.c b/EmbeddedPkg/GdbStub/X64/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 = SystemContext.SystemContextIa32->Dr7; if (Register == 0) { - SystemContext.SystemContextIa32->Dr0 = Address; + SystemContext.SystemContextIa32->Dr0 = (UINT32)Address; Dr7.Bits.G0 = 1; - Dr7.Bits.RW0 = Type; - Dr7.Bits.LEN0 = Length; + Dr7.Bits.RW0 = (UINT32)Type; + Dr7.Bits.LEN0 = (UINT32)Length; } else if (Register == 1) { - SystemContext.SystemContextIa32->Dr1 = Address; + SystemContext.SystemContextIa32->Dr1 = (UINT32)Address; Dr7.Bits.G1 = 1; - Dr7.Bits.RW1 = Type; - Dr7.Bits.LEN1 = Length; + Dr7.Bits.RW1 = (UINT32)Type; + Dr7.Bits.LEN1 = (UINT32)Length; } else if (Register == 2) { - SystemContext.SystemContextIa32->Dr2 = Address; + SystemContext.SystemContextIa32->Dr2 = (UINT32)Address; Dr7.Bits.G2 = 1; - Dr7.Bits.RW2 = Type; - Dr7.Bits.LEN2 = Length; + Dr7.Bits.RW2 = (UINT32)Type; + Dr7.Bits.LEN2 = (UINT32)Length; } else if (Register == 3) { - SystemContext.SystemContextIa32->Dr3 = Address; + SystemContext.SystemContextIa32->Dr3 = (UINT32)Address; Dr7.Bits.G3 = 1; - Dr7.Bits.RW3 = Type; - Dr7.Bits.LEN3 = Length; + Dr7.Bits.RW3 = (UINT32)Type; + Dr7.Bits.LEN3 = (UINT32)Length; } else { return EFI_INVALID_PARAMETER; } // Update Dr7 with appropriate Gn, RWn and LENn bits - SystemContext.SystemContextIa32->Dr7 = Dr7.UintN; + SystemContext.SystemContextIa32->Dr7 = (UINT32)(Dr7.UintN); return EFI_SUCCESS; } @@ -722,22 +722,22 @@ DisableDebugRegister ( Dr7.UintN = SystemContext.SystemContextIa32->Dr7; if (Register == 0) { - SystemContext.SystemContextIa32->Dr0 = Address; + SystemContext.SystemContextIa32->Dr0 = (UINT32)Address; Dr7.Bits.G0 = 0; Dr7.Bits.RW0 = 0; Dr7.Bits.LEN0 = 0; } else if (Register == 1) { - SystemContext.SystemContextIa32->Dr1 = Address; + SystemContext.SystemContextIa32->Dr1 = (UINT32)Address; Dr7.Bits.G1 = 0; Dr7.Bits.RW1 = 0; Dr7.Bits.LEN1 = 0; } else if (Register == 2) { - SystemContext.SystemContextIa32->Dr2 = Address; + SystemContext.SystemContextIa32->Dr2 = (UINT32)Address; Dr7.Bits.G2 = 0; Dr7.Bits.RW2 = 0; Dr7.Bits.LEN2 = 0; } else if (Register == 3) { - SystemContext.SystemContextIa32->Dr3 = Address; + SystemContext.SystemContextIa32->Dr3 = (UINT32)Address; Dr7.Bits.G3 = 0; Dr7.Bits.RW3 = 0; Dr7.Bits.LEN3 = 0; @@ -746,7 +746,7 @@ DisableDebugRegister ( } // Update DR7 register so appropriate Gn, RWn and LENn bits can be turned off. - SystemContext.SystemContextIa32->Dr7 = Dr7.UintN; + SystemContext.SystemContextIa32->Dr7 = (UINT32)(Dr7.UintN); return EFI_SUCCESS; } diff --git a/EmbeddedPkg/Include/libfdt_env.h b/EmbeddedPkg/Include/libfdt_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); } static inline int @@ -90,7 +90,7 @@ memcmp ( int len ) { - return CompareMem (dest, src, len); + return (int) CompareMem (dest, src, len); } static inline void * @@ -100,7 +100,7 @@ memchr ( size_t n ) { - return ScanMem8 (s, n, c); + return ScanMem8 (s, n, (UINT8)c); } static inline size_t @@ -119,7 +119,7 @@ strchr ( { char pattern[2]; - pattern[0] = c; + pattern[0] = (char)c; pattern[1] = 0; return AsciiStrStr (s, pattern); } diff --git a/EmbeddedPkg/Library/FdtLib/fdt.c b/EmbeddedPkg/Library/FdtLib/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 = offset + fdt_off_dt_struct (fdt); - 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 ( } if (fdt_version (fdt) >= 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 = strlen (s) + 1; + int len = (int) strlen (s) + 1; const char *last = strtab + tabsize - len; const char *p; @@ -321,7 +322,7 @@ fdt_move ( { FDT_CHECK_HEADER (fdt); - if (fdt_totalsize (fdt) > bufsize) { + if ((bufsize < 0) || (fdt_totalsize (fdt) > (unsigned int)bufsize)) { return -FDT_ERR_NOSPACE; } diff --git a/EmbeddedPkg/Library/FdtLib/fdt_overlay.c b/EmbeddedPkg/Library/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; } - fixup_len = fixup_end - fixup_str; + fixup_len = (uint32_t)(fixup_end - fixup_str); len -= fixup_len + 1; value += fixup_len + 1; @@ -621,7 +621,7 @@ overlay_fixup_phandle ( return -FDT_ERR_BADOVERLAY; } - path_len = sep - path; + path_len = (uint32_t)(sep - path); if (path_len == (fixup_len - 1)) { return -FDT_ERR_BADOVERLAY; } @@ -633,7 +633,7 @@ overlay_fixup_phandle ( return -FDT_ERR_BADOVERLAY; } - name_len = sep - name; + name_len = (uint32_t)(sep - name); if (!name_len) { return -FDT_ERR_BADOVERLAY; } @@ -971,7 +971,7 @@ overlay_symbol_update ( } frag_name = path + 1; - frag_name_len = s - path - 1; + frag_name_len = (int)(s - path - 1); /* verify format; safe since "s" lies in \0 terminated prop */ len = sizeof ("/__overlay__/") - 1; @@ -980,7 +980,7 @@ overlay_symbol_update ( } rel_path = s + len; - rel_path_len = e - rel_path; + rel_path_len = (int)(e - rel_path); /* find the fragment index in which the symbol lies */ ret = fdt_subnode_offset_namelen ( @@ -1019,7 +1019,7 @@ overlay_symbol_update ( len = ret; } else { - len = strlen (target_path); + len = (int)strlen (target_path); } ret = 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); return 0; @@ -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); /* * The base device tree might have been damaged, erase its * magic. */ - fdt_set_magic (fdt, ~0); + fdt_set_magic (fdt, (uint32_t)~0); return ret; } diff --git a/EmbeddedPkg/Library/FdtLib/fdt_ro.c b/EmbeddedPkg/Library/FdtLib/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 (name)); + return fdt_subnode_offset_namelen (fdt, parentoffset, name, (int)strlen (name)); } int @@ -258,7 +258,7 @@ fdt_path_offset_namelen ( q = end; } - p = fdt_get_alias_namelen (fdt, p, q - p); + p = fdt_get_alias_namelen (fdt, p, (int)(q - p)); if (!p) { return -FDT_ERR_BADPATH; } @@ -283,7 +283,7 @@ fdt_path_offset_namelen ( q = end; } - offset = fdt_subnode_offset_namelen (fdt, offset, p, q-p); + offset = 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)); } const char * @@ -320,7 +320,7 @@ fdt_get_name ( } if (len) { - *len = strlen (nh->name); + *len = (int)strlen (nh->name); } return nh->name; @@ -402,8 +402,8 @@ fdt_get_property_namelen ( (offset = fdt_next_property_offset (fdt, offset))) { const struct fdt_property *prop; - - if (!(prop = fdt_get_property_by_offset (fdt, offset, lenp))) { + prop = fdt_get_property_by_offset (fdt, offset, lenp); + if (!prop) { offset = -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); } 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)); } int @@ -769,7 +769,7 @@ fdt_stringlist_contains ( const char *str ) { - int len = strlen (str); + int len = (int)strlen (str); const char *p; while (listlen >= len) { @@ -782,7 +782,7 @@ fdt_stringlist_contains ( return 0; /* malformed strlist.. */ } - listlen -= (p-strlist) + 1; + listlen -= (int)(p-strlist) + 1; strlist = p + 1; } @@ -807,7 +807,7 @@ fdt_stringlist_count ( end = list + length; while (list < end) { - length = strnlen (list, end - list) + 1; + length = (int)strnlen (list, end - list) + 1; /* Abort if the last string isn't properly NUL-terminated. */ if (list + length > end) { @@ -837,11 +837,11 @@ fdt_stringlist_search ( return length; } - len = strlen (string) + 1; + len = (int)strlen (string) + 1; end = list + length; while (list < end) { - length = strnlen (list, end - list) + 1; + length = (int)strnlen (list, end - list) + 1; /* Abort if the last string isn't properly NUL-terminated. */ if (list + length > end) { @@ -883,7 +883,7 @@ fdt_stringlist_get ( end = list + length; while (list < end) { - length = strnlen (list, end - list) + 1; + length = (int)strnlen (list, end - list) + 1; /* 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/FdtLib/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 = newlen - oldlen; int err; - - if ((err = _fdt_splice (fdt, p, oldlen, newlen))) { + err = _fdt_splice (fdt, p, oldlen, newlen); + if (err) { return err; } @@ -190,8 +190,8 @@ _fdt_splice_string ( void *p = (char *)fdt + fdt_off_dt_strings (fdt) + fdt_size_dt_strings (fdt); int err; - - if ((err = _fdt_splice (fdt, p, 0, newlen))) { + err = _fdt_splice (fdt, p, 0, newlen); + if (err) { return err; } @@ -208,13 +208,13 @@ _fdt_find_add_string ( char *strtab = (char *)fdt + fdt_off_dt_strings (fdt); const char *p; char *new; - int len = strlen (s) + 1; + int len = (int)strlen (s) + 1; int err; p = _fdt_find_string (strtab, fdt_size_dt_strings (fdt), s); if (p) { /* found it */ - return (p - strtab); + return (int)(p - strtab); } new = strtab + fdt_size_dt_strings (fdt); @@ -224,7 +224,7 @@ _fdt_find_add_string ( } memcpy (new, s, len); - return (new - strtab); + return (int)(new - strtab); } int @@ -283,13 +283,13 @@ _fdt_resize_property ( if (!*prop) { return oldlen; } - - if ((err = _fdt_splice_struct ( + err = _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; } - newlen = strlen (name); + newlen = (int)strlen (name); err = _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)); } int diff --git a/EmbeddedPkg/Library/FdtLib/fdt_strerror.c b/EmbeddedPkg/Library/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 == 0) { return ""; - } else if (errval > -FDT_ERRTABSIZE) { + } else if (errval > (-1 * FDT_ERRTABSIZE)) { const char *s = fdt_errtable[-errval].str; if (s) { diff --git a/EmbeddedPkg/Library/FdtLib/fdt_strtoul.c b/EmbeddedPkg/Library/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; } - return ReturnValue; + return (unsigned long)ReturnValue; } diff --git a/EmbeddedPkg/Library/FdtLib/fdt_sw.c b/EmbeddedPkg/Library/FdtLib/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; } - fdt_set_size_dt_struct (fdt, offset + len); + fdt_set_size_dt_struct (fdt, offset + (int)len); return _fdt_offset_ptr_w (fdt, offset); } @@ -210,7 +210,7 @@ fdt_begin_node ( ) { struct fdt_node_header *nh; - int namelen = strlen (name) + 1; + int namelen = (int)strlen (name) + 1; FDT_SW_CHECK_HEADER (fdt); @@ -251,18 +251,18 @@ _fdt_find_add_string ( char *strtab = (char *)fdt + fdt_totalsize (fdt); const char *p; int strtabsize = fdt_size_dt_strings (fdt); - int len = strlen (s) + 1; + int len = (int)strlen (s) + 1; int struct_top, offset; p = _fdt_find_string (strtab - strtabsize, strtabsize, s); if (p) { - return p - strtab; + return (int)(p - strtab); } /* Add it */ offset = -strtabsize - len; struct_top = 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 :( */ } diff --git a/EmbeddedPkg/Library/FdtLib/fdt_wip.c b/EmbeddedPkg/Library/FdtLib/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; } - if (proplen < (len + idx)) { + if ((proplen < 0) || ((uint32_t)proplen < (len + idx))) { return -FDT_ERR_NOSPACE; } @@ -113,7 +113,7 @@ fdt_setprop_inplace ( fdt, nodeoffset, name, - strlen (name), + (int)strlen (name), 0, val, len diff --git a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.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 != NULL) { HandOffHob = GetHobList (); ASSERT (((EFI_PHYSICAL_ADDRESS)(UINTN)OldBuffer >= HandOffHob->EfiMemoryBottom)); - ASSERT (((EFI_PHYSICAL_ADDRESS)(UINTN)(OldBuffer + OldSize) <= HandOffHob->EfiFreeMemoryBottom)); + ASSERT (((EFI_PHYSICAL_ADDRESS)(UINTN)((UINTN)OldBuffer + OldSize) <= HandOffHob->EfiFreeMemoryBottom)); } DEBUG_CODE_END (); diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c b/EmbeddedPkg/Universal/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 != MmcHwInitializationState) { // Get the Status of the card. CmdArg = MmcHostInstance->CardInfo.RCA << 16; - Status = MmcHost->SendCommand (MmcHost, MMC_CMD13, CmdArg); + Status = MmcHost->SendCommand (MmcHost, MMC_CMD13, (UINT32)CmdArg); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "MmcGetCardStatus(MMC_CMD13): Error and Status = %r\n", Status)); return Status; @@ -165,7 +165,7 @@ MmcTransferBlock ( } } - Status = MmcHost->SendCommand (MmcHost, Cmd, CmdArg); + Status = MmcHost->SendCommand (MmcHost, (MMC_CMD)Cmd, (UINT32)CmdArg); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a(MMC_CMD%d): Error %r\n", __func__, Cmd, Status)); return Status; @@ -203,7 +203,7 @@ MmcTransferBlock ( && (MMC_R0_CURRENTSTATE (Response) != MMC_R0_STATE_TRAN) && Timeout--) { - Status = MmcHost->SendCommand (MmcHost, MMC_CMD13, CmdArg); + Status = 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) != MMC_R0_STATE_TRAN) && Timeout--) { - Status = MmcHost->SendCommand (MmcHost, MMC_CMD13, CmdArg); + Status = MmcHost->SendCommand (MmcHost, MMC_CMD13, (UINT32)CmdArg); if (!EFI_ERROR (Status)) { MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1, Response); } diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c b/EmbeddedPkg/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 ( } // Assign a relative address value to the card - MmcHostInstance->CardInfo.RCA = ++mEmmcRcaCount; // TODO: might need a more sophisticated way of doing this + MmcHostInstance->CardInfo.RCA = (UINT16)++mEmmcRcaCount; // TODO: might need a more sophisticated way of doing this RCA = MmcHostInstance->CardInfo.RCA << RCA_SHIFT_OFFSET; Status = Host->SendCommand (Host, MMC_CMD3, RCA); if (EFI_ERROR (Status)) { @@ -386,21 +386,21 @@ InitializeSdMmcDevice ( if (MmcHostInstance->CardInfo.CardType == SD_CARD_2_HIGH) { CardSize = HC_MMC_CSD_GET_DEVICESIZE (Response); NumBlocks = ((CardSize + 1) * 1024); - BlockSize = 1 << MMC_CSD_GET_READBLLEN (Response); + BlockSize = (UINTN)(1 << MMC_CSD_GET_READBLLEN (Response)); } else { CardSize = MMC_CSD_GET_DEVICESIZE (Response); - NumBlocks = (CardSize + 1) * (1 << (MMC_CSD_GET_DEVICESIZEMULT (Response) + 2)); - BlockSize = 1 << MMC_CSD_GET_READBLLEN (Response); + NumBlocks = (CardSize + 1) * (UINTN)(1 << (MMC_CSD_GET_DEVICESIZEMULT (Response) + 2)); + BlockSize = (UINTN)(1 << MMC_CSD_GET_READBLLEN (Response)); } // For >=2G card, BlockSize may be 1K, but the transfer size is 512 bytes. if (BlockSize > 512) { - NumBlocks = MultU64x32 (NumBlocks, BlockSize / 512); + NumBlocks = MultU64x32 (NumBlocks, (UINT32)(BlockSize / 512)); BlockSize = 512; } MmcHostInstance->BlockIo.Media->LastBlock = (NumBlocks - 1); - MmcHostInstance->BlockIo.Media->BlockSize = BlockSize; + MmcHostInstance->BlockIo.Media->BlockSize = (UINT32)BlockSize; MmcHostInstance->BlockIo.Media->ReadOnly = MmcHost->IsReadOnly (MmcHost); MmcHostInstance->BlockIo.Media->MediaPresent = TRUE; MmcHostInstance->BlockIo.Media->MediaId++; @@ -629,7 +629,7 @@ MmcIdentificationMode ( // Check which kind of card we are using. Ver2.00 or later SD Memory Card (PL180 is SD v1.1) CmdArg = (0x0UL << 12 | BIT8 | 0xCEUL << 0); - Status = MmcHost->SendCommand (MmcHost, MMC_CMD8, CmdArg); + Status = MmcHost->SendCommand (MmcHost, MMC_CMD8, (UINT32)CmdArg); if (Status == EFI_SUCCESS) { DEBUG ((DEBUG_ERROR, "Card is SD2.0 => Supports high capacity\n")); IsHCS = TRUE; @@ -668,7 +668,7 @@ MmcIdentificationMode ( CmdArg |= BIT30; } - Status = MmcHost->SendCommand (MmcHost, MMC_ACMD41, CmdArg); + Status = MmcHost->SendCommand (MmcHost, MMC_ACMD41, (UINT32)CmdArg); if (!EFI_ERROR (Status)) { Status = 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 = 1; - Status = MmcHost->SendCommand (MmcHost, MMC_CMD3, CmdArg); + Status = 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 != MMC_CARD) { MmcHostInstance->CardInfo.RCA = Response[0] >> 16; } else { - MmcHostInstance->CardInfo.RCA = CmdArg; + MmcHostInstance->CardInfo.RCA = (UINT16)CmdArg; } Status = MmcNotifyState (MmcHostInstance, MmcStandByState); @@ -829,7 +829,7 @@ InitializeMmcDevice ( // Block Count (not used). Could return an error for SD card if (MmcHostInstance->CardInfo.CardType == MMC_CARD) { - Status = MmcHost->SendCommand (MmcHost, MMC_CMD23, BlockCount); + Status = MmcHost->SendCommand (MmcHost, MMC_CMD23, (UINT32)BlockCount); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "InitializeMmcDevice(MMC_CMD23): Error, Status=%r\n", Status)); return Status; -- 2.40.0.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#115181): https://edk2.groups.io/g/devel/message/115181 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] -=-=-=-=-=-=-=-=-=-=-=-