Value stored to unread variable in map_io/widelands_map_buildingdata_data_packet.cc

Bug #1205901 reported by Hans Joachim Desserud
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
widelands
Fix Released
Low
cghislai

Bug Description

On line 271 map_io/widelands_map_buildingdata_data_packet.cc, the variable done is assigned the value true. However, the next line breaks out of the loop and that variable is never read beyond that point.

Found by scan-build in r6675.

Revision history for this message
cghislai (charlyghislain) wrote :

yes that var is useless. The block could be replaced by
 // iterate through all buildings to find first predecessor
 const Tribe_Descr & t = b.descr().tribe();
 while (true) {
  const Building_Descr * oldest = b.m_old_buildings.front();
  if (!oldest->is_enhanced()) {
   break;
  }
  const Building_Index & oldest_idx = t.building_index(oldest->name());
  for (Building_Index i = Building_Index::First(); i < t.get_nrbuildings(); ++i) {
   Building_Descr const * ob = t.get_building_descr(i);
   if (ob->enhancements().count(oldest_idx)) {
    b.m_old_buildings.insert(b.m_old_buildings.begin(), ob);
    break;
   }
  }
 }
}

Changed in widelands:
status: New → Confirmed
assignee: nobody → cghislai (charlyghislain)
milestone: none → build18-rc1
Revision history for this message
SirVer (sirver) wrote :

Fixed in r6677.

Changed in widelands:
status: Confirmed → Fix Committed
Revision history for this message
SirVer (sirver) wrote :

Released in build-18 rc1.

Changed in widelands:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.