Skip to content

Commit 049a9ea

Browse files
liebmand-a-v
authored andcommitted
decorate as override virtual methods in WiFiUDP (#5637)
make WiFiUDP destructor virtual add empty virtual destructor to Udp
1 parent bd11d02 commit 049a9ea

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

cores/esp8266/Udp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
class UDP: public Stream {
4242

4343
public:
44+
virtual ~UDP() {};
4445
virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use
4546
virtual void stop() =0; // Finish with the UDP socket
4647

libraries/ESP8266WiFi/src/WiFiUdp.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,26 @@ class WiFiUDP : public UDP, public SList<WiFiUDP> {
3737
WiFiUDP(); // Constructor
3838
WiFiUDP(const WiFiUDP& other);
3939
WiFiUDP& operator=(const WiFiUDP& rhs);
40-
~WiFiUDP();
40+
virtual ~WiFiUDP();
4141

4242
operator bool() const { return _ctx != 0; }
4343

4444
// initialize, start listening on specified port.
4545
// Returns 1 if successful, 0 if there are no sockets available to use
46-
virtual uint8_t begin(uint16_t port);
46+
uint8_t begin(uint16_t port) override;
4747
// Finish with the UDP connetion
48-
virtual void stop();
48+
void stop() override;
4949
// join a multicast group and listen on the given port
5050
uint8_t beginMulticast(IPAddress interfaceAddr, IPAddress multicast, uint16_t port);
5151

5252
// Sending UDP packets
5353

5454
// Start building up a packet to send to the remote host specific in ip and port
5555
// Returns 1 if successful, 0 if there was a problem with the supplied IP address or port
56-
virtual int beginPacket(IPAddress ip, uint16_t port);
56+
int beginPacket(IPAddress ip, uint16_t port) override;
5757
// Start building up a packet to send to the remote host specific in host and port
5858
// Returns 1 if successful, 0 if there was a problem resolving the hostname or port
59-
virtual int beginPacket(const char *host, uint16_t port);
59+
int beginPacket(const char *host, uint16_t port) override;
6060
// Start building up a packet to send to the multicast address
6161
// multicastAddress - muticast address to send to
6262
// interfaceAddress - the local IP address of the interface that should be used
@@ -69,35 +69,35 @@ class WiFiUDP : public UDP, public SList<WiFiUDP> {
6969
int ttl = 1);
7070
// Finish off this packet and send it
7171
// Returns 1 if the packet was sent successfully, 0 if there was an error
72-
virtual int endPacket();
72+
int endPacket() override;
7373
// Write a single byte into the packet
74-
virtual size_t write(uint8_t);
74+
size_t write(uint8_t) override;
7575
// Write size bytes from buffer into the packet
76-
virtual size_t write(const uint8_t *buffer, size_t size);
76+
size_t write(const uint8_t *buffer, size_t size) override;
7777

7878
using Print::write;
7979

8080
// Start processing the next available incoming packet
8181
// Returns the size of the packet in bytes, or 0 if no packets are available
82-
virtual int parsePacket();
82+
int parsePacket() override;
8383
// Number of bytes remaining in the current packet
84-
virtual int available();
84+
int available() override;
8585
// Read a single byte from the current packet
86-
virtual int read();
86+
int read() override;
8787
// Read up to len bytes from the current packet and place them into buffer
8888
// Returns the number of bytes read, or 0 if none are available
89-
virtual int read(unsigned char* buffer, size_t len);
89+
int read(unsigned char* buffer, size_t len) override;
9090
// Read up to len characters from the current packet and place them into buffer
9191
// Returns the number of characters read, or 0 if none are available
92-
virtual int read(char* buffer, size_t len) { return read((unsigned char*)buffer, len); };
92+
int read(char* buffer, size_t len) override { return read((unsigned char*)buffer, len); };
9393
// Return the next byte from the current packet without moving on to the next byte
94-
virtual int peek();
95-
virtual void flush(); // Finish reading the current packet
94+
int peek() override;
95+
void flush() override; // Finish reading the current packet
9696

9797
// Return the IP address of the host who sent the current incoming packet
98-
virtual IPAddress remoteIP() const;
98+
IPAddress remoteIP() const override;
9999
// Return the port of the host who sent the current incoming packet
100-
virtual uint16_t remotePort() const;
100+
uint16_t remotePort() const override;
101101
// Return the destination address for incoming packets,
102102
// useful to distinguish multicast and ordinary packets
103103
IPAddress destinationIP() const;

0 commit comments

Comments
 (0)