Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 7 Jul 2019 18:29:10 +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: r349813 - stable/12/sys/cam/scsi
Message-ID:  <201907071829.x67ITAJs064400@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Sun Jul  7 18:29:10 2019
New Revision: 349813
URL: https://svnweb.freebsd.org/changeset/base/349813

Log:
  MFC r349281: Fix individual_element_index when some type has 0 elements.
  
  When some type has 0 elements, saved_individual_element_index was set
  to -1 on second type bump, since individual_element_index was not
  restored after the first.  To me it looks easier just to increment
  saved_individual_element_index separately than think when to save it.

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	Sun Jul  7 17:45:17 2019	(r349812)
+++ stable/12/sys/cam/scsi/scsi_enc_ses.c	Sun Jul  7 18:29:10 2019	(r349813)
@@ -444,6 +444,7 @@ ses_iter_next(struct ses_iterator *iter)
 		iter->type_element_index       = ITERATOR_INDEX_END;
 		iter->global_element_index     = ITERATOR_INDEX_END;
 		iter->individual_element_index = ITERATOR_INDEX_END;
+		iter->saved_individual_element_index = ITERATOR_INDEX_END;
 		return (NULL);
 	}
 
@@ -468,17 +469,12 @@ ses_iter_next(struct ses_iterator *iter)
 		 */
 		iter->type_index++;
 		iter->type_element_index = 0;
-		iter->saved_individual_element_index
-		    = iter->individual_element_index;
 		iter->individual_element_index = ITERATOR_INDEX_INVALID;
 	}
 
 	if (iter->type_element_index > 0) {
-		if (iter->type_element_index == 1) {
-			iter->individual_element_index
-			    = iter->saved_individual_element_index;
-		}
-		iter->individual_element_index++;
+		iter->individual_element_index =
+		    ++iter->saved_individual_element_index;
 	}
 
 	return (&iter->cache->elm_map[iter->global_element_index]);



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