Use uint64_t for fingerprints to prevent easy overflows
Instead of using int for state/command/traits/components fingerprints,
use uint64_t and reserve the value of 0 as a special "ignore" whildcard
(instead of former -1).
Change-Id: I3b95b4a8f9f41a963486d31ca6632ec0738dd7e9
Reviewed-on: https://weave-review.googlesource.com/1793
Reviewed-by: Alex Vakulenko <avakulenko@google.com>
diff --git a/src/privet/privet_handler.h b/src/privet/privet_handler.h
index 6bc4ac6..fc024d1 100644
--- a/src/privet/privet_handler.h
+++ b/src/privet/privet_handler.h
@@ -130,10 +130,10 @@
void ReplyToUpdateRequest(const RequestCallback& callback) const;
void OnUpdateRequestTimeout(int update_request_id);
- CloudDelegate* cloud_ = nullptr;
- DeviceDelegate* device_ = nullptr;
- SecurityDelegate* security_ = nullptr;
- WifiDelegate* wifi_ = nullptr;
+ CloudDelegate* cloud_{nullptr};
+ DeviceDelegate* device_{nullptr};
+ SecurityDelegate* security_{nullptr};
+ WifiDelegate* wifi_{nullptr};
struct HandlerParameters {
ApiHandler handler;
@@ -144,18 +144,18 @@
struct UpdateRequestParameters {
RequestCallback callback;
- int request_id = 0;
- int state_fingerprint = -1;
- int traits_fingerprint = -1;
- int components_fingerprint = -1;
+ int request_id{0};
+ uint64_t state_fingerprint{0};
+ uint64_t traits_fingerprint{0};
+ uint64_t components_fingerprint{0};
};
std::vector<UpdateRequestParameters> update_requests_;
int last_update_request_id_{0};
uint64_t last_user_id_{0};
- int state_fingerprint_{0};
- int traits_fingerprint_{0};
- int components_fingerprint_{0};
+ uint64_t state_fingerprint_{1};
+ uint64_t traits_fingerprint_{1};
+ uint64_t components_fingerprint_{1};
ScopedObserver<CloudDelegate, CloudDelegate::Observer> cloud_observer_{this};
base::WeakPtrFactory<PrivetHandler> weak_ptr_factory_{this};