From 7ea24be51ef95a864d4e3dde7395780244a69f15 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Thu, 1 Jan 2026 17:47:57 +0100 Subject: chore: improve checksum API, making checksum constexpr. Update example. Signed-off-by: Amlal El Mahrouss --- include/ocl/fix/checksum.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/ocl/fix/checksum.hpp b/include/ocl/fix/checksum.hpp index 31aee75..451e387 100644 --- a/include/ocl/fix/checksum.hpp +++ b/include/ocl/fix/checksum.hpp @@ -35,18 +35,18 @@ namespace ocl::fix /// \param in_ Pointer to the message buffer. /// \param len Length of the message in bytes. /// \return The checksum value (sum of all bytes modulo 256). - inline checksum_type + inline constexpr checksum_type checksum(const char* in_, - const long len) + const std::size_t len) { if (len < 1) return 0L; - long long cks{}; + checksum_type cks{}; - for (long idx{}; idx < len; ++idx) + for (std::size_t idx{}; idx < len; ++idx) { - cks += static_cast(in_[idx]); + cks += static_cast(in_[idx]); } return cks % 256; -- cgit v1.2.3