You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by jm...@apache.org on 2018/01/06 00:21:01 UTC
[incubator-plc4x] 01/03: fix up switch and endless loops
This is an automated email from the ASF dual-hosted git repository.
jmclean pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-plc4x.git
commit ff882df35e2487502d7865d5f546ed235e225547
Author: Justin Mclean <jm...@apache.org>
AuthorDate: Sat Jan 6 11:20:00 2018 +1100
fix up switch and endless loops
---
.../plc4x/java/s7/netty/Plc4XS7Protocol.java | 26 +++++++++++++---------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/s7/netty/Plc4XS7Protocol.java b/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/s7/netty/Plc4XS7Protocol.java
index 6a75419..ed69c1f 100644
--- a/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/s7/netty/Plc4XS7Protocol.java
+++ b/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/s7/netty/Plc4XS7Protocol.java
@@ -341,22 +341,26 @@ public class Plc4XS7Protocol extends MessageToMessageCodec<S7Message, PlcRequest
////////////////////////////////////////////////////////////////////////////////
private ResponseCode decodeResponseCode(DataTransportErrorCode dataTransportErrorCode) {
- if(dataTransportErrorCode != null) {
- switch (dataTransportErrorCode) {
- case OK:
- return ResponseCode.OK;
- case NOT_FOUND:
- return ResponseCode.NOT_FOUND;
- case INVALID_ADDRESS:
- return ResponseCode.INVALID_ADDRESS;
- }
+ if (dataTransportErrorCode == null) {
+ return ResponseCode.INTERNAL_ERROR;
+ }
+ switch (dataTransportErrorCode) {
+ case OK:
+ return ResponseCode.OK;
+ case NOT_FOUND:
+ return ResponseCode.NOT_FOUND;
+ case INVALID_ADDRESS:
+ return ResponseCode.INVALID_ADDRESS;
+ default:
+ return ResponseCode.INTERNAL_ERROR;
}
- return ResponseCode.INTERNAL_ERROR;
}
private List<Object> decodeData(Class<?> datatype, byte[] s7Data) throws PlcProtocolException {
List<Object> result = new LinkedList<>();
- for(int i = 0; i < s7Data.length;) {
+ int i = 0;
+
+ while (i < s7Data.length) {
if (datatype == Boolean.class) {
result.add((s7Data[i] & 0x01) == 0x01);
i+=1;
--
To stop receiving notification emails like this one, please contact
"commits@plc4x.apache.org" <co...@plc4x.apache.org>.