From f97f21c17f24e1d426e5b5863676071a5809b185 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 10 Dec 2022 00:04:07 +0200 Subject: [PATCH] Use the override specifier when overriding --- source/http/request.h | 2 +- source/http/response.h | 2 +- source/http/submessage.h | 2 +- source/net/clientsocket.h | 4 ++-- source/net/communicator.cpp | 2 +- source/net/datagramsocket.h | 4 ++-- source/net/inet.h | 8 ++++---- source/net/inet6.h | 8 ++++---- source/net/protocol.h | 12 ++++++------ source/net/resolve.h | 2 +- source/net/serversocket.h | 4 ++-- source/net/socket.h | 6 +++--- source/net/streamserversocket.h | 4 ++-- source/net/streamsocket.h | 4 ++-- source/net/unix.h | 8 ++++---- 15 files changed, 36 insertions(+), 36 deletions(-) diff --git a/source/http/request.h b/source/http/request.h index ec5030e..979c785 100644 --- a/source/http/request.h +++ b/source/http/request.h @@ -17,7 +17,7 @@ public: Request(const std::string &, const std::string &); const std::string &get_method() const { return method; } const std::string &get_path() const { return path; } - virtual std::string str() const; + std::string str() const override; static Request parse(const std::string &); static Request from_url(const std::string &); diff --git a/source/http/response.h b/source/http/response.h index 8d88c92..f7c6812 100644 --- a/source/http/response.h +++ b/source/http/response.h @@ -16,7 +16,7 @@ private: public: Response(Status); Status get_status() const { return status; } - virtual std::string str() const; + std::string str() const override; static Response parse(const std::string &); }; diff --git a/source/http/submessage.h b/source/http/submessage.h index 9cf4d2c..7ef9e37 100644 --- a/source/http/submessage.h +++ b/source/http/submessage.h @@ -12,7 +12,7 @@ private: SubMessage() = default; public: - virtual std::string str() const; + std::string str() const override; static SubMessage parse(const std::string &); }; diff --git a/source/net/clientsocket.h b/source/net/clientsocket.h index ab83322..672c32b 100644 --- a/source/net/clientsocket.h +++ b/source/net/clientsocket.h @@ -42,8 +42,8 @@ public: const SockAddr &get_peer_address() const; protected: - virtual std::size_t do_write(const char *, std::size_t); - virtual std::size_t do_read(char *, std::size_t); + std::size_t do_write(const char *, std::size_t) override; + std::size_t do_read(char *, std::size_t) override; }; } // namespace Net diff --git a/source/net/communicator.cpp b/source/net/communicator.cpp index f74f4d3..05ef0ea 100644 --- a/source/net/communicator.cpp +++ b/source/net/communicator.cpp @@ -35,7 +35,7 @@ private: public: HandshakeReceiver(); uint64_t get_hash() const { return hash; } - virtual void receive(const Handshake &); + void receive(const Handshake &) override; }; HandshakeReceiver::HandshakeReceiver(): diff --git a/source/net/datagramsocket.h b/source/net/datagramsocket.h index 678a844..e5ded78 100644 --- a/source/net/datagramsocket.h +++ b/source/net/datagramsocket.h @@ -11,8 +11,8 @@ class DatagramSocket: public ClientSocket public: DatagramSocket(Family, int = 0); - virtual bool connect(const SockAddr &); - virtual bool poll_connect(const Time::TimeDelta &) { return false; } + bool connect(const SockAddr &) override; + bool poll_connect(const Time::TimeDelta &) override { return false; } std::size_t sendto(const char *, std::size_t, const SockAddr &); std::size_t recvfrom(char *, std::size_t, SockAddr *&); diff --git a/source/net/inet.h b/source/net/inet.h index 639e64c..67bb610 100644 --- a/source/net/inet.h +++ b/source/net/inet.h @@ -19,13 +19,13 @@ public: InetAddr(); InetAddr(const SysAddr &); - virtual InetAddr *copy() const { return new InetAddr(*this); } + InetAddr *copy() const override { return new InetAddr(*this); } - virtual SysAddr to_sys() const; + SysAddr to_sys() const override; - virtual Family get_family() const { return INET; } + Family get_family() const override { return INET; } unsigned get_port() const { return port; } - virtual std::string str() const; + std::string str() const override; }; } // namespace Net diff --git a/source/net/inet6.h b/source/net/inet6.h index cc33e76..fb07eec 100644 --- a/source/net/inet6.h +++ b/source/net/inet6.h @@ -16,13 +16,13 @@ public: Inet6Addr(); Inet6Addr(const SysAddr &); - virtual Inet6Addr *copy() const { return new Inet6Addr(*this); } + Inet6Addr *copy() const override { return new Inet6Addr(*this); } - virtual SysAddr to_sys() const; + SysAddr to_sys() const override; - virtual Family get_family() const { return INET6; } + Family get_family() const override { return INET6; } unsigned get_port() const { return port; } - virtual std::string str() const; + std::string str() const override; }; } // namespace Net diff --git a/source/net/protocol.h b/source/net/protocol.h index aca3ca8..ff18e85 100644 --- a/source/net/protocol.h +++ b/source/net/protocol.h @@ -50,9 +50,9 @@ private: CompoundDef(const S &); - virtual std::string describe() const; - virtual char *serialize(const C &, char *, char *) const; - virtual const char *deserialize(C &, const char *, const char *) const; + std::string describe() const override; + char *serialize(const C &, char *, char *) const override; + const char *deserialize(C &, const char *, const char *) const override; }; template @@ -183,17 +183,17 @@ private: PacketTypeDef(unsigned); ~PacketTypeDef(); - virtual unsigned get_class_id() const { return get_packet_class_id

(); } + unsigned get_class_id() const override { return get_packet_class_id

(); } template void set_serializer(const S &); const CompoundTypeDef

&get_compound() const { return *compound; } - virtual std::string describe() const { return compound->describe(); } + std::string describe() const override { return compound->describe(); } char *serialize(const P &, char *, char *) const; const char *deserialize(P &, const char *, const char *) const; - virtual const char *dispatch(ReceiverBase &, const char *, const char *) const; + const char *dispatch(ReceiverBase &, const char *, const char *) const override; }; template diff --git a/source/net/resolve.h b/source/net/resolve.h index 5e7781d..b006aff 100644 --- a/source/net/resolve.h +++ b/source/net/resolve.h @@ -68,7 +68,7 @@ private: IO::Pipe &get_notify_pipe() { return notify_pipe; } private: - virtual void main(); + void main() override; }; public: diff --git a/source/net/serversocket.h b/source/net/serversocket.h index dd892e0..48ab9ba 100644 --- a/source/net/serversocket.h +++ b/source/net/serversocket.h @@ -22,8 +22,8 @@ public: virtual ClientSocket *accept() = 0; protected: - virtual std::size_t do_write(const char *, std::size_t); - virtual std::size_t do_read(char *, std::size_t); + std::size_t do_write(const char *, std::size_t) override; + std::size_t do_read(char *, std::size_t) override; }; } // namespace Net diff --git a/source/net/socket.h b/source/net/socket.h index 2e736e9..d917bd8 100644 --- a/source/net/socket.h +++ b/source/net/socket.h @@ -41,10 +41,10 @@ private: public: ~Socket(); - virtual void set_block(bool); - virtual void set_inherit(bool); + void set_block(bool) override; + void set_inherit(bool) override; const IO::Handle &get_handle(IO::Mode); - virtual const IO::Handle &get_event_handle(); + const IO::Handle &get_event_handle() override; /** Associates the socket with a local address. There must be no existing users of the address. */ diff --git a/source/net/streamserversocket.h b/source/net/streamserversocket.h index 3152265..d38c2eb 100644 --- a/source/net/streamserversocket.h +++ b/source/net/streamserversocket.h @@ -15,9 +15,9 @@ private: public: StreamServerSocket(Family, int = 0); - virtual void listen(const SockAddr &, unsigned = 4); + void listen(const SockAddr &, unsigned = 4) override; bool is_listening() const { return listening; } - virtual StreamSocket *accept(); + StreamSocket *accept() override; }; } // namespace Net diff --git a/source/net/streamsocket.h b/source/net/streamsocket.h index 8b39e91..b6d43b5 100644 --- a/source/net/streamsocket.h +++ b/source/net/streamsocket.h @@ -23,9 +23,9 @@ public: If the socket is non-blocking, this function may return before the connection is fully established. The caller must then use either the poll_connect function or an EventDispatcher to finish the process. */ - virtual bool connect(const SockAddr &); + bool connect(const SockAddr &) override; - virtual bool poll_connect(const Time::TimeDelta &); + bool poll_connect(const Time::TimeDelta &) override; private: void on_event(IO::PollEvent); diff --git a/source/net/unix.h b/source/net/unix.h index 821e915..ec65164 100644 --- a/source/net/unix.h +++ b/source/net/unix.h @@ -17,12 +17,12 @@ public: UnixAddr(const SysAddr &); UnixAddr(const std::string &, bool = false); - virtual UnixAddr *copy() const { return new UnixAddr(*this); } + UnixAddr *copy() const override { return new UnixAddr(*this); } - virtual SysAddr to_sys() const; + SysAddr to_sys() const override; - virtual Family get_family() const { return UNIX; } - virtual std::string str() const; + Family get_family() const override { return UNIX; } + std::string str() const override; }; } // namespace Net -- 2.43.0