Fix some minor warnings to allow -Werror.
PATCH 8/10 Fix some minor warnings to allow -Werror.
--- builtin-mailinfo.c | 3 ++- diff.c | 1 + 2 files changed, 3 insertions(+), 1 deletions(-)
builtin-mailinfo.c +2 -1
@@ -531,7 +531,8 @@ static int decode_b_segment(char *in, chstatic 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" ;
diff.c +1 -0
@@ -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,
Signature · 1 line
1.4.1
From 262b57917ff01f74c95670ae59f1cd59a9024135 Mon Sep 17 00:00:00 2001
From: Ramsay Allan Jones <[email protected]>
Date: Sun, 30 Jul 2006 17:06:25 +0100
Subject: [PATCH 8/10] Fix some minor warnings to allow -Werror.
--- builtin-mailinfo.c | 3 ++- diff.c | 1 + 2 files changed, 3 insertions(+), 1 deletions(-)
builtin-mailinfo.c +2 -1
@@ -531,7 +531,8 @@ static int decode_b_segment(char *in, chstatic 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" ;
diff.c +1 -0
@@ -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,
Signature · 1 line
1.4.1
Quoted 5 lines · Ramsay Jones
builtin-mailinfo.c +0
-0
builtin-mailinfo.c static int decode_b_segment(char *in, ch · line 538
Quoted 9 lines
builtin-mailinfo.c +2
-1@@ -531,7 +531,8 @@ static int decode_b_segment(char *in, chstatic 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 errorsbuiltin-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);
diff.c static void emit_binary_diff(mmfile_t *o · line 620
Quoted 12 lines
diff.c +1
-0@@ -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.
Quoted 29 lines · Junio C Hamano
Quoted 5 lines · Ramsay Jones
builtin-mailinfo.c +0
-0builtin-mailinfo.c static int decode_b_segment(char *in, ch · line 538
Quoted 9 lines
builtin-mailinfo.c +2
-1@@ -531,7 +531,8 @@ static int decode_b_segment(char *in, chstatic 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
(quoted diff) +0
-3-D_XOPEN_SOURCE=500 -D_BSD_SOURCE -Wall -Wdeclaration-after-statement -g -DSHA1_HEADER='<openssl/sha.h>' -DNO_STRLCPY builtin-mailinfo.ccc1: 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
Quoted 4 lines
where the line 561 reads:
nrc = iconv(conv, &in, &insize, &out, &outsize);
OK, so I get exactly the same if I don't make the indicated change! The second param of iconv() must have changed from const char* to char* at some point in the last six years.
Just ignore this.
Quoted 9 lines
Quoted 9 lines
diff.c +1
-0@@ -614,6 +614,7 @@ static void emit_binary_diff(mmfile_t *o* whichever is smaller. */ delta =NULL ; + orig_size =0 ;
Quoted 9 lines
diff.c static void emit_binary_diff(mmfile_t *o · line 620
Quoted 3 lines
diff.c +0
-0deflated =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_sizeis only used when delta is non NULL, and when delta is non NULL, the variable is always set. Not very happy but is acceptable.
Yes, you are absolutely correct. I agree it would be nice if gcc was "fixed" so that it could detect this situation, but I'm not going to hold my breath. It just seemed to be the lesser evil.
Ramsay
Hi,
* Junio C Hamano [06-08-02 00:46:23 -0700] wrote:
[...]
Quoted 10 lines
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 errorsbuiltin-mailinfo.c: In function 'convert_to_utf8':
builtin-mailinfo.c:561: warning: passing argument 2 of 'iconv' from incompatible pointer typewhere the line 561 reads:
nrc = iconv(conv, &in, &insize, &out, &outsize);
It depends on the iconv() implementation as what the input pointer is defined: some use just 'char*' while others use 'const char*' (GNU libiconv IIRC).
bye, Rocco
Signature · 1 line
:wq!