From ff8ca7f073a34e4e2e7829e914e1db43271a15c4 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Thu, 15 Sep 2022 12:22:37 +0200 Subject: [PATCH] Use uint8_t where appropriate Signed-off-by: Simon Rozman --- include/stdex/base64.h | 13 +++++++------ include/stdex/hex.h | 15 ++++++++------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/include/stdex/base64.h b/include/stdex/base64.h index 2f9512f7a..6c79f20a9 100644 --- a/include/stdex/base64.h +++ b/include/stdex/base64.h @@ -6,6 +6,7 @@ #pragma once #include "sal.h" +#include #include #include @@ -55,7 +56,7 @@ namespace stdex if (i >= size) break; - buf[num++] = reinterpret_cast(data)[i]; + buf[num++] = reinterpret_cast(data)[i]; } // If this is the last block, flush the buffer. @@ -134,8 +135,8 @@ namespace stdex protected: - unsigned char buf[3]; ///< Internal buffer - size_t num; ///< Number of bytes used in `buf` + uint8_t buf[3]; ///< Internal buffer + size_t num; ///< Number of bytes used in `buf` }; @@ -251,13 +252,13 @@ namespace stdex protected: - unsigned char buf[4]; ///< Internal buffer - size_t num; ///< Number of bytes used in `buf` + uint8_t buf[4]; ///< Internal buffer + size_t num; ///< Number of bytes used in `buf` }; /// \cond internal - static const unsigned char base64_dec_lookup[256] = { + static const uint8_t base64_dec_lookup[256] = { /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ /* 0 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, /* 1 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, diff --git a/include/stdex/hex.h b/include/stdex/hex.h index cbcf00719..be398333a 100644 --- a/include/stdex/hex.h +++ b/include/stdex/hex.h @@ -6,6 +6,7 @@ #pragma once #include "sal.h" +#include #include #include @@ -43,8 +44,8 @@ namespace stdex // Convert data character by character. for (size_t i = 0; i < size; i++) { - unsigned char - x = reinterpret_cast(data)[i], + uint8_t + x = reinterpret_cast(data)[i], x_h = ((x & 0xf0) >> 4), x_l = ((x & 0x0f) ); @@ -118,13 +119,13 @@ namespace stdex int x = data[i]; if ('0' <= x && x <= '9') { - buf = ((buf & 0xf) << 4) | (unsigned char)(x - '0'); + buf = ((buf & 0xf) << 4) | (uint8_t)(x - '0'); num++; } else if ('A' <= x && x <= 'F') { - buf = ((buf & 0xf) << 4) | (unsigned char)(x - ('A' - 10)); + buf = ((buf & 0xf) << 4) | (uint8_t)(x - ('A' - 10)); num++; } else if ('a' <= x && x <= 'f') { - buf = ((buf & 0xf) << 4) | (unsigned char)(x - ('a' - 10)); + buf = ((buf & 0xf) << 4) | (uint8_t)(x - ('a' - 10)); num++; } } @@ -154,7 +155,7 @@ namespace stdex protected: - unsigned char buf; ///< Internal buffer - size_t num; ///< Number of nibbles used in `buf` + uint8_t buf; ///< Internal buffer + size_t num; ///< Number of nibbles used in `buf` }; }