Skip to content

Commit 86204ca

Browse files
committed
fix compiler warnings
1 parent ac20bc5 commit 86204ca

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

libraries/ESP8266mDNS/ESP8266mDNS.cpp

+16-8
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ MDNSTxt::~MDNSTxt(){
111111

112112
MDNSAnswer::MDNSAnswer() :
113113
txts(nullptr),
114-
ip({0,0,0,0}),
114+
ip(), //NOTE: should value-initialize to 0
115115
port(0),
116116
hostname(nullptr)
117117
{}
@@ -147,7 +147,7 @@ int MDNSAnswer::numTxt(){
147147
return numTxt;
148148
}
149149

150-
bool MDNSAnswer::hasTxt(char * key){
150+
bool MDNSAnswer::hasTxt(const char * key){
151151
MDNSTxt *txt = txts;
152152
while(txt != nullptr){
153153
if(txt->_txt.startsWith(String(key)+'=')){
@@ -158,7 +158,7 @@ bool MDNSAnswer::hasTxt(char * key){
158158
return false;
159159
}
160160

161-
String MDNSAnswer::getTxt(char * key){
161+
String MDNSAnswer::getTxt(const char * key){
162162
MDNSTxt *txt = txts;
163163
String cmp = String(key)+'=';
164164
while(txt != nullptr){
@@ -441,7 +441,11 @@ int MDNSResponder::queryService(char *service, char *proto) {
441441
};
442442
_conn->append(reinterpret_cast<const char*>(ptrAttrs), 4);
443443
_waitingForAnswers = true;
444-
_conn->send();
444+
if(!_conn->send()){
445+
#ifdef MDNS_DEBUG_ERR
446+
Serial.println("ERROR: Query send failed!");
447+
#endif
448+
}
445449

446450
#ifdef MDNS_DEBUG_TX
447451
Serial.println("Waiting for answers..");
@@ -485,15 +489,15 @@ int MDNSResponder::numTxt(int idx) {
485489
return answer->numTxt();
486490
}
487491

488-
bool MDNSResponder::hasTxt(int idx, char * key) {
492+
bool MDNSResponder::hasTxt(int idx, const char * key) {
489493
MDNSAnswer *answer = _getAnswerFromIdx(idx);
490494
if (answer == nullptr) {
491495
return false;
492496
}
493497
return answer->hasTxt(key);
494498
}
495499

496-
String MDNSResponder::txt(int idx, char * key) {
500+
String MDNSResponder::txt(int idx, const char * key) {
497501
MDNSAnswer *answer = _getAnswerFromIdx(idx);
498502
if (answer == nullptr) {
499503
return String();
@@ -506,7 +510,7 @@ String MDNSResponder::txt(int idx, int txtIdx) {
506510
if (answer == nullptr) {
507511
return String();
508512
}
509-
answer->getTxtString(txtIdx);
513+
return answer->getTxtString(txtIdx);
510514
}
511515

512516
MDNSAnswer* MDNSResponder::getAnswer(int idx) {
@@ -1243,7 +1247,11 @@ void MDNSResponder::_reply(uint8_t replyMask, char * service, char *proto, uint1
12431247
ip_addr_t ifaddr;
12441248
ifaddr.addr = ip;
12451249
_conn->setMulticastInterface(ifaddr);
1246-
_conn->send();
1250+
if(!_conn->send()){
1251+
#ifdef MDNS_DEBUG_ERR
1252+
Serial.println("ERROR: Reply send failed!");
1253+
#endif
1254+
}
12471255
}
12481256

12491257
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_MDNS)

libraries/ESP8266mDNS/ESP8266mDNS.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ friend class MDNSResponder;
7474
IPAddress getIP();
7575
uint16_t getPort();
7676
int numTxt();
77-
bool hasTxt(char * key);
78-
String getTxt(char * key);
77+
bool hasTxt(const char * key);
78+
String getTxt(const char * key);
7979
std::pair<String,String> getTxt(int idx);
8080
String getTxtString(int idx);
8181

@@ -129,8 +129,8 @@ class MDNSResponder {
129129
IPAddress IP(int idx);
130130
uint16_t port(int idx);
131131
int numTxt(int idx);
132-
bool hasTxt(int idx, char * key);
133-
String txt(int idx, char * key);
132+
bool hasTxt(int idx, const char * key);
133+
String txt(int idx, const char * key);
134134
String txt(int idx, int txtIdx);
135135
MDNSAnswer* getAnswer(int idx);
136136

0 commit comments

Comments
 (0)