pw_{multisync, thread}: Enforce pw::Status return checks

Add missing pw::Status return checks to allow PW_STATUS_CFG_CHECK_IF_USED to be enabled

Bug: b/247812747

Change-Id: I449f0f6e8bd1441ba81a952ccd1fd7c11aeed530
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/111630
Commit-Queue: Armando Montanez <amontanez@google.com>
Commit-Queue: Mahitha Rachumalla <rachumalla@google.com>
Reviewed-by: Armando Montanez <amontanez@google.com>
Reviewed-by: Carlos Chinchilla <cachinchilla@google.com>
diff --git a/pw_multisink/util.cc b/pw_multisink/util.cc
index 825701d..e8b4819 100644
--- a/pw_multisink/util.cc
+++ b/pw_multisink/util.cc
@@ -25,8 +25,10 @@
                                pw::log::LogEntries::StreamEncoder& encoder,
                                size_t max_num_entries) {
   auto callback = [&encoder](ConstByteSpan entry) {
-    encoder.WriteBytes(
-        static_cast<uint32_t>(pw::log::LogEntries::Fields::ENTRIES), entry);
+    encoder
+        .WriteBytes(static_cast<uint32_t>(pw::log::LogEntries::Fields::ENTRIES),
+                    entry)
+        .IgnoreError();
   };
   return sink.UnsafeForEachEntry(callback, max_num_entries);
 }
diff --git a/pw_thread/snapshot.cc b/pw_thread/snapshot.cc
index cfc36ce..4754420 100644
--- a/pw_thread/snapshot.cc
+++ b/pw_thread/snapshot.cc
@@ -33,9 +33,9 @@
                      Thread::StreamEncoder& encoder,
                      const ProcessThreadStackCallback& thread_stack_callback) {
   // TODO(b/234890430): Add support for ascending stacks.
-  encoder.WriteStackStartPointer(stack.stack_high_addr);
-  encoder.WriteStackEndPointer(stack.stack_low_addr);
-  encoder.WriteStackPointer(stack.stack_pointer);
+  encoder.WriteStackStartPointer(stack.stack_high_addr).IgnoreError();
+  encoder.WriteStackEndPointer(stack.stack_low_addr).IgnoreError();
+  encoder.WriteStackPointer(stack.stack_pointer).IgnoreError();
   // The PRIuPTR is an appropriate format specifier for uintptr_t values
   // https://stackoverflow.com/a/5796039/1224002
   PW_LOG_DEBUG("Active stack: 0x%08" PRIuPTR "x-0x%08" PRIuPTR "x (%ld bytes)",
@@ -46,7 +46,7 @@
   if (stack.stack_pointer_est_peak.has_value()) {
     const uintptr_t stack_pointer_est_peak =
         stack.stack_pointer_est_peak.value();
-    encoder.WriteStackPointerEstPeak(stack_pointer_est_peak);
+    encoder.WriteStackPointerEstPeak(stack_pointer_est_peak).IgnoreError();
     PW_LOG_DEBUG("Est peak stack: 0x%08" PRIuPTR "x-0x%08" PRIuPTR
                  "x (%ld bytes)",
                  stack.stack_high_addr,
diff --git a/pw_thread/thread_snapshot_service.cc b/pw_thread/thread_snapshot_service.cc
index df87eac..02114d0 100644
--- a/pw_thread/thread_snapshot_service.cc
+++ b/pw_thread/thread_snapshot_service.cc
@@ -107,8 +107,8 @@
 
   ConstByteSpan name_request;
   if (!request.empty()) {
-    Status status = DecodeThreadName(request, name_request);
-    if (!status.ok()) {
+    if (const auto status = DecodeThreadName(request, name_request);
+        !status.ok()) {
       PW_LOG_ERROR("Service unable to decode thread name with error code %d",
                    status.code());
     }
@@ -142,7 +142,10 @@
     }
     return iteration_info.status.ok();
   };
-  ForEachThread(cb);
+  if (const auto status = ForEachThread(cb); !status.ok()) {
+    PW_LOG_ERROR("Failed to capture thread information, error %d",
+                 status.code());
+  }
 
   // This logging action is external to thread iteration because it is
   // unsafe to log within ForEachThread() when the scheduler is disabled.
diff --git a/pw_thread_freertos/snapshot.cc b/pw_thread_freertos/snapshot.cc
index 631eca9..8d19f7f 100644
--- a/pw_thread_freertos/snapshot.cc
+++ b/pw_thread_freertos/snapshot.cc
@@ -48,33 +48,33 @@
   switch (thread_state) {
     case eRunning:
       PW_LOG_DEBUG("Thread state: RUNNING");
-      encoder.WriteState(ThreadState::Enum::RUNNING);
+      encoder.WriteState(ThreadState::Enum::RUNNING).IgnoreError();
       return;
 
     case eReady:
       PW_LOG_DEBUG("Thread state: READY");
-      encoder.WriteState(ThreadState::Enum::READY);
+      encoder.WriteState(ThreadState::Enum::READY).IgnoreError();
       return;
 
     case eBlocked:
       PW_LOG_DEBUG("Thread state: BLOCKED");
-      encoder.WriteState(ThreadState::Enum::BLOCKED);
+      encoder.WriteState(ThreadState::Enum::BLOCKED).IgnoreError();
       return;
 
     case eSuspended:
       PW_LOG_DEBUG("Thread state: SUSPENDED");
-      encoder.WriteState(ThreadState::Enum::SUSPENDED);
+      encoder.WriteState(ThreadState::Enum::SUSPENDED).IgnoreError();
       return;
 
     case eDeleted:
       PW_LOG_DEBUG("Thread state: INACTIVE");
-      encoder.WriteState(ThreadState::Enum::INACTIVE);
+      encoder.WriteState(ThreadState::Enum::INACTIVE).IgnoreError();
       return;
 
     case eInvalid:
     default:
       PW_LOG_DEBUG("Thread state: UNKNOWN");
-      encoder.WriteState(ThreadState::Enum::UNKNOWN);
+      encoder.WriteState(ThreadState::Enum::UNKNOWN).IgnoreError();
       return;
   }
 }
@@ -123,7 +123,7 @@
   const tskTCB& tcb = *reinterpret_cast<tskTCB*>(thread);
 
   PW_LOG_DEBUG("Capturing thread info for %s", tcb.pcTaskName);
-  encoder.WriteName(as_bytes(span(std::string_view(tcb.pcTaskName))));
+  PW_TRY(encoder.WriteName(as_bytes(span(std::string_view(tcb.pcTaskName)))));
 
   CaptureThreadState(thread_state, encoder);