From cb09cefc89425d13fbc587c984c54ca1fc065a26 Mon Sep 17 00:00:00 2001 From: Brian Horton Date: Wed, 20 Mar 2013 13:18:15 -0500 Subject: loops: replace ++ and .size() with C++ iterators where possible. Change-Id: I42a23fe81f08cb533b76ec5ff043bfe31b60bbdd RTC: 52905 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/3697 Tested-by: Jenkins Server Reviewed-by: MIKE J. JONES Reviewed-by: A. Patrick Williams III --- src/usr/targeting/attrrp.C | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'src/usr/targeting/attrrp.C') diff --git a/src/usr/targeting/attrrp.C b/src/usr/targeting/attrrp.C index 7c6c9e55f..b5ae745ef 100644 --- a/src/usr/targeting/attrrp.C +++ b/src/usr/targeting/attrrp.C @@ -154,7 +154,7 @@ namespace TARGETING // Locate corresponding attribute section for message. ssize_t section = -1; - for (size_t i = 0; i < iv_sectionCount; i++) + for (size_t i = 0; i < iv_sectionCount; ++i) { if ((vAddr >= iv_sections[i].vmmAddress) && (vAddr < iv_sections[i].vmmAddress + iv_sections[i].size)) @@ -338,7 +338,7 @@ namespace TARGETING ); // Parse each section. - for (size_t i = 0; i < iv_sectionCount; i++, l_section++) + for (size_t i = 0; i < iv_sectionCount; i++, ++l_section) { iv_sections[i].type = l_section->sectionType; @@ -379,7 +379,7 @@ namespace TARGETING iv_msgQ = msg_q_create(); // Create VMM block for each section, assign permissions. - for (size_t i = 0; i < iv_sectionCount; i++) + for (size_t i = 0; i < iv_sectionCount; ++i) { uint64_t l_perm = 0; switch(iv_sections[i].type) @@ -515,12 +515,15 @@ namespace TARGETING bool l_rc = true; // true if write to section is successful // for each page - for ( size_t i = 0; (i < i_pages.size()) && (true == l_rc); i++ ) + for (std::vector::const_iterator + pageIter = i_pages.begin(); + (pageIter != i_pages.end()) && (true == l_rc); + ++pageIter) { // search for the section we need - for ( size_t j = 0; j < iv_sectionCount; j++ ) + for ( size_t j = 0; j < iv_sectionCount; ++j ) { - if ( iv_sections[j].type == i_pages[i].sectionId ) + if ( iv_sections[j].type == (*pageIter).sectionId ) { // found it.. TARG_DBG( "Writing Attribute Section: ID: %u, " @@ -528,10 +531,10 @@ namespace TARGETING iv_sections[j].type, iv_sections[j].vmmAddress, iv_sections[j].size, - i_pages[i].pageNumber); + (*pageIter).pageNumber); // check that page number is within range - uint64_t l_pageOffset = i_pages[i].pageNumber * PAGESIZE; + uint64_t l_pageOffset = (*pageIter).pageNumber * PAGESIZE; if ( iv_sections[j].size < (l_pageOffset + PAGESIZE) ) { TARG_ERR("page offset 0x%lx is greater than " @@ -549,7 +552,7 @@ namespace TARGETING reinterpret_cast (iv_sections[j].vmmAddress) + l_pageOffset; - memcpy( l_dataPtr, i_pages[i].dataPtr, PAGESIZE ); + memcpy( l_dataPtr, (*pageIter).dataPtr, PAGESIZE ); break; } } @@ -573,7 +576,7 @@ namespace TARGETING uint16_t pages = 0; // search for the section we need - for (size_t i = 0; i < iv_sectionCount; i++ ) + for (size_t i = 0; i < iv_sectionCount; ++i ) { if ( iv_sections[i].type == i_sectionId ) { -- cgit v1.2.1