git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 8/10] Fix some minor warnings to allow -Werror.

From
Junio C Hamano <junkio@cox.net>
Date
Aug 2, 2006, 07:46 UTC
Message-ID
<7vvepbvauo.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<00be01c6b5cf$7f7e9e20$c47eedc1@ramsay1.demon.co.uk>
"Ramsay Jones" <ramsay@ramsay1.demon.co.uk> writes:
Show 14 quoted lines
> diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
> index 3e40747..bb5e7b7 100644
> --- a/builtin-mailinfo.c
> +++ b/builtin-mailinfo.c
> @@ -531,7 +531,8 @@ static int decode_b_segment(char *in, ch
>  static void convert_to_utf8(char *line, char *charset)
>  {
>  #ifndef NO_ICONV
> -	char *in, *out;
> +	const char *in;
> +	char *out;
>  	size_t insize, outsize, nrc;
>  	char outbuf[4096]; /* cheat */
>  	static char latin_one[] = "latin1";
This kills the compilation with:

gcc -o builtin-mailinfo.o -c -O2 -Werror -ansi -pedantic -std=c99 -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -Wall -Wdeclaration-after-statement -g -DSHA1_HEADER='<openssl/sha.h>' -DNO_STRLCPY builtin-mailinfo.c cc1: warnings being treated as errors builtin-mailinfo.c: In function 'convert_to_utf8': builtin-mailinfo.c:561: warning: passing argument 2 of 'iconv' from incompatible pointer type

where the line 561 reads:
	nrc = iconv(conv, &in, &insize, &out, &outsize);
Show 12 quoted lines
> diff --git a/diff.c b/diff.c
> index 5a71489..81630c0 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -614,6 +614,7 @@ static void emit_binary_diff(mmfile_t *o
>  	 * whichever is smaller.
>  	 */
>  	delta = NULL;
> +	orig_size = 0;
>  	deflated = deflate_it(two->ptr, two->size, &deflate_size);
>  	if (one->size && two->size) {
>  		delta = diff_delta(one->ptr, one->size,

This is not wrong per se, but is working around a stupid compiler that do not understand the dataflow. orig_size is only used when delta is non NULL, and when delta is non NULL, the variable is always set. Not very happy but is acceptable.

Previous: Ramsay JonesNext: Rocco Rutte
Message 2 of 4 in “Fix some minor warnings to allow -Werror.”
  1. 8/10 Fix some minor warnings to allow -Werror.Ramsay Jones, Aug 2, 2006
  2. Junio C HamanoAug 2, 2006
  3. Rocco RutteAug 2, 2006
  4. Ramsay JonesAug 2, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.