Skip to content
This repository has been archived by the owner on Aug 24, 2022. It is now read-only.

Commit

Permalink
Fixing Klocwork NUM.OVERFLOW issues
Browse files Browse the repository at this point in the history
Signed-off-by: Juha Vainio <[email protected]>
  • Loading branch information
JuhaVainio authored and kwang13 committed May 20, 2020
1 parent 7735f69 commit 38abefc
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion avb/libavb_user/uefi_avb_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
extern char _binary_avb_pk_start;
extern char _binary_avb_pk_end;
#define avb_pk (&_binary_avb_pk_start)
#define avb_pk_size (&_binary_avb_pk_end - &_binary_avb_pk_start)
#define avb_pk_size ((size_t)&_binary_avb_pk_end - (size_t)&_binary_avb_pk_start)

static AvbIOResult read_from_partition(__attribute__((unused)) AvbOps* ops,
const char* partition_name,
Expand Down
2 changes: 1 addition & 1 deletion libedk2_tpm/Tpm2Help.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,5 +330,5 @@ CopyAuthSessionCommand (
Buffer += sizeof(UINT16);
}

return (UINT32)(UINTN)(Buffer - (UINT8 *)AuthSessionOut);
return (UINT32)(Buffer - (UINT8 *)AuthSessionOut);
}
8 changes: 4 additions & 4 deletions libefiusb/device_mode/XdciDWC.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ UsbRegRead (
IN UINT32 Offset
)
{
volatile UINT32 *addr = (volatile UINT32 *)(UINTN)(Base + Offset);
volatile UINT32 *addr = (volatile UINT32 *)((UINTN)Base + (UINTN)Offset);
return *addr;
}

Expand All @@ -36,7 +36,7 @@ UsbRegWrite (
IN UINT32 val
)
{
volatile UINT32 *addr = (volatile UINT32 *)(UINTN)(Base + Offset);
volatile UINT32 *addr = (volatile UINT32 *)((UINTN)Base + (UINTN)Offset);
*addr = val;
}

Expand Down Expand Up @@ -1848,7 +1848,7 @@ DwcXdciCoreInit (
//
// Prepare a Buffer for SETUP packet
//
LocalCoreHandle->Trbs = (DWC_XDCI_TRB *)(UINTN)((UINT32)(UINTN)
LocalCoreHandle->Trbs = (DWC_XDCI_TRB *)(UINTN)((UINTN)
LocalCoreHandle->UnalignedTrbs +
(DWC_XDCI_TRB_BYTE_ALIGNMENT -
((UINT32)(UINTN)LocalCoreHandle->UnalignedTrbs %
Expand Down Expand Up @@ -3946,7 +3946,7 @@ UsbXdciCoreReinit (
//
// Prepare a Buffer for SETUP packet
//
LocalCoreHandle->Trbs = (DWC_XDCI_TRB *)(UINTN)((UINT32)(UINTN)
LocalCoreHandle->Trbs = (DWC_XDCI_TRB *)(UINTN)((UINTN)
LocalCoreHandle->UnalignedTrbs +
(DWC_XDCI_TRB_BYTE_ALIGNMENT -
((UINT32)(UINTN)LocalCoreHandle->UnalignedTrbs %
Expand Down
2 changes: 1 addition & 1 deletion libkernelflinger/qsort.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ loop: SWAPINIT(a, es);
pn = (char *)a + n * es;
r = min(pa - (char *)a, pb - pa);
vecswap(a, pb - r, r);
r = min((size_t)(pd - pc), pn - pd - es);
r = min(((size_t)pd - (size_t)pc), pn - pd - es);
vecswap(pb, pn - r, r);
if ((r = pb - pa) > es)
qsort(a, r / es, es, cmp);
Expand Down
2 changes: 1 addition & 1 deletion libkernelflinger/upng.c
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@ static EFI_STATUS upng_decode(upng_t* upng)

/* Make sure chunk header is not larger than the total
* compressed */
if ((unsigned long)(chunk - upng->source.buffer + 12) >
if ((unsigned long)(chunk - (unsigned long)upng->source.buffer + 12) >
upng->source.size) {
SET_ERROR(upng, EFI_INVALID_PARAMETER);
return upng->error;
Expand Down
6 changes: 3 additions & 3 deletions libsslsupport/wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -547,9 +547,9 @@ time_t time(time_t *timer)
*timer = *timer +
(time_t)((Time.TimeZone != EFI_UNSPECIFIED_TIMEZONE) ? (Time.TimeZone * 60) : 0) +
(time_t)(CumulativeDays[isleap(Time.Year)][Time.Month] * SECSPERDAY) +
(time_t)(((Time.Day > 0) ? Time.Day - 1 : 0) * SECSPERDAY) +
(time_t)(Time.Hour * SECSPERHOUR) +
(time_t)(Time.Minute * 60) +
(time_t)(((Time.Day > 0) ? (time_t)Time.Day - 1 : 0) * SECSPERDAY) +
(time_t)((time_t)Time.Hour * SECSPERHOUR) +
(time_t)((time_t)Time.Minute * 60) +
(time_t)Time.Second;

return *timer;
Expand Down

0 comments on commit 38abefc

Please sign in to comment.