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 845 void MqttPacket::parsePublishData()
846 846 {
847 847 publishData.retain = (first_byte & 0b00000001);
848   - bool dup = !!(first_byte & 0b00001000);
  848 + const bool duplicate = !!(first_byte & 0b00001000);
849 849 publishData.qos = (first_byte & 0b00000110) >> 1;
850 850  
851 851 if (publishData.qos > 2)
852 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 855 throw ProtocolError("Duplicate flag is set for QoS 0 packet. This is illegal.", ReasonCodes::MalformedPacket);
856 856  
857 857 publishData.topic = readBytesToString(true, true);
... ... @@ -957,7 +957,8 @@ void MqttPacket::handlePublish()
957 957 parsePublishData();
958 958  
959 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 962 #endif
962 963  
963 964 ReasonCodes ackCode = ReasonCodes::Success;
... ...