Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 11 Feb 2019 14:50:33 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r344009 - stable/12/sys/cam/scsi
Message-ID:  <201902111450.x1BEoXtE015530@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Mon Feb 11 14:50:33 2019
New Revision: 344009
URL: https://svnweb.freebsd.org/changeset/base/344009

Log:
  MFC r343727: Use switch instead of chained if/else to improve readability.
  
  Submitted by:   Ryan Moeller <ryan@freqlabs.com>
  Sponsored by:   iXsystems, Inc.

Modified:
  stable/12/sys/cam/scsi/scsi_enc_ses.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/cam/scsi/scsi_enc_ses.c
==============================================================================
--- stable/12/sys/cam/scsi/scsi_enc_ses.c	Mon Feb 11 14:50:12 2019	(r344008)
+++ stable/12/sys/cam/scsi/scsi_enc_ses.c	Mon Feb 11 14:50:33 2019	(r344009)
@@ -2729,13 +2729,13 @@ ses_handle_string(enc_softc_t *enc, encioc_string_t *s
 	if (sstr->bufsiz > 0xffff)
 		return (EINVAL); /* buffer size too large */
 
-	if (ioc == ENCIOC_SETSTRING) {
+	switch (ioc) {
+	case ENCIOC_SETSTRING:
 		payload = sstr->bufsiz + 4; /* header for SEND DIAGNOSTIC */
 		amt = 0 - payload;
 		buf = ENC_MALLOC(payload);
 		if (buf == NULL)
-			return ENOMEM;
-
+			return (ENOMEM);
 		ses_page_cdb(cdb, payload, 0, CAM_DIR_OUT);
 		/* Construct the page request */
 		buf[0] = SesStringOut;
@@ -2743,12 +2743,14 @@ ses_handle_string(enc_softc_t *enc, encioc_string_t *s
 		buf[2] = sstr->bufsiz >> 8;
 		buf[3] = sstr->bufsiz & 0xff;
 		memcpy(&buf[4], sstr->buf, sstr->bufsiz);
-	} else if (ioc == ENCIOC_GETSTRING) {
+		break;
+	case ENCIOC_GETSTRING:
 		payload = sstr->bufsiz;
 		amt = payload;
 		ses_page_cdb(cdb, payload, SesStringIn, CAM_DIR_IN);
 		buf = sstr->buf;
-	} else if (ioc == ENCIOC_GETENCNAME) {
+		break;
+	case ENCIOC_GETENCNAME:
 		if (ses_cache->ses_nsubencs < 1)
 			return (ENODEV);
 		enc_desc = ses_cache->subencs[0];
@@ -2768,7 +2770,7 @@ ses_handle_string(enc_softc_t *enc, encioc_string_t *s
 			size = sstr->bufsiz;
 		copyout(str, sstr->buf, size);
 		return (size == rsize ? 0 : ENOMEM);
-	} else if (ioc == ENCIOC_GETENCID) {
+	case ENCIOC_GETENCID:
 		if (ses_cache->ses_nsubencs < 1)
 			return (ENODEV);
 		enc_desc = ses_cache->subencs[0];
@@ -2782,13 +2784,13 @@ ses_handle_string(enc_softc_t *enc, encioc_string_t *s
 			size = sstr->bufsiz;
 		copyout(str, sstr->buf, size);
 		return (size == rsize ? 0 : ENOMEM);
-	} else
-		return EINVAL;
-
+	default:
+		return (EINVAL);
+	}
 	ret = enc_runcmd(enc, cdb, 6, buf, &amt);
 	if (ioc == ENCIOC_SETSTRING)
 		ENC_FREE(buf);
-	return ret;
+	return (ret);
 }
 
 /**



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