Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warnings about implicit cast #1064

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions sds.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ typedef long long ssize_t;
#endif

#include <sys/types.h>

#include <stdarg.h>
#include <stdint.h>

Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -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:
{
Expand All @@ -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:
{
Expand All @@ -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);
Expand All @@ -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. */
Expand Down