cf4a81
From 544ef98f873688d875b453c3f7afc60c4fd0329c Mon Sep 17 00:00:00 2001
cf4a81
From: Bhupesh Sharma <bhsharma@redhat.com>
cf4a81
Date: Thu, 12 Sep 2019 12:43:23 +0530
cf4a81
Subject: [PATCH] [PATCH] vmcore-dmesg/vmcore-dmesg.c: Fix shifting error
cf4a81
 reported by cppcheck
cf4a81
cf4a81
Running 'cppcheck' static code analyzer (see cppcheck(1))
cf4a81
on 'vmcore-dmesg/vmcore-dmesg.c' shows the following
cf4a81
shifting error:
cf4a81
cf4a81
  $ cppcheck  --enable=all  vmcore-dmesg/vmcore-dmesg.c
cf4a81
  Checking vmcore-dmesg/vmcore-dmesg.c ...
cf4a81
  [vmcore-dmesg/vmcore-dmesg.c:17]: (error) Shifting signed 32-bit value
cf4a81
  by 31 bits is undefined behaviour
cf4a81
cf4a81
Fix the same via this patch.
cf4a81
cf4a81
Cc: Lianbo Jiang <lijiang@redhat.com>
cf4a81
Signed-off-by: Bhupesh Sharma <bhsharma@redhat.com>
cf4a81
---
cf4a81
 vmcore-dmesg/vmcore-dmesg.c | 2 +-
cf4a81
 1 file changed, 1 insertion(+), 1 deletion(-)
cf4a81
cf4a81
diff --git a/vmcore-dmesg/vmcore-dmesg.c b/vmcore-dmesg/vmcore-dmesg.c
cf4a81
index 41ab73147155..8790738c0e23 100644
cf4a81
--- a/vmcore-dmesg/vmcore-dmesg.c
cf4a81
+++ b/vmcore-dmesg/vmcore-dmesg.c
cf4a81
@@ -23,7 +23,7 @@
cf4a81
 typedef Elf32_Nhdr Elf_Nhdr;
cf4a81
cf4a81
 /* stole this macro from kernel printk.c */
cf4a81
-#define LOG_BUF_LEN_MAX (uint32_t)(1 << 31)
cf4a81
+#define LOG_BUF_LEN_MAX (uint32_t)(1U << 31)
cf4a81
cf4a81
 static const char *fname;
cf4a81
 static Elf64_Ehdr ehdr;
cf4a81
--
cf4a81
2.7.4