Skip to content

Commit 32f615e

Browse files
authored
Merge pull request #12495 from kjbracey-arm/override_serial
C++11-ify virtualisation in FileHandle + Serials
2 parents 98db255 + c39959c commit 32f615e

File tree

5 files changed

+31
-31
lines changed

5 files changed

+31
-31
lines changed

drivers/BufferedSerial.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@ class BufferedSerial:
8080
int baud = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE
8181
);
8282

83-
virtual ~BufferedSerial();
83+
~BufferedSerial() override;
8484

8585
/** Equivalent to POSIX poll(). Derived from FileHandle.
8686
* Provides a mechanism to multiplex input/output over a set of file
8787
* handles.
8888
* The events that can be reported are POLLIN, POLLOUT, POLLHUP.
8989
*/
90-
virtual short poll(short events) const;
90+
short poll(short events) const final;
9191

9292
/* Resolve ambiguities versus our private SerialBase
9393
* (for writable, spelling differs, but just in case)
@@ -107,7 +107,7 @@ class BufferedSerial:
107107
* @param length The number of bytes to write
108108
* @return The number of bytes written, negative error on failure
109109
*/
110-
virtual ssize_t write(const void *buffer, size_t length);
110+
ssize_t write(const void *buffer, size_t length) override;
111111

112112
/** Read the contents of a file into a buffer
113113
*
@@ -123,21 +123,21 @@ class BufferedSerial:
123123
* @return The number of bytes read, 0 at end of file, negative
124124
* error on failure
125125
*/
126-
virtual ssize_t read(void *buffer, size_t length);
126+
ssize_t read(void *buffer, size_t length) override;
127127

128128
/** Close a file
129129
*
130130
* @return 0 on success, negative error code on failure
131131
*/
132-
virtual int close();
132+
int close() override;
133133

134134
/** Check if the file in an interactive terminal device
135135
*
136136
* @return True if the file is a terminal
137137
* @return False if the file is not a terminal
138138
* @return Negative error code on failure
139139
*/
140-
virtual int isatty();
140+
int isatty() override;
141141

142142
/** Move the file position to a given offset from from a given location
143143
*
@@ -152,20 +152,20 @@ class BufferedSerial:
152152
* @return The new offset of the file, negative error code on
153153
* failure
154154
*/
155-
virtual off_t seek(off_t offset, int whence);
155+
off_t seek(off_t offset, int whence) override;
156156

157157
/** Flush any buffers associated with the file
158158
*
159159
* @return 0 on success, negative error code on failure
160160
*/
161-
virtual int sync();
161+
int sync() override;
162162

163163
/** Set blocking or non-blocking mode
164164
* The default is blocking.
165165
*
166166
* @param blocking true for blocking mode, false for non-blocking mode.
167167
*/
168-
virtual int set_blocking(bool blocking)
168+
int set_blocking(bool blocking) override
169169
{
170170
_blocking = blocking;
171171
return 0;
@@ -175,7 +175,7 @@ class BufferedSerial:
175175
*
176176
* @return true for blocking mode, false for non-blocking mode.
177177
*/
178-
virtual bool is_blocking() const
178+
bool is_blocking() const override
179179
{
180180
return _blocking;
181181
}
@@ -193,7 +193,7 @@ class BufferedSerial:
193193
* @return 0 on success
194194
* @return Negative error code on failure
195195
*/
196-
virtual int enable_input(bool enabled);
196+
int enable_input(bool enabled) override;
197197

198198
/** Enable or disable output
199199
*
@@ -208,7 +208,7 @@ class BufferedSerial:
208208
* @return 0 on success
209209
* @return Negative error code on failure
210210
*/
211-
virtual int enable_output(bool enabled);
211+
int enable_output(bool enabled) override;
212212

213213
/** Register a callback on state change of the file.
214214
*
@@ -227,7 +227,7 @@ class BufferedSerial:
227227
*
228228
* @param func Function to call on state change
229229
*/
230-
virtual void sigio(Callback<void()> func);
230+
void sigio(Callback<void()> func) override;
231231

232232
/** Setup interrupt handler for DCD line
233233
*
@@ -288,11 +288,11 @@ class BufferedSerial:
288288

289289
/** Acquire mutex
290290
*/
291-
virtual void api_lock(void);
291+
void api_lock(void);
292292

293293
/** Release mutex
294294
*/
295-
virtual void api_unlock(void);
295+
void api_unlock(void);
296296

297297
/** Unbuffered write - invoked when write called from critical section
298298
* @param buf_ptr The buffer to write from

drivers/SerialWireOutput.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,35 +35,35 @@ class SerialWireOutput : public FileHandle {
3535

3636
public:
3737

38-
SerialWireOutput(void);
38+
SerialWireOutput();
3939

40-
virtual ssize_t write(const void *buffer, size_t size);
40+
ssize_t write(const void *buffer, size_t size) override;
4141

42-
virtual ssize_t read(void *buffer, size_t size)
42+
ssize_t read(void *buffer, size_t size) override
4343
{
4444
/* Reading is not supported by this file handle */
4545
return -EBADF;
4646
}
4747

48-
virtual off_t seek(off_t offset, int whence = SEEK_SET)
48+
off_t seek(off_t offset, int whence = SEEK_SET) override
4949
{
5050
/* Seeking is not support by this file handler */
5151
return -ESPIPE;
5252
}
5353

54-
virtual off_t size()
54+
off_t size() override
5555
{
5656
/* Size is not defined for this file handle */
5757
return -EINVAL;
5858
}
5959

60-
virtual int isatty()
60+
int isatty() override
6161
{
6262
/* File handle is used for terminal output */
6363
return true;
6464
}
6565

66-
virtual int close()
66+
int close() override
6767
{
6868
return 0;
6969
}

drivers/UnbufferedSerial.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class UnbufferedSerial:
8585
* @param size The number of bytes to write
8686
* @return The number of bytes written
8787
*/
88-
virtual ssize_t write(const void *buffer, size_t size);
88+
ssize_t write(const void *buffer, size_t size) override;
8989

9090
/** Read the contents of a file into a buffer
9191
*
@@ -95,7 +95,7 @@ class UnbufferedSerial:
9595
* @param size The number of bytes to read
9696
* @return The number of bytes read
9797
*/
98-
virtual ssize_t read(void *buffer, size_t size);
98+
ssize_t read(void *buffer, size_t size) override;
9999

100100
/** Move the file position to a given offset from from a given location
101101
*
@@ -109,7 +109,7 @@ class UnbufferedSerial:
109109
* SEEK_END to start from end of file
110110
* @return The new offset of the file, negative error code on failure
111111
*/
112-
virtual off_t seek(off_t offset, int whence = SEEK_SET)
112+
off_t seek(off_t offset, int whence = SEEK_SET) override
113113
{
114114
return -ESPIPE;
115115
}
@@ -118,7 +118,7 @@ class UnbufferedSerial:
118118
*
119119
* @return Size of the file in bytes
120120
*/
121-
virtual off_t size()
121+
off_t size() override
122122
{
123123
return -EINVAL;
124124
}
@@ -129,7 +129,7 @@ class UnbufferedSerial:
129129
* @return False if the file is not a terminal
130130
* @return Negative error code on failure
131131
*/
132-
virtual int isatty()
132+
int isatty() override
133133
{
134134
return true;
135135
}
@@ -138,7 +138,7 @@ class UnbufferedSerial:
138138
*
139139
* @return 0 on success, negative error code on failure
140140
*/
141-
virtual int close()
141+
int close() override
142142
{
143143
return 0;
144144
}
@@ -153,7 +153,7 @@ class UnbufferedSerial:
153153
*
154154
* @returns bitmask of poll events that have occurred.
155155
*/
156-
virtual short poll(short events) const;
156+
short poll(short events) const override;
157157

158158
using SerialBase::readable;
159159
using SerialBase::writeable;

drivers/source/SerialWireOutput.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
namespace mbed {
2525

26-
SerialWireOutput::SerialWireOutput(void)
26+
SerialWireOutput::SerialWireOutput()
2727
{
2828
/* Initialize ITM using internal init function. */
2929
mbed_itm_init();

platform/FileHandle.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ namespace mbed {
4545
*/
4646
class FileHandle : private NonCopyable<FileHandle> {
4747
public:
48-
virtual ~FileHandle() {}
48+
virtual ~FileHandle() = default;
4949

5050
/** Read the contents of a file into a buffer
5151
*

0 commit comments

Comments
 (0)