Don't memset SEvent directly (#15359)

Fixes a compiler warning by manually zeroing the tag and the largest union member instead
This commit is contained in:
sfan5 2024-10-31 19:24:43 +01:00 committed by GitHub
parent 8b85a62310
commit 5c5538685e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 8 deletions

@ -18,7 +18,7 @@ enum EEVENT_TYPE
to mouse or keyboard events. When a GUI element receives an event it will either
process it and return true, or pass the event to its parent. If an event is not absorbed
before it reaches the root element then it will then be passed to the user receiver. */
EET_GUI_EVENT = 0,
EET_GUI_EVENT = 1,
//! A mouse input event.
/** Mouse events are created by the device and passed to IrrlichtDevice::postEventFromUser
@ -332,6 +332,9 @@ struct SEvent
//! True if ctrl was also pressed
bool Control : 1;
//! Is this a simulated mouse event generated by the engine itself?
bool Simulated : 1;
//! A bitmap of button states. You can use isButtonPressed() to determine
//! if a button is pressed or not.
u32 ButtonStates;
@ -347,9 +350,6 @@ struct SEvent
//! Type of mouse event
EMOUSE_INPUT_EVENT Event;
//! Is this a simulated mouse event generated by Minetest itself?
bool Simulated;
};
//! Any kind of keyboard event.
@ -543,8 +543,9 @@ struct SEvent
};
SEvent() {
// would be left uninitialized in many places otherwise
MouseInput.Simulated = false;
EventType = static_cast<EEVENT_TYPE>(0);
// zero the biggest union member we have, which clears all others too
memset(&JoystickEvent, 0, sizeof(JoystickEvent));
}
};

@ -1581,7 +1581,6 @@ bool CIrrDeviceLinux::activateJoysticks(core::array<SJoystickInfo> &joystickInfo
fcntl(info.fd, F_SETFL, O_NONBLOCK);
#endif
(void)memset(&info.persistentData, 0, sizeof(info.persistentData));
info.persistentData.EventType = irr::EET_JOYSTICK_INPUT_EVENT;
info.persistentData.JoystickEvent.Joystick = ActiveJoysticks.size();

@ -1107,7 +1107,6 @@ void GUITable::sendTableEvent(s32 column, bool doubleclick)
m_sel_doubleclick = doubleclick;
if (Parent) {
SEvent e;
memset(&e, 0, sizeof e);
e.EventType = EET_GUI_EVENT;
e.GUIEvent.Caller = this;
e.GUIEvent.Element = 0;