knolleary / pubsubclient

A client library for the Arduino Ethernet Shield that provides support for MQTT.
http://pubsubclient.knolleary.net/
MIT License
3.78k stars 1.46k forks source link

fixed warning of integer comparsion #1056

Open tolacika opened 2 months ago

tolacika commented 2 months ago

I got this warning on build:

.pio\libdeps\esp01s\PubSubClient\src\PubSubClient.cpp: In member function 'boolean PubSubClient::publish_P(const char*, const uint8_t*, unsigned int, boolean)':
.pio\libdeps\esp01s\PubSubClient\src\PubSubClient.cpp:523:16: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Wsign-compare]
  523 |     return (rc == expectedLength);
      |             ~~~^~~~~~~~~~~~~~~~~

I think the expected length should also be unsigned, negative length should not be interpreted.

hmueller01 commented 2 months ago

Hey @tolacika, thanks for doing this PR. But this is a long known bug, see also #1045 first item I mentioned. I did a merge of all the suggestions in my fork and didn't get a negative response yet. https://github.com/hmueller01/pubsubclient/tree/dev-fixes Maybe you like to test this as well. Hope that @knolleary likes to merge all this here soon.

tolacika commented 2 months ago

@hmueller01 thank you, I'll try it soon 😉