From: Dan Harkless Date: Wed, 26 Jan 2000 21:35:43 +0000 (+0000) Subject: Dan Winship informed me that the right fix when gcc -Wall complains about char X-Git-Tag: nmh-1_0~90 X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=f3572e4b56fe8fffc75cb99b82b0cb063772836e;p=mmh Dan Winship informed me that the right fix when gcc -Wall complains about char indexes to arrays is to cast to unsigned char, not int. You want to prevent negative indexes into the array. --- diff --git a/sbr/m_getfld.c b/sbr/m_getfld.c index 0db7bd9..beb6e76 100644 --- a/sbr/m_getfld.c +++ b/sbr/m_getfld.c @@ -578,7 +578,7 @@ m_unknown(FILE *iob) pat_map = (unsigned char **) calloc (256, sizeof(unsigned char *)); for (cp = (char *) fdelim + 1; cp < (char *) delimend; cp++ ) - pat_map[(int)*cp] = (unsigned char *) cp; + pat_map[(unsigned char)*cp] = (unsigned char *) cp; if (msg_style == MS_MMDF) { /* flush extra msg hdrs */ diff --git a/uip/picksbr.c b/uip/picksbr.c index 3d4e978..848adc0 100644 --- a/uip/picksbr.c +++ b/uip/picksbr.c @@ -690,7 +690,7 @@ plist if (*p2 == CCHR) { c = p2[1]; do { - if (*p1 == c || cc[(int)*p1] == c) + if (*p1 == c || cc[(unsigned char)*p1] == c) if (advance (p1, p2)) return 1; } while (*p1++); @@ -715,7 +715,7 @@ advance (char *alp, char *aep) for (;;) switch (*ep++) { case CCHR: - if (*ep++ == *lp++ || ep[-1] == cc[(int)lp[-1]]) + if (*ep++ == *lp++ || ep[-1] == cc[(unsigned char)lp[-1]]) continue; return 0; @@ -754,7 +754,7 @@ advance (char *alp, char *aep) case CCHR | STAR: curlp = lp; - while (*lp++ == *ep || cc[(int)lp[-1]] == *ep) + while (*lp++ == *ep || cc[(unsigned char)lp[-1]] == *ep) continue; ep++; goto star; diff --git a/uip/vmhsbr.c b/uip/vmhsbr.c index 4a2b951..cc92b49 100644 --- a/uip/vmhsbr.c +++ b/uip/vmhsbr.c @@ -106,7 +106,7 @@ peer2rc (struct record *rc) if (fp) { fseek (fp, 0L, SEEK_END); fprintf (fp, "%d: <--- %s %d: \"%*.*s\"\n", (int) getpid(), - types[(int)rc->rc_type], rc->rc_len, + types[(unsigned char)rc->rc_type], rc->rc_len, rc->rc_len, rc->rc_len, rc->rc_data); fflush (fp); } @@ -127,7 +127,7 @@ rc2peer (char code, int len, char *data) if (fp) { fseek (fp, 0L, SEEK_END); fprintf (fp, "%d: ---> %s %d: \"%*.*s\"\n", (int) getpid(), - types[(int)rc->rc_type], rc->rc_len, + types[(unsigned char)rc->rc_type], rc->rc_len, rc->rc_len, rc->rc_len, data); fflush (fp); }