From 82fc67ae4d530317bf6174696ab4939285db6658 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Sat, 18 Dec 2021 14:01:02 +0300
Subject: [PATCH] SDL_joystick.c: cast the arguments to nibble() to unsigned
char.
---
src/joystick/SDL_joystick.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c
index fe6128c9370..31a0277fe43 100644
--- a/src/joystick/SDL_joystick.c
+++ b/src/joystick/SDL_joystick.c
@@ -2646,18 +2646,18 @@ void SDL_JoystickGetGUIDString(SDL_JoystickGUID guid, char *pszGUID, int cbGUID)
* Input : c -
* Output : unsigned char
*-----------------------------------------------------------------------------*/
-static unsigned char nibble(char c)
+static unsigned char nibble(unsigned char c)
{
if ((c >= '0') && (c <= '9')) {
- return (unsigned char)(c - '0');
+ return (c - '0');
}
if ((c >= 'A') && (c <= 'F')) {
- return (unsigned char)(c - 'A' + 0x0a);
+ return (c - 'A' + 0x0a);
}
if ((c >= 'a') && (c <= 'f')) {
- return (unsigned char)(c - 'a' + 0x0a);
+ return (c - 'a' + 0x0a);
}
/* received an invalid character, and no real way to return an error */
@@ -2681,7 +2681,7 @@ SDL_JoystickGUID SDL_JoystickGetGUIDFromString(const char *pchGUID)
p = (Uint8 *)&guid;
for (i = 0; (i < len) && ((p - (Uint8 *)&guid) < maxoutputbytes); i+=2, p++) {
- *p = (nibble(pchGUID[i]) << 4) | nibble(pchGUID[i+1]);
+ *p = (nibble((unsigned char)pchGUID[i]) << 4) | nibble((unsigned char)pchGUID[i+1]);
}
return guid;