Skip to content

Commit

Permalink
Avoid char index warning by casting to int
Browse files Browse the repository at this point in the history
  • Loading branch information
uyjulian committed Jun 11, 2021
1 parent e7756f8 commit cde9b0a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions src/cheatman.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static code_t make_code(const char *s)
int i = 0;

while (*s) {
if (isxdigit(*s))
if (isxdigit((int)*s))
digits[i++] = *s;
s++;
}
Expand All @@ -99,10 +99,10 @@ static int is_cheat_code(const char *s)
int i = 0;

while (*s) {
if (isxdigit(*s)) {
if (isxdigit((int)*s)) {
if (++i > CODE_DIGITS)
return 0;
} else if (!isspace(*s)) {
} else if (!isspace((int)*s)) {
return 0;
}
s++;
Expand Down Expand Up @@ -178,7 +178,7 @@ static int is_empty_str(const char *s)
size_t slen = strlen(s);

while (slen--) {
if (isgraph(*s++))
if (isgraph((int)*s++))
return 0;
}

Expand All @@ -200,13 +200,13 @@ static int trim_str(char *s)
return -1;

/* Get first non-space char */
while (isspace(*t++))
while (isspace((int)*t++))
first++;

/* Get last non-space char */
last = strlen(s) - 1;
t = &s[last];
while (isspace(*t--))
while (isspace((int)*t--))
last--;

/* Kill leading/trailing spaces */
Expand All @@ -224,7 +224,7 @@ static int trim_str(char *s)
static int is_empty_substr(const char *s, size_t count)
{
while (count--) {
if (isgraph(*s++))
if (isgraph((int)*s++))
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion src/opl.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ int oplPath2Mode(const char *path)
if (blkdevnameend != NULL) {
blkdevnamelen = (int)(blkdevnameend - appsPath);

while ((blkdevnamelen > 0) && isdigit(appsPath[blkdevnamelen - 1]))
while ((blkdevnamelen > 0) && isdigit((int)appsPath[blkdevnamelen - 1]))
blkdevnamelen--; //Ignore the unit number.

if (strncmp(path, appsPath, blkdevnamelen) == 0)
Expand Down
8 changes: 4 additions & 4 deletions src/ps2cnf.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

static const char *CNFGetToken(const char *cnf, const char *key)
{
for (; isspace(*cnf); cnf++) {
for (; isspace((int)*cnf); cnf++) {
}

for (; *key != '\0'; key++, cnf++) {
Expand Down Expand Up @@ -45,19 +45,19 @@ static const char *CNFGetKey(const char *line, char *key)
int i;

//Skip leading whitespace
for (; isspace(*line); line++) {
for (; isspace((int)*line); line++) {
}

if (*line == '\0') { //Unexpected end of file
return (const char *)-1;
}

for (i = 0; i < CNF_PATH_LEN_MAX && *line != '\0'; i++) {
if (isgraph(*line)) {
if (isgraph((int)*line)) {
*key = *line;
line++;
key++;
} else if (isspace(*line)) {
} else if (isspace((int)*line)) {
*key = '\0';
break;
} else if (*line == '\0') { //Unexpected end of file. This check exists, along with the other similar check above.
Expand Down

0 comments on commit cde9b0a

Please sign in to comment.