From 79a24c200ef2b2ce0268b80cf5425c02d458ed56 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Mon, 7 Dec 2020 10:27:31 +0800 Subject: [PATCH] use autogened protobuf init code --- src/mesh/MeshService.cpp | 4 +--- src/plugins/RemoteHardwarePlugin.cpp | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/mesh/MeshService.cpp b/src/mesh/MeshService.cpp index 059cd70d..afd5a6d4 100644 --- a/src/mesh/MeshService.cpp +++ b/src/mesh/MeshService.cpp @@ -194,9 +194,7 @@ int MeshService::onGPSChanged(const meshtastic::GPSStatus *unused) { // Update our local node info with our position (even if we don't decide to update anyone else) - Position pos; - - memset(&pos, 0, sizeof(pos)); + Position pos = Position_init_default; if (gps->hasLock()) { if (gps->altitude != 0) diff --git a/src/plugins/RemoteHardwarePlugin.cpp b/src/plugins/RemoteHardwarePlugin.cpp index 085d7d69..eab0f125 100644 --- a/src/plugins/RemoteHardwarePlugin.cpp +++ b/src/plugins/RemoteHardwarePlugin.cpp @@ -13,6 +13,7 @@ RemoteHardwarePlugin remoteHardwarePlugin; // A macro for clearing a struct, FIXME, move elsewhere #define CLEAR_STRUCT(r) memset(&r, 0, sizeof(r)) + bool RemoteHardwarePlugin::handleReceivedProtobuf(const MeshPacket &req, const HardwareMessage &p) { switch (p.typ) { @@ -43,8 +44,7 @@ bool RemoteHardwarePlugin::handleReceivedProtobuf(const MeshPacket &req, const H } // Send the reply - HardwareMessage reply; - CLEAR_STRUCT(reply); + HardwareMessage reply = HardwareMessage_init_default; reply.typ = HardwareMessage_Type_READ_GPIOS_REPLY; reply.gpio_value = res; MeshPacket *p = allocDataProtobuf(reply);