Menu

#81 Fix VS2019 Code Analysis warnings

Unstable_(example)
closed
Patch (1)
5
2021-07-16
2021-07-15
Pete Batard
No

When compiling for x64, Visual Studio 2019's Code Analysis produces the following warnings:

C:\Projects\gnu-efi\lib\print.c(1380): warning C26451: Arithmetic overflow: Using operator '+' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '+' to avoid overflow (io.2).
C:\Projects\gnu-efi\lib\smbios.c(47): warning C26451: Arithmetic overflow: Using operator '+' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '+' to avoid overflow (io.2).
C:\Projects\gnu-efi\lib\str.c(289): warning C26451: Arithmetic overflow: Using operator '-' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '-' to avoid overflow (io.2).

Fix these by adding an explicit cast to UINTN.

1 Attachments

Discussion

  • Nigel Croxon

    Nigel Croxon - 2021-07-16
    • status: open --> closed
    • assigned_to: Nigel Croxon
     
  • Nigel Croxon

    Nigel Croxon - 2021-07-16

    commit 4ef183353cd98e8d0e9ef0c5bbe7783ff10da891 (HEAD -> master)
    Author: Pete Batard pete@akeo.ie
    Date: Thu Jul 15 12:38:22 2021 +0100

    Fix VS2019 Code Analysis warnings
    
     

Log in to post a comment.

MongoDB Logo MongoDB