(no subject)

Nelson H. F. Beebe beebe at math.utah.edu
Thu Mar 28 01:14:57 EST 2002


There are quite a few compilation warnings from rsync-2.5.5rc1 that
could be eliminated by code cleanup.

	gcc -I. -I. -g -O2 -DHAVE_CONFIG_H -Wall -W -c main.c -o main.o
	main.c: In function `start_client':
	main.c:665: warning: unused variable `write_batch'
	main.c:664: warning: unused variable `whole_file'


These warnings will go away when the two variables are properly
bracketed by #ifdef INET6 ... #endif:

	gcc -I. -I. -g -O2 -DHAVE_CONFIG_H -Wall -W -I./popt -c lib/getaddrinfo.c -o lib/getaddrinfo.o
	lib/getaddrinfo.c: In function `getaddrinfo':
	lib/getaddrinfo.c:399: warning: unused variable `pfx'
	lib/getaddrinfo.c: In function `get_name':
	lib/getaddrinfo.c:476: warning: unused variable `h_error'

	gcc -I. -I. -g -O2 -DHAVE_CONFIG_H -Wall -W -I./popt -c lib/getnameinfo.c -o lib/getnameinfo.o
	...
	lib/getnameinfo.c:92: warning: unused variable `pfx'


This one will go away when line 57 in the source is corrected from
	{0, 0, 0},
to
	{0, 0, 0, 0},

	gcc -I. -I. -g -O2 -DHAVE_CONFIG_H -Wall -W -I./popt -c lib/getnameinfo.c -o lib/getnameinfo.o
	lib/getnameinfo.c:57: warning: missing initializer
	lib/getnameinfo.c:57: warning: (near initialization for `afdl[1].a_off')


More seriously, a build on GNU/Linux on 64-bit Alpha (and also with
gcc on other systems) caught some mismatches between format items and
arguments in printf() that reflect an absence of required type casts,
or better, corrected format items:

	gcc -I. -I. -g -O2 -DHAVE_CONFIG_H -Wall -W -c generator.c -o generator.o
	generator.c: In function `generate_sums':
	generator.c:191: warning: int format, different type arg (arg 3)
	generator.c:191: warning: int format, different type arg (arg 4)
	generator.c:191: warning: int format, different type arg (arg 5)

	gcc -I. -I. -g -O2 -DHAVE_CONFIG_H -Wall -W -c sender.c -o sender.o
	sender.c: In function `receive_sums':
	sender.c:50: warning: int format, different type arg (arg 3)
	sender.c:50: warning: int format, different type arg (arg 4)
	sender.c:50: warning: int format, different type arg (arg 5)

	gcc -I. -I. -g -O2 -DHAVE_CONFIG_H -Wall -W -c match.c -o match.o
	match.c: In function `hash_search':
	match.c:144: warning: int format, different type arg (arg 3)
	match.c:146: warning: comparison between signed and unsigned
	match.c:162: warning: int format, different type arg (arg 3)
	match.c:162: warning: int format, different type arg (arg 5)
	match.c:184: warning: comparison between signed and unsigned
	match.c:220: warning: comparison between signed and unsigned
	match.c:250: warning: comparison between signed and unsigned

	gcc -I. -I. -g -O2 -DHAVE_CONFIG_H -Wall -W -c io.c -o io.o
	io.c: In function `read_unbuffered':
	io.c:303: warning: int format, different type arg (arg 3)
	io.c: In function `writefd_unbuffered':
	io.c:462: warning: int format, different type arg (arg 3)

	gcc -I. -I. -g -O2 -DHAVE_CONFIG_H -Wall -W -I./popt -c tls.c -o tls.o
	tls.c: In function `list_file':
	tls.c:124: warning: int format, long int arg (arg 4)
	tls.c:124: warning: int format, long int arg (arg 5)


	gcc -I. -I. -g -O2 -DHAVE_CONFIG_H -Wall -W -I./popt -c getgroups.c -o getgroups.o
	getgroups.c: In function `main':
	getgroups.c:45: warning: unsigned int format, long unsigned int arg (arg 2)

The SGI IRIX 6.5 C compiler, which is noted for its excellent
diagnostics, had these additional comments:

	c89 -mips3 -O2 -I. -I. -g -DHAVE_CONFIG_H -I./popt -c options.c -o options.o
	cc-3303 c89: WARNING File = ./popt/popt.h, Line = 117
	  A type qualifier on a return type is meaningless.

	  /*@observer@*/ const char *const poptStrerror(const int error);

	c89 -mips3 -O2 -I. -I. -g -DHAVE_CONFIG_H -I./popt -c lib/getaddrinfo.c -o lib/getaddrinfo.o
	cc-1174 c89: WARNING File = lib/getaddrinfo.c, Line = 67
	  The variable "in6_addrany" was declared but never referenced.

	  static const char in6_addrany[] = {
			    ^
	cc-1174 c89: WARNING File = lib/getaddrinfo.c, Line = 71
	  The variable "in6_loopback" was declared but never referenced.

	  static const char in6_loopback[] = {
			    ^

	c89 -mips3 -O2 -I. -I. -g -DHAVE_CONFIG_H -I./popt -c popt/findme.c -o popt/findme.o
	cc-3303 c89: WARNING File = popt/popt.h, Line = 117
	  A type qualifier on a return type is meaningless.

	  /*@observer@*/ const char *const poptStrerror(const int error);
					   ^

	c89 -mips3 -O2 -I. -I. -g -DHAVE_CONFIG_H -I./popt -c popt/popt.c -o popt/popt.o
	cc-3303 c89: WARNING File = popt/popt.h, Line = 117
	  A type qualifier on a return type is meaningless.

	  /*@observer@*/ const char *const poptStrerror(const int error);
					   ^

	cc-3303 c89: WARNING File = popt/popt.c, Line = 713
	  A type qualifier on a return type is meaningless.

	  const char *const poptStrerror(const int error) {
			    ^
	c89 -mips3 -O2 -I. -I. -g -DHAVE_CONFIG_H -I./popt -c popt/poptconfig.c -o popt/poptconfig.o
	cc-3303 c89: WARNING File = popt/popt.h, Line = 117
	  A type qualifier on a return type is meaningless.

	  /*@observer@*/ const char *const poptStrerror(const int error);
					   ^

	c89 -mips3 -O2 -I. -I. -g -DHAVE_CONFIG_H -I./popt -c popt/popthelp.c -o popt/popthelp.o
	cc-3303 c89: WARNING File = popt/popt.h, Line = 117
	  A type qualifier on a return type is meaningless.

	  /*@observer@*/ const char *const poptStrerror(const int error);
					   ^

	cc-3303 c89: WARNING File = popt/popthelp.c, Line = 30
	  A type qualifier on a return type is meaningless.

	  getTableTranslationDomain(const struct poptOption *table)
	  ^

	cc-3303 c89: WARNING File = popt/popthelp.c, Line = 45
	  A type qualifier on a return type is meaningless.

	  getArgDescrip(const struct poptOption * opt, const char *translation_domain)
	  ^

	c89 -mips3 -O2 -I. -I. -g -DHAVE_CONFIG_H -I./popt -c popt/poptparse.c -o popt/poptparse.o
	cc-3303 c89: WARNING File = popt/popt.h, Line = 117
	  A type qualifier on a return type is meaningless.

	  /*@observer@*/ const char *const poptStrerror(const int error);
					   ^

gcc on the DEC Alpha OSF/1 caught several instances of char
subscripts; these are potentially erroneous because char is a signed
type on many architectures, but naive programmers erroneously expect
that

	int arr[256];
	char c;
	c = 255;
	arr[c] = 123;

will store at location 255, whereas, on many systems, it produces a
segment violation.

	gcc -I. -I. -g -O2 -DHAVE_CONFIG_H -Wall -W -I./popt -c exclude.c -o exclude.o
	exclude.c: In function `get_exclude_tok':
	exclude.c:337: warning: subscript has type `char'
	exclude.c:350: warning: subscript has type `char'

	gcc -I. -I. -g -O2 -DHAVE_CONFIG_H -Wall -W -I./popt -c util.c -o util.o
	util.c: In function `strlower':
	util.c:637: warning: subscript has type `char'

	gcc -I. -I. -g -O2 -DHAVE_CONFIG_H -Wall -W -I./popt -c socket.c -o socket.o
	socket.c: In function `establish_proxy_connection':
	socket.c:71: warning: subscript has type `char'

	gcc -I. -I. -g -O2 -DHAVE_CONFIG_H -Wall -W -I./popt -c params.c -o params.o
	params.c: In function `Continuation':
	params.c:167: warning: subscript has type `char'
	params.c: In function `Parameter':
	params.c:389: warning: subscript has type `char'

	gcc -I. -I. -g -O2 -DHAVE_CONFIG_H -Wall -W -I./popt -c loadparm.c -o loadparm.o
	loadparm.c: In function `strwicmp':
	loadparm.c:482: warning: subscript has type `char'
	loadparm.c:484: warning: subscript has type `char'

	gcc -I. -I. -g -O2 -DHAVE_CONFIG_H -Wall -W -I./popt -c clientserver.c -o clientserver.o
	clientserver.c: In function `rsync_module':
	clientserver.c:227: warning: subscript has type `char'
	clientserver.c:237: warning: subscript has type `char'

	gcc -I. -I. -g -O2 -DHAVE_CONFIG_H -Wall -W -I./popt -c access.c -o access.o
	access.c: In function `match_address':
	access.c:41: warning: subscript has type `char'

	gcc -I. -I. -g -O2 -DHAVE_CONFIG_H -Wall -W -I./popt -c lib/getaddrinfo.c -o lib/getaddrinfo.o
	lib/getaddrinfo.c: In function `str_isnumber':
	lib/getaddrinfo.c:206: warning: subscript has type `char'

	gcc -I. -I. -g -O2 -DHAVE_CONFIG_H -Wall -W -I./popt -c popt/poptconfig.c -o popt/poptconfig.o
	popt/poptconfig.c: In function `configLine':
	popt/poptconfig.c:18: warning: subscript has type `char'
	popt/poptconfig.c:19: warning: subscript has type `char'
	popt/poptconfig.c:22: warning: subscript has type `char'
	popt/poptconfig.c:24: warning: subscript has type `char'
	popt/poptconfig.c:28: warning: subscript has type `char'
	popt/poptconfig.c:30: warning: subscript has type `char'
	popt/poptconfig.c: In function `poptReadConfigFile':
	popt/poptconfig.c:93: warning: subscript has type `char'

	gcc -I. -I. -g -O2 -DHAVE_CONFIG_H -Wall -W -I./popt -c popt/popthelp.c -o popt/popthelp.o
	...
	popt/popthelp.c:93: warning: subscript has type `char'
	popt/popthelp.c:95: warning: subscript has type `char'
	popt/popthelp.c:101: warning: subscript has type `char'


	gcc -I. -I. -g -O2 -DHAVE_CONFIG_H -Wall -W -I./popt -c popt/poptparse.c -o popt/poptparse.o
	popt/poptparse.c: In function `poptParseArgvString':
	popt/poptparse.c:65: warning: subscript has type `char'

-------------------------------------------------------------------------------
- Nelson H. F. Beebe                    Tel: +1 801 581 5254                  -
- Center for Scientific Computing       FAX: +1 801 585 1640, +1 801 581 4148 -
- University of Utah                    Internet e-mail: beebe at math.utah.edu  -
- Department of Mathematics, 110 LCB        beebe at acm.org  beebe at computer.org -
- 155 S 1400 E RM 233                       beebe at ieee.org                    -
- Salt Lake City, UT 84112-0090, USA    URL: http://www.math.utah.edu/~beebe  -
-------------------------------------------------------------------------------




More information about the rsync mailing list