From 2b05b1c85c85ffbfc58be9b83855961ab80db135 Mon Sep 17 00:00:00 2001 From: arvidn Date: Sat, 11 Jul 2015 10:36:13 -0400 Subject: [PATCH] fix cppcheck warnings --- src/disk_io_thread.cpp | 3 +-- src/peer_connection.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/disk_io_thread.cpp b/src/disk_io_thread.cpp index 54f90a9ff..3985eb3ad 100644 --- a/src/disk_io_thread.cpp +++ b/src/disk_io_thread.cpp @@ -3496,8 +3496,7 @@ namespace libtorrent continue; } - cached_piece_entry* pe = m_disk_cache.find_piece(j); - pe = m_disk_cache.add_dirty_block(j); + cached_piece_entry* pe = m_disk_cache.add_dirty_block(j); if (pe == NULL) { diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index c22ea94f0..180036ecf 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -862,9 +862,10 @@ namespace libtorrent if (on_parole()) ret |= piece_picker::on_parole | piece_picker::prioritize_partials; - // only one of rarest_first and sequential can be set. - TORRENT_ASSERT((ret & piece_picker::rarest_first) ? 1 : 0 - + (ret & piece_picker::sequential) ? 1 : 0 <= 1); + // only one of rarest_first and sequential can be set. i.e. the sum of + // whether the bit is set or not may only be 0 or 1 (never 2) + TORRENT_ASSERT(((ret & piece_picker::rarest_first) ? 1 : 0) + + ((ret & piece_picker::sequential) ? 1 : 0) <= 1); return ret; }