Skip to content

Commit 2fe4b4d

Browse files
committed
HID: Zero-initialize pointer members
I'm new to Arduino development, so I'm not sure if variable are zero-initialized by default. Regardless, it's often regarded good practice to explicitly zero-initialize pointers to reduce risk of treating uninitialized pointers as valid.
1 parent 01bc7ae commit 2fe4b4d

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/HID/HID.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,20 +141,19 @@ class HID_ : public PluggableUSBModule
141141
private:
142142
uint8_t epType[2];
143143

144-
HIDSubDescriptor* rootNode;
144+
HIDSubDescriptor* rootNode = nullptr;
145145
uint16_t descriptorSize;
146146

147147
uint8_t protocol;
148148
uint8_t idle;
149149

150150
// Buffer pointer to hold the feature data
151-
HIDReport* rootReport;
151+
HIDReport* rootReport = nullptr;
152152
uint16_t reportCount;
153153

154-
Serial_ *dbg;
155-
156-
const char *serial;
154+
Serial_ *dbg = nullptr;
157155

156+
const char *serial = nullptr;
158157
};
159158

160159
// Replacement for global singleton.

0 commit comments

Comments
 (0)