Commit 58ec60b247300636a825fa1322757ab49e2f07f9

Authored by Wiebe Cazemier
1 parent 6473b379

Fix incorrect use of variable 'dup'

It erroneously referred to the system function 'dup' now...
Showing 1 changed file with 4 additions and 3 deletions
mqttpacket.cpp
@@ -845,13 +845,13 @@ void MqttPacket::handleUnsubscribe() @@ -845,13 +845,13 @@ void MqttPacket::handleUnsubscribe()
845 void MqttPacket::parsePublishData() 845 void MqttPacket::parsePublishData()
846 { 846 {
847 publishData.retain = (first_byte & 0b00000001); 847 publishData.retain = (first_byte & 0b00000001);
848 - bool dup = !!(first_byte & 0b00001000); 848 + const bool duplicate = !!(first_byte & 0b00001000);
849 publishData.qos = (first_byte & 0b00000110) >> 1; 849 publishData.qos = (first_byte & 0b00000110) >> 1;
850 850
851 if (publishData.qos > 2) 851 if (publishData.qos > 2)
852 throw ProtocolError("QoS 3 is a protocol violation.", ReasonCodes::MalformedPacket); 852 throw ProtocolError("QoS 3 is a protocol violation.", ReasonCodes::MalformedPacket);
853 853
854 - if (publishData.qos == 0 && dup) 854 + if (publishData.qos == 0 && duplicate)
855 throw ProtocolError("Duplicate flag is set for QoS 0 packet. This is illegal.", ReasonCodes::MalformedPacket); 855 throw ProtocolError("Duplicate flag is set for QoS 0 packet. This is illegal.", ReasonCodes::MalformedPacket);
856 856
857 publishData.topic = readBytesToString(true, true); 857 publishData.topic = readBytesToString(true, true);
@@ -957,7 +957,8 @@ void MqttPacket::handlePublish() @@ -957,7 +957,8 @@ void MqttPacket::handlePublish()
957 parsePublishData(); 957 parsePublishData();
958 958
959 #ifndef NDEBUG 959 #ifndef NDEBUG
960 - logger->logf(LOG_DEBUG, "Publish received, topic '%s'. QoS=%d. Retain=%d, dup=%d", publishData.topic.c_str(), publishData.qos, publishData.retain, dup); 960 + const bool duplicate = !!(first_byte & 0b00001000);
  961 + logger->logf(LOG_DEBUG, "Publish received, topic '%s'. QoS=%d. Retain=%d, dup=%d", publishData.topic.c_str(), publishData.qos, publishData.retain, duplicate);
961 #endif 962 #endif
962 963
963 ReasonCodes ackCode = ReasonCodes::Success; 964 ReasonCodes ackCode = ReasonCodes::Success;