diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2026-01-01 17:47:57 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2026-01-01 17:47:57 +0100 |
| commit | 7ea24be51ef95a864d4e3dde7395780244a69f15 (patch) | |
| tree | d97a424905f8326374ae02d0c6b0313d7fdf17f8 /include | |
| parent | 665e433697247c4a43e055830dee7a72afdb810f (diff) | |
chore: improve checksum API, making checksum constexpr. Update example.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'include')
| -rw-r--r-- | include/ocl/fix/checksum.hpp | 10 |
1 files changed, 5 insertions, 5 deletions
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<unsigned char>(in_[idx]); + cks += static_cast<uint8_t>(in_[idx]); } return cks % 256; |
