Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Jul 2019 23:43:38 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r350020 - head/sbin/camcontrol
Message-ID:  <201907152343.x6FNhcsm039360@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: imp
Date: Mon Jul 15 23:43:38 2019
New Revision: 350020
URL: https://svnweb.freebsd.org/changeset/base/350020

Log:
  Use a different approach to range check.
  
  gcc hates dt < CC_DT_NONE since it can never be true when dt is an unsigned
  type. Since that's a compiler choice and may be affected by weird stuff, instead
  use (unsigned)dt > CC_DT_UNKNOWN to test for bounds error since that will work
  regardless of the signedness of dt.

Modified:
  head/sbin/camcontrol/camcontrol.c

Modified: head/sbin/camcontrol/camcontrol.c
==============================================================================
--- head/sbin/camcontrol/camcontrol.c	Mon Jul 15 23:41:00 2019	(r350019)
+++ head/sbin/camcontrol/camcontrol.c	Mon Jul 15 23:43:38 2019	(r350020)
@@ -676,7 +676,7 @@ getdevtype(struct cam_device *cam_dev)
 	 * Get the device type and report it, request no I/O be done to do this.
 	 */
 	error = get_device_type(cam_dev, -1, 0, 0, &dt);
-	if (error != 0 || dt < CC_DT_NONE || dt > CC_DT_UNKNOWN) {
+	if (error != 0 || (unsigned)dt > CC_DT_UNKNOWN) {
 		fprintf(stdout, "illegal\n");
 		return (1);
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201907152343.x6FNhcsm039360>