Author: mav
Date: Fri Jan 10 12:18:05 2014
New Revision: 260509
URL: http://svnweb.freebsd.org/changeset/base/260509

Log:
  Replace several instances of -1 with appropriate CAM_*_WILDCARD and types.
  
  It was equal before r259397, but for good or bad, not any more for LUNs.
  
  This change fixes at least CAM debugging.

Modified:
  head/sbin/camcontrol/camcontrol.c
  head/sys/cam/cam_debug.h
  head/sys/cam/cam_xpt.c
  head/sys/cam/scsi/scsi_low.c

Modified: head/sbin/camcontrol/camcontrol.c
==============================================================================
--- head/sbin/camcontrol/camcontrol.c   Fri Jan 10 12:13:55 2014        
(r260508)
+++ head/sbin/camcontrol/camcontrol.c   Fri Jan 10 12:18:05 2014        
(r260509)
@@ -264,11 +264,12 @@ static int scsiinquiry(struct cam_device
 static int scsiserial(struct cam_device *device, int retry_count, int timeout);
 static int camxferrate(struct cam_device *device);
 #endif /* MINIMALISTIC */
-static int parse_btl(char *tstr, int *bus, int *target, int *lun,
-                    cam_argmask *arglst);
+static int parse_btl(char *tstr, path_id_t *bus, target_id_t *target,
+                    lun_id_t *lun, cam_argmask *arglst);
 static int dorescan_or_reset(int argc, char **argv, int rescan);
-static int rescan_or_reset_bus(int bus, int rescan);
-static int scanlun_or_reset_dev(int bus, int target, int lun, int scan);
+static int rescan_or_reset_bus(path_id_t bus, int rescan);
+static int scanlun_or_reset_dev(path_id_t bus, target_id_t target,
+    lun_id_t lun, int scan);
 #ifndef MINIMALISTIC
 static int readdefects(struct cam_device *device, int argc, char **argv,
                       char *combinedopt, int retry_count, int timeout);
@@ -3019,7 +3020,8 @@ atasecurity(struct cam_device *device, i
  * Returns the number of parsed components, or 0.
  */
 static int
-parse_btl(char *tstr, int *bus, int *target, int *lun, cam_argmask *arglst)
+parse_btl(char *tstr, path_id_t *bus, target_id_t *target, lun_id_t *lun,
+    cam_argmask *arglst)
 {
        char *tmpstr;
        int convs = 0;
@@ -3055,7 +3057,9 @@ dorescan_or_reset(int argc, char **argv,
        static const char must[] =
                "you must specify \"all\", a bus, or a bus:target:lun to %s";
        int rv, error = 0;
-       int bus = -1, target = -1, lun = -1;
+       path_id_t bus = CAM_BUS_WILDCARD;
+       target_id_t target = CAM_TARGET_WILDCARD;
+       lun_id_t lun = CAM_LUN_WILDCARD;
        char *tstr;
 
        if (argc < 3) {
@@ -3087,7 +3091,7 @@ dorescan_or_reset(int argc, char **argv,
 }
 
 static int
-rescan_or_reset_bus(int bus, int rescan)
+rescan_or_reset_bus(path_id_t bus, int rescan)
 {
        union ccb ccb, matchccb;
        int fd, retval;
@@ -3101,7 +3105,7 @@ rescan_or_reset_bus(int bus, int rescan)
                return(1);
        }
 
-       if (bus != -1) {
+       if (bus != CAM_BUS_WILDCARD) {
                ccb.ccb_h.func_code = rescan ? XPT_SCAN_BUS : XPT_RESET_BUS;
                ccb.ccb_h.path_id = bus;
                ccb.ccb_h.target_id = CAM_TARGET_WILDCARD;
@@ -3201,7 +3205,7 @@ rescan_or_reset_bus(int bus, int rescan)
                         * We don't want to rescan or reset the xpt bus.
                         * See above.
                         */
-                       if ((int)bus_result->path_id == -1)
+                       if (bus_result->path_id == CAM_XPT_PATH_ID)
                                continue;
 
                        ccb.ccb_h.func_code = rescan ? XPT_SCAN_BUS :
@@ -3254,7 +3258,7 @@ bailout:
 }
 
 static int
-scanlun_or_reset_dev(int bus, int target, int lun, int scan)
+scanlun_or_reset_dev(path_id_t bus, target_id_t target, lun_id_t lun, int scan)
 {
        union ccb ccb;
        struct cam_device *device;
@@ -3262,18 +3266,18 @@ scanlun_or_reset_dev(int bus, int target
 
        device = NULL;
 
-       if (bus < 0) {
+       if (bus == CAM_BUS_WILDCARD) {
                warnx("invalid bus number %d", bus);
                return(1);
        }
 
-       if (target < 0) {
+       if (target == CAM_TARGET_WILDCARD) {
                warnx("invalid target number %d", target);
                return(1);
        }
 
-       if (lun < 0) {
-               warnx("invalid lun number %d", lun);
+       if (lun == CAM_LUN_WILDCARD) {
+               warnx("invalid lun number %jx", (uintmax_t)lun);
                return(1);
        }
 
@@ -3331,12 +3335,12 @@ scanlun_or_reset_dev(int bus, int target
        if (((ccb.ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP)
         || ((!scan)
          && ((ccb.ccb_h.status & CAM_STATUS_MASK) == CAM_BDR_SENT))) {
-               fprintf(stdout, "%s of %d:%d:%d was successful\n",
-                   scan? "Re-scan" : "Reset", bus, target, lun);
+               fprintf(stdout, "%s of %d:%d:%jx was successful\n",
+                   scan? "Re-scan" : "Reset", bus, target, (uintmax_t)lun);
                return(0);
        } else {
-               fprintf(stdout, "%s of %d:%d:%d returned error %#x\n",
-                   scan? "Re-scan" : "Reset", bus, target, lun,
+               fprintf(stdout, "%s of %d:%d:%jx returned error %#x\n",
+                   scan? "Re-scan" : "Reset", bus, target, (uintmax_t)lun,
                    ccb.ccb_h.status & CAM_STATUS_MASK);
                return(1);
        }
@@ -4218,7 +4222,9 @@ static int
 camdebug(int argc, char **argv, char *combinedopt)
 {
        int c, fd;
-       int bus = -1, target = -1, lun = -1;
+       path_id_t bus = CAM_BUS_WILDCARD;
+       target_id_t target = CAM_TARGET_WILDCARD;
+       lun_id_t lun = CAM_LUN_WILDCARD;
        char *tstr, *tmpstr = NULL;
        union ccb ccb;
        int error = 0;
@@ -4338,8 +4344,8 @@ camdebug(int argc, char **argv, char *co
                                } else {
                                        fprintf(stderr,
                                                "Debugging enabled for "
-                                               "%d:%d:%d\n",
-                                               bus, target, lun);
+                                               "%d:%d:%jx\n",
+                                               bus, target, (uintmax_t)lun);
                                }
                        }
                }
@@ -7986,7 +7992,9 @@ main(int argc, char **argv)
        int error = 0, optstart = 2;
        int devopen = 1;
 #ifndef MINIMALISTIC
-       int bus, target, lun;
+       path_id_t bus;
+       target_id_t target;
+       lun_id_t lun;
 #endif /* MINIMALISTIC */
 
        cmdlist = CAM_CMD_NONE;

Modified: head/sys/cam/cam_debug.h
==============================================================================
--- head/sys/cam/cam_debug.h    Fri Jan 10 12:13:55 2014        (r260508)
+++ head/sys/cam/cam_debug.h    Fri Jan 10 12:18:05 2014        (r260509)
@@ -61,13 +61,13 @@ typedef enum {
 #endif
 
 #ifndef CAM_DEBUG_BUS
-#define CAM_DEBUG_BUS          (-1)
+#define CAM_DEBUG_BUS          CAM_BUS_WILDCARD
 #endif
 #ifndef CAM_DEBUG_TARGET
-#define CAM_DEBUG_TARGET       (-1)
+#define CAM_DEBUG_TARGET       CAM_TARGET_WILDCARD
 #endif
 #ifndef CAM_DEBUG_LUN
-#define CAM_DEBUG_LUN          (-1)
+#define CAM_DEBUG_LUN          CAM_LUN_WILDCARD
 #endif
 
 #ifndef CAM_DEBUG_DELAY

Modified: head/sys/cam/cam_xpt.c
==============================================================================
--- head/sys/cam/cam_xpt.c      Fri Jan 10 12:13:55 2014        (r260508)
+++ head/sys/cam/cam_xpt.c      Fri Jan 10 12:18:05 2014        (r260509)
@@ -1992,13 +1992,15 @@ xptplistperiphfunc(struct cam_periph *pe
                        cdm->matches[j].result.periph_result.target_id =
                                periph->path->target->target_id;
                else
-                       cdm->matches[j].result.periph_result.target_id = -1;
+                       cdm->matches[j].result.periph_result.target_id =
+                               CAM_TARGET_WILDCARD;
 
                if (periph->path->device)
                        cdm->matches[j].result.periph_result.target_lun =
                                periph->path->device->lun_id;
                else
-                       cdm->matches[j].result.periph_result.target_lun = -1;
+                       cdm->matches[j].result.periph_result.target_lun =
+                               CAM_LUN_WILDCARD;
 
                cdm->matches[j].result.periph_result.unit_number =
                        periph->unit_number;

Modified: head/sys/cam/scsi/scsi_low.c
==============================================================================
--- head/sys/cam/scsi/scsi_low.c        Fri Jan 10 12:13:55 2014        
(r260508)
+++ head/sys/cam/scsi/scsi_low.c        Fri Jan 10 12:18:05 2014        
(r260509)
@@ -4232,7 +4232,7 @@ scsi_low_print(slp, ti)
        if (ti != NULL)
        {
                u_int flags = 0, maxnqio = 0, nqio = 0;
-               int lun = -1;
+               int lun = CAM_LUN_WILDCARD;
 
                if (li != NULL)
                {
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to