From 79ad703b55a2534ec97b284d38349f6ff6dab8b8 Mon Sep 17 00:00:00 2001 From: kuqin12 <42554914+kuqin12@users.noreply.github.com> Date: Thu, 1 Aug 2024 12:20:01 -0700 Subject: ArmPlatformPkg: CodeQL Fixes. Makes changes to comply with alerts raised by CodeQL. The issues here fall into the following category: 1. comparison-with-wider-type Signed-off-by: Eeshan Londhe --- .../LcdGraphicsOutputDxe/LcdGraphicsOutputBlt.c | 32 +++++++++++----------- ArmPlatformPkg/Drivers/PL061GpioDxe/PL061Gpio.c | 14 +++++----- ArmPlatformPkg/Drivers/PL061GpioDxe/PL061Gpio.h | 2 +- .../Drivers/SP805WatchdogDxe/SP805Watchdog.c | 4 +-- ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.h | 2 +- 5 files changed, 27 insertions(+), 27 deletions(-) (limited to 'ArmPlatformPkg') diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputBlt.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputBlt.c index 013506976f..3679ee93df 100644 --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputBlt.c +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputBlt.c @@ -140,10 +140,10 @@ VideoCopyHorizontalOverlap ( UINT16 *SourcePixel16bit; UINT16 *DestinationPixel16bit; - UINT32 SourcePixelY; - UINT32 DestinationPixelY; - UINTN SizeIn32Bits; - UINTN SizeIn16Bits; + UINTN SourcePixelY; + UINTN DestinationPixelY; + UINTN SizeIn32Bits; + UINTN SizeIn16Bits; Status = EFI_SUCCESS; @@ -271,8 +271,8 @@ BltVideoFill ( VOID *DestinationAddr; UINT16 *DestinationPixel16bit; UINT16 Pixel16bit; - UINT32 DestinationPixelX; - UINT32 DestinationLine; + UINTN DestinationPixelX; + UINTN DestinationLine; UINTN WidthInBytes; Status = EFI_SUCCESS; @@ -420,11 +420,11 @@ BltVideoToBltBuffer ( VOID *DestinationAddr; UINT16 *SourcePixel16bit; UINT16 Pixel16bit; - UINT32 SourcePixelX; - UINT32 SourceLine; - UINT32 DestinationPixelX; - UINT32 DestinationLine; - UINT32 BltBufferHorizontalResolution; + UINTN SourcePixelX; + UINTN SourceLine; + UINTN DestinationPixelX; + UINTN DestinationLine; + UINTN BltBufferHorizontalResolution; UINTN WidthInBytes; Status = EFI_SUCCESS; @@ -583,11 +583,11 @@ BltBufferToVideo ( VOID *SourceAddr; VOID *DestinationAddr; UINT16 *DestinationPixel16bit; - UINT32 SourcePixelX; - UINT32 SourceLine; - UINT32 DestinationPixelX; - UINT32 DestinationLine; - UINT32 BltBufferHorizontalResolution; + UINTN SourcePixelX; + UINTN SourceLine; + UINTN DestinationPixelX; + UINTN DestinationLine; + UINTN BltBufferHorizontalResolution; UINTN WidthInBytes; Status = EFI_SUCCESS; diff --git a/ArmPlatformPkg/Drivers/PL061GpioDxe/PL061Gpio.c b/ArmPlatformPkg/Drivers/PL061GpioDxe/PL061Gpio.c index fc062204c0..9d6e8832e2 100644 --- a/ArmPlatformPkg/Drivers/PL061GpioDxe/PL061Gpio.c +++ b/ArmPlatformPkg/Drivers/PL061GpioDxe/PL061Gpio.c @@ -34,7 +34,7 @@ PL061Locate ( OUT UINTN *RegisterBase ) { - UINT32 Index; + UINTN Index; for (Index = 0; Index < mPL061PlatformGpio->GpioControllerCount; Index++) { if ( (Gpio >= mPL061PlatformGpio->GpioController[Index].GpioIndex) @@ -74,18 +74,18 @@ UINTN EFIAPI PL061EffectiveAddress ( IN UINTN Address, - IN UINTN Mask + IN UINT8 Mask ) { - return ((Address + PL061_GPIO_DATA_REG_OFFSET) + (Mask << 2)); + return ((Address + PL061_GPIO_DATA_REG_OFFSET) + (UINTN)(Mask << 2)); } STATIC -UINTN +UINT8 EFIAPI PL061GetPins ( IN UINTN Address, - IN UINTN Mask + IN UINT8 Mask ) { return MmioRead8 (PL061EffectiveAddress (Address, Mask)); @@ -96,8 +96,8 @@ VOID EFIAPI PL061SetPins ( IN UINTN Address, - IN UINTN Mask, - IN UINTN Value + IN UINT8 Mask, + IN UINT8 Value ) { MmioWrite8 (PL061EffectiveAddress (Address, Mask), Value); diff --git a/ArmPlatformPkg/Drivers/PL061GpioDxe/PL061Gpio.h b/ArmPlatformPkg/Drivers/PL061GpioDxe/PL061Gpio.h index 42d87a16a3..8db1e1f8ec 100644 --- a/ArmPlatformPkg/Drivers/PL061GpioDxe/PL061Gpio.h +++ b/ArmPlatformPkg/Drivers/PL061GpioDxe/PL061Gpio.h @@ -37,6 +37,6 @@ #define PL061_GPIO_PINS 8 // All bits low except one bit high, native bit length -#define GPIO_PIN_MASK(Pin) (1UL << ((UINTN)(Pin))) +#define GPIO_PIN_MASK(Pin) (UINT8)(1 << (Pin & (PL061_GPIO_PINS - 1))) #endif // __PL061_GPIO_H__ diff --git a/ArmPlatformPkg/Drivers/SP805WatchdogDxe/SP805Watchdog.c b/ArmPlatformPkg/Drivers/SP805WatchdogDxe/SP805Watchdog.c index b8e7fbe38d..c9ffb7c612 100644 --- a/ArmPlatformPkg/Drivers/SP805WatchdogDxe/SP805Watchdog.c +++ b/ArmPlatformPkg/Drivers/SP805WatchdogDxe/SP805Watchdog.c @@ -24,7 +24,7 @@ STATIC EFI_EVENT mEfiExitBootServicesEvent; STATIC EFI_HARDWARE_INTERRUPT_PROTOCOL *mInterrupt; STATIC EFI_WATCHDOG_TIMER_NOTIFY mWatchdogNotify; -STATIC UINT32 mTimerPeriod; +STATIC UINT64 mTimerPeriod; /** Make sure the SP805 registers are unlocked for writing. @@ -101,7 +101,7 @@ SP805Stop ( { // Disable interrupts if ((MmioRead32 (SP805_WDOG_CONTROL_REG) & SP805_WDOG_CTRL_INTEN) != 0) { - MmioAnd32 (SP805_WDOG_CONTROL_REG, ~SP805_WDOG_CTRL_INTEN); + MmioAnd32 (SP805_WDOG_CONTROL_REG, (UINT32) ~SP805_WDOG_CTRL_INTEN); } } diff --git a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.h b/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.h index 0d4fe387c5..6b1e41796c 100644 --- a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.h +++ b/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.h @@ -108,7 +108,7 @@ #define PL111_CTRL_LCD_16BPP_565 (6 << 1) #define PL111_CTRL_LCD_12BPP_444 (7 << 1) #define PL111_CTRL_LCD_BPP(Bpp) ((Bpp) << 1) -#define PL111_CTRL_LCD_EN 1 +#define PL111_CTRL_LCD_EN 1U /**********************************************************************/ -- cgit v1.2.3