BaseTools: Fix wrong type of arguments to formatting functions

Fixes issues found with the cpp/wrong-type-format-argument CodeQL
rule in BaseTools.

Reference:
https://cwe.mitre.org/data/definitions/686.html

The following CodeQL errors are resolved:

1. Check failure on line 1115 in
   BaseTools/Source/C/EfiRom/EfiRom.c

   - This argument should be of type 'int' but is of type 'char *'.
   - This argument should be of type 'int' but is of type 'signed
     char *'.

2. Check failure on line 359 in
   BaseTools/Source/C/GenFw/Elf32Convert.c

   - This argument should be of type 'CHAR8 *' but is of type
     'unsigned int'.

3. Check failure on line 1841 in
   BaseTools/Source/C/GenFw/Elf64Convert.c

   - This argument should be of type 'unsigned int' but is of type
     'unsigned long long'.

4. Check failure on line 1871 in
   BaseTools/Source/C/GenFw/Elf64Convert.c

   - This argument should be of type 'unsigned int' but is of type
     'unsigned long long'.

5. Check failure on line 2400 in
   BaseTools/Source/C/GenFv/GenFvInternalLib.c

   - This argument should be of type 'unsigned long long' but is of
     type 'unsigned int'.

6. Check failure on line 1099 in
   BaseTools/Source/C/GenFw/Elf64Convert.c

   - This argument should be of type 'CHAR8 *' but is of type
     'unsigned int'.

7. Check failure on line 1098 in
   BaseTools/Source/C/GenSec/GenSec.c

   - This argument should be of type 'CHAR8 *' but is of type
     'char **'.

8. Check failure on line 911 in
   BaseTools/Source/C/GenSec/GenSec.c

  - This argument should be of type 'CHAR8 *' but is of type
    'char **'.

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Sean Brogan <sean.brogan@microsoft.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
This commit is contained in:
Michael Kubacki
2022-11-08 12:17:59 -05:00
committed by mergify[bot]
parent 0be81a4d83
commit 179efe5d69
5 changed files with 8 additions and 8 deletions

View File

@@ -356,7 +356,7 @@ ScanSections32 (
mCoffOffset += sizeof (EFI_IMAGE_NT_HEADERS32);
break;
default:
VerboseMsg ("%s unknown e_machine type. Assume IA-32", (UINTN)mEhdr->e_machine);
VerboseMsg ("%u unknown e_machine type. Assume IA-32", (UINTN)mEhdr->e_machine);
mCoffOffset += sizeof (EFI_IMAGE_NT_HEADERS32);
break;
}

View File

@@ -1096,7 +1096,7 @@ ScanSections64 (
break;
default:
VerboseMsg ("%s unknown e_machine type. Assume X64", (UINTN)mEhdr->e_machine);
VerboseMsg ("%u unknown e_machine type. Assume X64", (UINTN)mEhdr->e_machine);
NtHdr->Pe32Plus.FileHeader.Machine = EFI_IMAGE_MACHINE_X64;
NtHdr->Pe32Plus.OptionalHeader.Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
}
@@ -1837,7 +1837,7 @@ WriteRelocations64 (
case R_X86_64_REX_GOTPCRELX:
break;
case R_X86_64_64:
VerboseMsg ("EFI_IMAGE_REL_BASED_DIR64 Offset: 0x%08X",
VerboseMsg ("EFI_IMAGE_REL_BASED_DIR64 Offset: 0x%08llX",
mCoffSectionsOffset[RelShdr->sh_info] + (Rel->r_offset - SecShdr->sh_addr));
CoffAddFixup(
(UINT32) ((UINT64) mCoffSectionsOffset[RelShdr->sh_info]
@@ -1867,7 +1867,7 @@ WriteRelocations64 (
//
// case R_X86_64_32S:
case R_X86_64_32:
VerboseMsg ("EFI_IMAGE_REL_BASED_HIGHLOW Offset: 0x%08X",
VerboseMsg ("EFI_IMAGE_REL_BASED_HIGHLOW Offset: 0x%08llX",
mCoffSectionsOffset[RelShdr->sh_info] + (Rel->r_offset - SecShdr->sh_addr));
CoffAddFixup(
(UINT32) ((UINT64) mCoffSectionsOffset[RelShdr->sh_info]