From 1962f7440266854ff99ccbcccdb8901d4a390f3b Mon Sep 17 00:00:00 2001 From: Christian Weisgerber Date: Fri, 15 Oct 2021 15:01:30 +0000 Subject: Don't declare variables as "unsigned char *" that are passed to functions that take "char *" arguments. Where such chars are assigned to int or passed to ctype functions, explicitly cast them to unsigned char. For OpenBSD's clang, -Wpointer-sign has been disabled by default, but when the parse.y code was built elsewhere, the compiler would complain. With help from millert@ ok benno@ deraadt@ --- usr.sbin/ntpd/parse.y | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'usr.sbin/ntpd') diff --git a/usr.sbin/ntpd/parse.y b/usr.sbin/ntpd/parse.y index 81d19bbff43..3aa8d95a9af 100644 --- a/usr.sbin/ntpd/parse.y +++ b/usr.sbin/ntpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.77 2020/04/11 07:49:48 otto Exp $ */ +/* $OpenBSD: parse.y,v 1.78 2021/10/15 15:01:28 naddy Exp $ */ /* * Copyright (c) 2002, 2003, 2004 Henning Brauer @@ -561,9 +561,9 @@ lookup(char *s) #define MAXPUSHBACK 128 -u_char *parsebuf; +char *parsebuf; int parseindex; -u_char pushback_buffer[MAXPUSHBACK]; +char pushback_buffer[MAXPUSHBACK]; int pushback_index = 0; int @@ -574,7 +574,7 @@ lgetc(int quotec) if (parsebuf) { /* Read character from the parsebuffer instead of input. */ if (parseindex >= 0) { - c = parsebuf[parseindex++]; + c = (unsigned char)parsebuf[parseindex++]; if (c != '\0') return (c); parsebuf = NULL; @@ -583,7 +583,7 @@ lgetc(int quotec) } if (pushback_index) - return (pushback_buffer[--pushback_index]); + return ((unsigned char)pushback_buffer[--pushback_index]); if (quotec) { if ((c = getc(file->stream)) == EOF) { @@ -624,10 +624,10 @@ lungetc(int c) if (parseindex >= 0) return (c); } - if (pushback_index < MAXPUSHBACK-1) - return (pushback_buffer[pushback_index++] = c); - else + if (pushback_index + 1 >= MAXPUSHBACK) return (EOF); + pushback_buffer[pushback_index++] = c; + return (c); } int @@ -640,7 +640,7 @@ findeol(void) /* skip to either EOF or the first real EOL */ while (1) { if (pushback_index) - c = pushback_buffer[--pushback_index]; + c = (unsigned char)pushback_buffer[--pushback_index]; else c = lgetc(0); if (c == '\n') { @@ -656,8 +656,8 @@ findeol(void) int yylex(void) { - u_char buf[8096]; - u_char *p; + char buf[8096]; + char *p; int quotec, next, c; int token; @@ -739,8 +739,8 @@ yylex(void) } else { nodigits: while (p > buf + 1) - lungetc(*--p); - c = *--p; + lungetc((unsigned char)*--p); + c = (unsigned char)*--p; if (c == '-') return (c); } -- cgit v1.2.3