From 8d1e3f1f7e35e5bc0c2898ca9c9d840ef9676cd8 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 13 Oct 2015 11:24:32 +1300 Subject: Fix last reported FindBugs issues --- src/org/traccar/protocol/AplicomProtocolDecoder.java | 4 ++++ src/org/traccar/protocol/CellocatorFrameDecoder.java | 4 ++++ src/org/traccar/protocol/Mta6ProtocolDecoder.java | 3 +++ src/org/traccar/protocol/TytanProtocolDecoder.java | 17 +++++++---------- 4 files changed, 18 insertions(+), 10 deletions(-) (limited to 'src/org') diff --git a/src/org/traccar/protocol/AplicomProtocolDecoder.java b/src/org/traccar/protocol/AplicomProtocolDecoder.java index c134a282e..9e0bddfcb 100644 --- a/src/org/traccar/protocol/AplicomProtocolDecoder.java +++ b/src/org/traccar/protocol/AplicomProtocolDecoder.java @@ -248,6 +248,8 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder { case 130: buf.readUnsignedInt(); // incorrect break; + default: + break; } } @@ -321,6 +323,8 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder { case 0x18: position.set("software-version", ChannelBuffers.swapInt(value.readInt()) * 0.01); break; + default: + break; } break; } diff --git a/src/org/traccar/protocol/CellocatorFrameDecoder.java b/src/org/traccar/protocol/CellocatorFrameDecoder.java index 3be0f5dfe..d4650d966 100644 --- a/src/org/traccar/protocol/CellocatorFrameDecoder.java +++ b/src/org/traccar/protocol/CellocatorFrameDecoder.java @@ -19,6 +19,7 @@ import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.handler.codec.frame.FrameDecoder; +import org.traccar.helper.Log; public class CellocatorFrameDecoder extends FrameDecoder { @@ -56,6 +57,9 @@ public class CellocatorFrameDecoder extends FrameDecoder { case CellocatorProtocolDecoder.MSG_CLIENT_MODULAR: length = 15 + buf.getUnsignedByte(13); break; + default: + Log.warning(new UnsupportedOperationException()); + break; } // Read packet diff --git a/src/org/traccar/protocol/Mta6ProtocolDecoder.java b/src/org/traccar/protocol/Mta6ProtocolDecoder.java index 5e9bb5174..c059d6160 100644 --- a/src/org/traccar/protocol/Mta6ProtocolDecoder.java +++ b/src/org/traccar/protocol/Mta6ProtocolDecoder.java @@ -85,6 +85,9 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder { case 3: previousFloat = (previousFloat & 0xff000000) + ((buf.readUnsignedMedium() & 0x3fffff) << 2); break; + default: + Log.warning(new IllegalArgumentException()); + break; } return Float.intBitsToFloat(previousFloat); } diff --git a/src/org/traccar/protocol/TytanProtocolDecoder.java b/src/org/traccar/protocol/TytanProtocolDecoder.java index be9a9afed..d1fdd99d0 100644 --- a/src/org/traccar/protocol/TytanProtocolDecoder.java +++ b/src/org/traccar/protocol/TytanProtocolDecoder.java @@ -174,16 +174,13 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder { break; case 107: int fuel = buf.readUnsignedShort(); - switch (fuel >> 14) { - case 1: - position.set(Event.KEY_FUEL, (fuel & 0x3fff) * 0.4 + "%"); - break; - case 2: - position.set(Event.KEY_FUEL, (fuel & 0x3fff) * 0.5 + " l"); - break; - case 3: - position.set(Event.KEY_FUEL, (fuel & 0x3fff) * -0.5 + " l"); - break; + int fuelFormat = fuel >> 14; + if (fuelFormat == 1) { + position.set(Event.KEY_FUEL, (fuel & 0x3fff) * 0.4 + "%"); + } else if (fuelFormat == 2) { + position.set(Event.KEY_FUEL, (fuel & 0x3fff) * 0.5 + " l"); + } else if (fuelFormat == 3) { + position.set(Event.KEY_FUEL, (fuel & 0x3fff) * -0.5 + " l"); } break; case 108: -- cgit v1.2.3