pw_kvs: Fix static analysis failure in unittest

Resolve static analysis complaint of a possible nullptr dereference. The
failure mode here could not happen as the existing code was taking a
reference of a reference, but the comparison to nullptr caused the
analyzer to complain. Explicitly check to see that a comparison to a
valid pointer is made before continuing.

Change-Id: I0e66624b46ba0de9ef48e80f63e8c96d4aa24253
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/31682
Reviewed-by: Keir Mierle <keir@google.com>
Commit-Queue: Prashanth Swaminathan <prashanthsw@google.com>
diff --git a/pw_kvs/entry_cache_test.cc b/pw_kvs/entry_cache_test.cc
index 6b7c9fa..bc49e19 100644
--- a/pw_kvs/entry_cache_test.cc
+++ b/pw_kvs/entry_cache_test.cc
@@ -282,10 +282,9 @@
 
   void CheckForCorruptSectors(SectorDescriptor* sector1 = nullptr,
                               SectorDescriptor* sector2 = nullptr) {
-    for (auto& sector : sectors_) {
+    for (const auto& sector : sectors_) {
       bool expect_corrupt =
-          (&sector == sector1 || &sector == sector2) ? true : false;
-
+          ((sector1 && &sector == sector1) || (sector2 && &sector == sector2));
       EXPECT_EQ(expect_corrupt, sector.corrupt());
     }
   }