]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
console: avoid promotion to signed int
authorDavid Tardon <dtardon@redhat.com>
Wed, 3 Oct 2018 10:48:58 +0000 (12:48 +0200)
committerDavid Tardon <dtardon@redhat.com>
Fri, 12 Oct 2018 10:38:41 +0000 (12:38 +0200)
coverity message:
sign_extension: Suspicious implicit sign extension: "keydata.Key.ScanCode" with type "UINT16" (16 bits, unsigned) is promoted in "keydata.Key.ScanCode << 16" to type "int" (32 bits, signed), then sign-extended to type "unsigned long" (64 bits, unsigned).  If "keydata.Key.ScanCode << 16" is greater than 0x7FFFFFFF, the upper bits of the result will all be 1.

src/boot/efi/console.h

index 10c5ce4ebdb30f826998a63f3e057b54a578a313..b9ed6c70b323c40f2d877308392735e0df683a55 100644 (file)
@@ -9,7 +9,7 @@
 
 #define EFI_CONTROL_PRESSED             (EFI_RIGHT_CONTROL_PRESSED|EFI_LEFT_CONTROL_PRESSED)
 #define EFI_ALT_PRESSED                 (EFI_RIGHT_ALT_PRESSED|EFI_LEFT_ALT_PRESSED)
-#define KEYPRESS(keys, scan, uni) ((((UINT64)keys) << 32) | ((scan) << 16) | (uni))
+#define KEYPRESS(keys, scan, uni) ((((UINT64)keys) << 32) | (((UINT64)scan) << 16) | (uni))
 #define KEYCHAR(k) ((k) & 0xffff)
 #define CHAR_CTRL(c) ((c) - 'a' + 1)