On Fri, Jul 05, 2019 at 07:33:17AM +0000, Gary Lin wrote: > On Fri, Jul 05, 2019 at 07:25:18AM +0000, Liming Gao wrote: > > Can you let me know your GCC compiler version? > > > I also encountered the error. My system is openSUSE Tumbleweed, and the > gcc version is 9.1.1. > > It seems the new gcc is restricter on memset and strncat. > Those warnings are legit.
For example: memset (Fv->FfsAttuibutes[Index].UiName, '\0', _MAX_PATH); UiName is CHAR16, so this line should be memset (Fv->FfsAttuibutes[Index].UiName, '\0', _MAX_PATH * sizeof(CHAR16)); For those strncat() statements, the third parameter of strncat() stands for the "available" space in the destination buffer, so using sizeof(SRC_STR) is actually very dangerous because it doesn't guarantee that the destination buffer has that many space for the string. Gary Lin > Gary Lin > > > From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Chen, > > Farrah > > Sent: Friday, July 05, 2019 3:10 PM > > To: devel@edk2.groups.io > > Cc: Hao, Xudong <xudong....@intel.com>; Wei, Danmei <danmei....@intel.com> > > Subject: [edk2-devel] Make edk2 fail on Red Hat 8.0 > > > > Hi, > > > > I tried to make ovmf with the latest commit: > > 0a487ef96bd6d2e0ac23323adab86f9949068ed6 on Red Hat 8.0, it failed, while > > it succeed on Red Hat 7.6. > > With commit 4b04d9d73604080a42daf737c39b98d4e1245a51 I used several days > > ago, it works well on both RHEL8.0 and RHEL7.6. > > > > Steps: > > git clone https://github.com/tianocore/edk2.git > > cd edk2 > > git submodule init > > git submodule update -recursive > > OvmfPkg/build.sh -a X64 -n 40 > > ............... > > make -C FMMT > > make[2]: Entering directory '/home/build/fan/edk2/BaseTools/Source/C/FMMT' > > gcc -c -I .. -I ../Include/Common -I ../Include/ -I > > ../Include/IndustryStandard -I ../Common/ -I .. -I . -I ../Include/X64/ > > -MD -fshort-wchar -fno-strict-aliasing -fwrapv > > -fno-delete-null-pointer-checks -Wall -Werror -Wno-deprecated-declarations > > -Wno-stringop-truncation -Wno-restrict -Wno-unused-result -nostdlib -g -O2 > > FmmtLib.c -o FmmtLib.o > > FmmtLib.c: In function 'LibInitializeFvStruct': > > FmmtLib.c:158:5: error: 'memset' used with length equal to number of > > elements without multiplication by element size [-Werror=memset-elt-size] > > memset (Fv->FfsAttuibutes[Index].UiName, '\0', _MAX_PATH); > > ^~~~~~ > > FmmtLib.c: In function 'LibFvHeaderAttributeToStr': > > FmmtLib.c:2521:47: error: argument to 'sizeof' in 'strncat' call is the > > same expression as the source; did you mean to use the size of the > > destination? [-Werror=sizeof-pointer-memaccess] > > strncat (LocalStr, "[attributes] \n", sizeof("[attributes] \n")); > > ^ > > FmmtLib.c:2524:66: error: argument to 'sizeof' in 'strncat' call is the > > same expression as the source; did you mean to use the size of the > > destination? [-Werror=sizeof-pointer-memaccess] > > strncat (LocalStr, "EFI_READ_DISABLED_CAP = TRUE \n", sizeof > > ("EFI_READ_DISABLED_CAP = TRUE \n")); > > ..................... > > > > And detailed log attached. > > Could anyone provide some advice? > > > > > > Thanks, > > Fan > > > > > > > > > > > > > > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#43345): https://edk2.groups.io/g/devel/message/43345 Mute This Topic: https://groups.io/mt/32315331/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-