From owner-freebsd-bugs Sat Jun 23 4:40:12 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id CB7E737B408 for ; Sat, 23 Jun 2001 04:40:02 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.3/8.11.3) id f5NBe2383344; Sat, 23 Jun 2001 04:40:02 -0700 (PDT) (envelope-from gnats) Received: from ajax2.sovam.com (ajax2.sovam.com [194.67.1.173]) by hub.freebsd.org (Postfix) with ESMTP id 658D737B401 for ; Sat, 23 Jun 2001 04:33:15 -0700 (PDT) (envelope-from avn@any.ru) Received: from ts9-a282.dial.sovam.com ([195.239.71.26]:1203 "EHLO srv2.any" ident: "TIMEDOUT" whoson: "-unregistered-" smtp-auth: TLS-CIPHER: TLS-PEER: ) by ajax2.sovam.com with ESMTP id ; Sat, 23 Jun 2001 15:33:07 +0400 Received: (from avn@localhost) by srv2.any (8.11.3/8.11.3) id f5NBVFS49472; Sat, 23 Jun 2001 15:31:15 +0400 (MSD) (envelope-from avn) Message-Id: <200106231131.f5NBVFS49472@srv2.any> Date: Sat, 23 Jun 2001 15:31:15 +0400 (MSD) From: avn@any.ru Reply-To: avn@any.ru To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.113 Subject: bin/28364: lex(1) generated files fail to compile cleanly with -Wconversion Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 28364 >Category: bin >Synopsis: lex(1) generated files fail to compile cleanly with -Wconversion >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Jun 23 04:40:02 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Alexey V. Neyman >Release: FreeBSD 4.3-STABLE i386 >Organization: http://www.any.ru/ >Environment: System: FreeBSD srv2.any 4.3-STABLE FreeBSD 4.3-STABLE #4: Thu Jun 14 12:25:16 MSD 2001 toor@srv2.any:/usr2/obj/usr2/src/sys/SRV2 i386 >Description: lex(1) generates files which do not pass -Wconversion either with -ansi or without it. This means, they won't compile under BDECFLAGS. >How-To-Repeat: --- Makefile --- SRCS = a.l PROG = a NOMAN = yes NOOBJ = yes CFLAGS = -Wconversion -ansi -pedantic .include --- a.l --- %option noyywrap %{ #include %} %% . { } %% int main(void) { return 0; } --- end --- produce the following warnings: a.l: In function `yylex': a.l:7: warning: passing arg 2 of `fwrite' as unsigned due to prototype a.l: In function `yy_get_next_buffer': a.l:246: warning: passing arg 3 of `fread' as unsigned due to prototype Also, these warnings point to 'a.l' which is erroneous (obviously, a.l does not have line 246 :). >Fix: The patch below makes this sample to go cleanly under -Wconversion with or without -ansi. --- flex.skl.orig Sat Jun 23 15:15:38 2001 +++ flex.skl Sat Jun 23 15:15:38 2001 @@ -104,7 +104,7 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; -extern int yyleng; +extern size_t yyleng; %- extern FILE *yyin, *yyout; %* @@ -228,7 +228,7 @@ static int yy_n_chars; /* number of characters read into yy_ch_buf */ -int yyleng; +size_t yyleng; /* Points to current character in buffer. */ static char *yy_c_buf_p = (char *) 0; @@ -788,7 +788,7 @@ else { - int num_to_read = + size_t num_to_read = yy_current_buffer->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) --- gen.c.orig Sat Jun 23 15:15:38 2001 +++ gen.c Sat Jun 23 15:15:38 2001 @@ -1070,11 +1070,11 @@ if ( yymore_used && ! yytext_is_array ) { indent_puts( "yytext_ptr -= yy_more_len; \\" ); - indent_puts( "yyleng = (int) (yy_cp - yytext_ptr); \\" ); + indent_puts( "yyleng = (size_t) (yy_cp - yytext_ptr); \\" ); } else - indent_puts( "yyleng = (int) (yy_cp - yy_bp); \\" ); + indent_puts( "yyleng = (size_t) (yy_cp - yy_bp); \\" ); /* Now also deal with copying yytext_ptr to yytext if needed. */ skelout(); @@ -1341,7 +1341,8 @@ outn( "\tif ( yy_current_buffer->yy_is_interactive ) \\" ); outn( "\t\t{ \\" ); - outn( "\t\tint c = '*', n; \\" ); + outn( "\t\tint c = '*'; \\"); + outn( "\t\tsize_t n; \\" ); outn( "\t\tfor ( n = 0; n < max_size && \\" ); outn( "\t\t\t (c = getc( yyin )) != EOF && c != '\\n'; ++n ) \\" ); outn( "\t\t\tbuf[n] = (char) c; \\" ); >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message