From d1ce71e9cc4b056908410389c6b5d7c620c94758 Mon Sep 17 00:00:00 2001 From: Chris Frey Date: Tue, 24 Jul 2012 23:02:04 -0400 Subject: [PATCH] lib: removing casts where possible I prefer to use exact variables if possible, instead of casts, in order to clear compiler warnings. I hope this still works on Win32. Reserve casting for actual conversions, such as the cast from float to time_t in Message2Time(), instead of only hiding compiler warnings. A compiler warning fixed only with a cast is a compiler warning that may be incorrectly hidden later. --- src/m_jvmdebug.cc | 8 ++++---- src/time.cc | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/m_jvmdebug.cc b/src/m_jvmdebug.cc index 30969b74..670ffc59 100644 --- a/src/m_jvmdebug.cc +++ b/src/m_jvmdebug.cc @@ -51,7 +51,7 @@ namespace Barry { void JVMModulesList::Parse(const Data &entry_packet) { - uint16_t count = 0; + uint32_t count = 0; size_t size = entry_packet.GetSize(); @@ -62,7 +62,7 @@ void JVMModulesList::Parse(const Data &entry_packet) Protocol::JVMModulesEntry *e = (Protocol::JVMModulesEntry *) ptr; len = SB_JVMMODULES_ENTRY_HEADER_SIZE + be_btohs(e->sizename); - if( (size_t)(count + len) > size ) + if( (count + len) > size ) break; JVMModulesEntry entry; @@ -117,7 +117,7 @@ void JVMModulesEntry::Dump(std::ostream &os) const void JVMThreadsList::Parse(const Data &entry_packet) { - uint16_t count = 0; + uint32_t count = 0; size_t size = entry_packet.GetSize(); @@ -128,7 +128,7 @@ void JVMThreadsList::Parse(const Data &entry_packet) uint32_t *e = (uint32_t *) ptr; len = sizeof(uint32_t); - if( (size_t)(count + len) > size ) + if( (count + len) > size ) break; JVMThreadsEntry entry; diff --git a/src/time.cc b/src/time.cc index a604b65e..a10dd0b1 100644 --- a/src/time.cc +++ b/src/time.cc @@ -220,8 +220,8 @@ time_t Message2Time(uint16_t r_date, uint16_t r_time) dout("Message2Time(0x" << std::hex << btohs(r_date) << ", 0x" << btohs(r_time) << ")"); - time_t result = ( btohs(r_date) & 0x01ff ) - 0x29; - result = DayToDate( (uint16_t)result ); + uint16_t day = ( btohs(r_date) & 0x01ff ) - 0x29; + time_t result = DayToDate( day ); result += (time_t)( btohs(r_time)*1.77 ); dout("Message2Time result: " << ctime(&result)); -- 2.11.4.GIT