From 249092a55faf84566473734bf036125ba356bd22 Mon Sep 17 00:00:00 2001 From: Ted Lyngmo Date: Thu, 28 Apr 2022 15:03:34 +0200 Subject: [PATCH] Fix warnings about implicit cast Added a few explicit casts to sds.h: unsigned char flags = (unsigned char)s[-1]; Signed-off-by: Ted Lyngmo --- sds.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sds.h b/sds.h index eda8833b5..df23e1d7b 100644 --- a/sds.h +++ b/sds.h @@ -41,6 +41,7 @@ typedef long long ssize_t; #endif #include + #include #include @@ -89,7 +90,7 @@ struct __attribute__ ((__packed__)) sdshdr64 { #define SDS_TYPE_5_LEN(f) ((f)>>SDS_TYPE_BITS) static inline size_t sdslen(const sds s) { - unsigned char flags = s[-1]; + unsigned char flags = (unsigned char)s[-1]; switch(flags&SDS_TYPE_MASK) { case SDS_TYPE_5: return SDS_TYPE_5_LEN(flags); @@ -106,7 +107,7 @@ static inline size_t sdslen(const sds s) { } static inline size_t sdsavail(const sds s) { - unsigned char flags = s[-1]; + unsigned char flags = (unsigned char)s[-1]; switch(flags&SDS_TYPE_MASK) { case SDS_TYPE_5: { return 0; @@ -132,7 +133,7 @@ static inline size_t sdsavail(const sds s) { } static inline void sdssetlen(sds s, size_t newlen) { - unsigned char flags = s[-1]; + unsigned char flags = (unsigned char)s[-1]; switch(flags&SDS_TYPE_MASK) { case SDS_TYPE_5: { @@ -156,7 +157,7 @@ static inline void sdssetlen(sds s, size_t newlen) { } static inline void sdsinclen(sds s, size_t inc) { - unsigned char flags = s[-1]; + unsigned char flags = (unsigned char)s[-1]; switch(flags&SDS_TYPE_MASK) { case SDS_TYPE_5: { @@ -182,7 +183,7 @@ static inline void sdsinclen(sds s, size_t inc) { /* sdsalloc() = sdsavail() + sdslen() */ static inline size_t sdsalloc(const sds s) { - unsigned char flags = s[-1]; + unsigned char flags = (unsigned char)s[-1]; switch(flags&SDS_TYPE_MASK) { case SDS_TYPE_5: return SDS_TYPE_5_LEN(flags); @@ -199,7 +200,7 @@ static inline size_t sdsalloc(const sds s) { } static inline void sdssetalloc(sds s, size_t newlen) { - unsigned char flags = s[-1]; + unsigned char flags = (unsigned char)s[-1]; switch(flags&SDS_TYPE_MASK) { case SDS_TYPE_5: /* Nothing to do, this type has no total allocation info. */