From 4f7ab6f4f359b7af3b91f87e1926fdc2069c97e6 Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Thu, 26 Nov 2015 12:18:42 +1100 Subject: [PATCH] uORBManager: Make `orb_check` fail safely The `orb_check` function takes a pointer to a `bool` which it then passes to `px4_ioctl`. However, if the call to `px4_ioctl` fails, the bool doesn't get updated (neither set nor cleared). Therefore, in `orb_check` we explicitly set the bool to `false` before passing the pointer to `px4_ioctl`. --- src/modules/uORB/uORBManager_posix.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/modules/uORB/uORBManager_posix.cpp b/src/modules/uORB/uORBManager_posix.cpp index 7fe3f6a687..3a01038b4a 100644 --- a/src/modules/uORB/uORBManager_posix.cpp +++ b/src/modules/uORB/uORBManager_posix.cpp @@ -164,6 +164,8 @@ int uORB::Manager::orb_copy(const struct orb_metadata *meta, int handle, void *b int uORB::Manager::orb_check(int handle, bool *updated) { + /* Set to false here so that if `px4_ioctl` fails to false. */ + *updated = false; return px4_ioctl(handle, ORBIOCUPDATED, (unsigned long)(uintptr_t)updated); }