Skip to content

Commit

Permalink
Fix clang and MSVC warnings/errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
kristomu committed Sep 1, 2024
1 parent f717383 commit 333b48c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
2 changes: 0 additions & 2 deletions src/multiwinner/auction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ int r_auction::elect_and_update(std::vector<bool> & elected,
// to the sum (for all non-elected candidates). Note the potential
// for vote-management.
size_t counter = 0;
double voters = 0;

for (election_t::const_iterator pos = ballots.begin(); pos !=
ballots.end(); ++pos) {
assert(pos->rated);
voters += pos->get_weight(); // not req'd?

double adjust = 0; // maximum if not cumulative, sum if so.
ordering::const_iterator sec;
Expand Down
8 changes: 2 additions & 6 deletions src/multiwinner/qpq.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ std::list<size_t> QPQ::get_council(std::vector<bool> & eliminated,
contributing_weights(num_candidates), quotients(num_candidates);

std::list<size_t> council;
size_t num_elected = 0, num_elim = 0;
size_t num_elected = 0;

std::vector<bool> elected(num_candidates, false);

Expand Down Expand Up @@ -104,18 +104,15 @@ std::list<size_t> QPQ::get_council(std::vector<bool> & eliminated,
counter = 0;

double inactive_ballot_fraction = 0,
active_ballots = 0, sum_weights = 0;
active_ballots = 0;

// Bah dual track. Get the active and inactive ballot data.

for (pos = ballots.begin(); pos != ballots.end(); ++pos) {
ordering::const_iterator contribute =
ballot_contribution(eliminated, elected, *pos);

sum_weights += elect_fraction[counter] * pos->get_weight();

if (contribute == pos->contents.end()) {
//inactive_ballots += pos->get_weight();
inactive_ballot_fraction +=
elect_fraction[counter] * pos->get_weight();
} else {
Expand Down Expand Up @@ -228,7 +225,6 @@ std::list<size_t> QPQ::get_council(std::vector<bool> & eliminated,
// reset set to true, tail-recurse. Otherwise, just loop
// through.
eliminated[lowest] = true;
++num_elim;

// TODO: Heuristic that automatically elects rest if
// just enough to fill council.
Expand Down
2 changes: 0 additions & 2 deletions src/multiwinner/qrange_stv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ int QRangeSTV::elect_next(size_t council_size, size_t num_candidates,
// i.e...

double p_y = quota / count_quad[winner];
double verify = 0;

election_t::iterator pos = altered_ballots.begin();

Expand All @@ -165,7 +164,6 @@ int QRangeSTV::elect_next(size_t council_size, size_t num_candidates,
pos = altered_ballots.erase(pos);
} else {
pos->set_weight(std::max(0.0, pos->get_weight() - subtr));
verify += pos->get_weight() * winner_score;
++pos;
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/tools/tools.cc
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,12 @@ std::vector<std::vector<bool> > power_set(
}
}

assert(power_set_out.size() == (1ULL << num_hopefuls));
// Can't use assert because then clang will complain when making
// a Release build.
if (power_set_out.size() != (1ULL << num_hopefuls)) {
throw std::logic_error("power_set: output set is of the wrong size! "
"This is a bug.");
}

return power_set_out;
}
Expand Down
2 changes: 2 additions & 0 deletions src/tools/tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <vector>
#include <map>

typedef ptrdiff_t ssize_t; /* ssize_t is not part of the C standard */

const double PI = 4 * atan(1);

// Transforms parameters of 0 1 2 ... skip skip+1 ... into
Expand Down

0 comments on commit 333b48c

Please sign in to comment.