From 2093a8d0afaa9754fa29dc81ed48e3c5f6a97ec9 Mon Sep 17 00:00:00 2001
From: chrfranke <chrfranke@4ea69e1a-61f1-4043-bf83-b5c94c648137>
Date: Sun, 16 Sep 2018 16:05:10 +0000
Subject: [PATCH] os_win32.cpp: Use unsigned int for bit shifts (cppcheck 1.84:
 shiftTooManyBitsSigned).

git-svn-id: https://svn.code.sf.net/p/smartmontools/code/trunk@4782 4ea69e1a-61f1-4043-bf83-b5c94c648137
---
 smartmontools/ChangeLog    |  3 +++
 smartmontools/os_win32.cpp | 11 +++++------
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/smartmontools/ChangeLog b/smartmontools/ChangeLog
index 65f823c71..49477b6a9 100644
--- a/smartmontools/ChangeLog
+++ b/smartmontools/ChangeLog
@@ -2,6 +2,9 @@ $Id$
 
 2018-09-16  Christian Franke  <franke@computer.org>
 
+	os_win32.cpp: Use unsigned int for bit shifts
+	(cppcheck 1.84: shiftTooManyBitsSigned).
+
 	Makefile.am: Set HAVE_WORKING_SNPRINTF also in VC14 config.h.
 
 	os_netbsd.cpp: Add spaces between string literals and macros for
diff --git a/smartmontools/os_win32.cpp b/smartmontools/os_win32.cpp
index 449cecb1f..1df556a55 100644
--- a/smartmontools/os_win32.cpp
+++ b/smartmontools/os_win32.cpp
@@ -1594,7 +1594,7 @@ bool win_ata_device::open(int phydrive, int logdrive, const char * options, int
   // 3ware RAID if vendor id present
   m_is_3ware = (vers_ex.wIdentifier == SMART_VENDOR_3WARE);
 
-  unsigned long portmap = 0;
+  unsigned portmap = 0;
   if (port >= 0 && devmap >= 0) {
     // 3ware RAID: check vendor id
     if (!m_is_3ware) {
@@ -1617,14 +1617,13 @@ bool win_ata_device::open(int phydrive, int logdrive, const char * options, int
 
   {
     // 3ware RAID: update devicemap first
-
     if (!update_3ware_devicemap_ioctl(h)) {
       if (   smart_get_version(h, &vers_ex) >= 0
           && vers_ex.wIdentifier == SMART_VENDOR_3WARE    )
         portmap = vers_ex.dwDeviceMapEx;
     }
     // Check port existence
-    if (!(portmap & (1L << port))) {
+    if (!(portmap & (1U << port))) {
       if (!is_permissive()) {
         close();
         return set_err(ENOENT, "%s: Port %d is empty or does not exist", devpath, port);
@@ -2162,7 +2161,7 @@ unsigned csmi_device::get_ports_used()
         continue;
     }
 
-    ports_used |= (1 << p);
+    ports_used |= (1U << p);
   }
 
   return ports_used;
@@ -4563,7 +4562,7 @@ bool win_smart_interface::scan_smart_devices(smart_device_list & devlist,
             // Add physical drives
             int len = strlen(name);
             for (unsigned int pi = 0; pi < 32; pi++) {
-              if (vers_ex.dwDeviceMapEx & (1L << pi)) {
+              if (vers_ex.dwDeviceMapEx & (1U << pi)) {
                 snprintf(name+len, sizeof(name)-1-len, ",%u", pi);
                 devlist.push_back( new win_ata_device(this, name, "ata") );
               }
@@ -4627,7 +4626,7 @@ bool win_smart_interface::scan_smart_devices(smart_device_list & devlist,
         continue;
 
       for (int pi = 0; pi < 32; pi++) {
-        if (!(ports_used & (1 << pi)))
+        if (!(ports_used & (1U << pi)))
           continue;
         snprintf(name, sizeof(name)-1, "/dev/csmi%d,%d", i, pi);
         devlist.push_back( new win_csmi_device(this, name, "ata") );
-- 
GitLab