]> git.proxmox.com Git - mirror_smartmontools-debian.git/blobdiff - cciss.cpp
import smartmontools 7.0
[mirror_smartmontools-debian.git] / cciss.cpp
index 163491601b9c5941159f67735e1b37e6a4446f74..1d207a6b3b9240df9d17d703cba0ac16653f3eaf 100644 (file)
--- a/cciss.cpp
+++ b/cciss.cpp
@@ -1,3 +1,13 @@
+/*
+ * cciss.cpp
+ *
+ * Home page of code is: http://www.smartmontools.org
+ *
+ * Copyright (C) 2007 Sergey Svishchev
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
 #include <stdio.h>
 #include <string.h>
 #include <sys/types.h>
@@ -5,7 +15,7 @@
 
 #include "config.h"
 
-#if defined(linux)
+#if defined(linux) || defined(__linux__)
 #  include <sys/ioctl.h>
 #  ifdef HAVE_LINUX_COMPILER_H
 #    include <linux/compiler.h>
 #  ifndef be32toh
 #    define be32toh __be32_to_cpu
 #  endif
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 #  include <sys/endian.h>
 #  include CISS_LOCATION
 #  define _HAVE_CCISS
-#elif defined(__FreeBSD_kernel__)
-#  include <endian.h>
-#  include CISS_LOCATION
-#  define _HAVE_CCISS
 #endif
 
 #ifdef _HAVE_CCISS
 #include "cciss.h"
-#include "int64.h"
 #include "scsicmds.h"
 #include "utility.h"
 
-const char * cciss_cpp_cvsid = "$Id: cciss.cpp 3446 2011-10-13 22:36:28Z samm2 $"
+const char * cciss_cpp_cvsid = "$Id: cciss.cpp 4858 2018-12-16 17:59:59Z chrfranke $"
   CCISS_H_CVSID;
 
 typedef struct _ReportLUNdata_struct
@@ -69,10 +74,9 @@ int cciss_io_interface(int device, int target, struct scsi_cmnd_io * iop, int re
      unsigned char pBuf[512] = {0};
      unsigned char phylun[8] = {0};
      int iBufLen = 512;
-     int status = -1;
      int len = 0; // used later in the code.
  
-     status = cciss_getlun(device, target, phylun, report);
+     int status = cciss_getlun(device, target, phylun, report);
      if (report > 0)
          printf("  cciss_getlun(%d, %d) = 0x%x; scsi3addr: %02x %02x %02x %02x %02x %02x %02x %02x\n", 
             device, target, status, 
@@ -95,7 +99,7 @@ int cciss_io_interface(int device, int target, struct scsi_cmnd_io * iop, int re
                  int trunc = (iop->dxfer_len > 256) ? 1 : 0;
                  printf("  Incoming data, len=%d%s:\n", (int)iop->dxfer_len,
                       (trunc ? " [only first 256 bytes shown]" : ""));
-                 dStrHex((const char*)iop->dxferp, (trunc ? 256 : iop->dxfer_len) , 1);
+                 dStrHex(iop->dxferp, (trunc ? 256 : iop->dxfer_len) , 1);
              }
          }
          return 0;
@@ -113,7 +117,7 @@ int cciss_io_interface(int device, int target, struct scsi_cmnd_io * iop, int re
          if (report > 1)
          {
              printf("  >>> Sense buffer, len=%d:\n", (int)len);
-             dStrHex((const char *)pBuf, len , 1);
+             dStrHex((const uint8_t *)pBuf, len , 1);
          }
      }
      if (report)
@@ -177,7 +181,7 @@ static int cciss_sendpassthru(unsigned int cmdtype, unsigned char *CDB,
 
     if ((err = ioctl(fd, CCISS_PASSTHRU, &iocommand))) 
     {
-        fprintf(stderr, "CCISS ioctl error %d (fd %d CDBLen %d buf_size %d)\n",
+        fprintf(stderr, "CCISS ioctl error %d (fd %d CDBLen %u buf_size %u)\n",
            fd, err, CDBlen, size);
     }
     return err;