Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id F2F356335FD for ; Thu, 28 May 2009 06:11:41 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 38737-06 for ; Thu, 28 May 2009 06:11:13 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from gmp-eb-inf-2.sun.com (gmp-eb-inf-2.sun.com [192.18.6.24]) by mail.postgresql.org (Postfix) with ESMTP id 8E2B4633815 for ; Thu, 28 May 2009 06:10:41 -0300 (ADT) Received: from fe-emea-09.sun.com (gmp-eb-lb-1-fe3.eu.sun.com [192.18.6.10]) by gmp-eb-inf-2.sun.com (8.13.7+Sun/8.12.9) with ESMTP id n4S9ARs9014317 for ; Thu, 28 May 2009 09:10:39 GMT MIME-version: 1.0 Content-type: multipart/mixed; boundary="Boundary_(ID_j/AsoXNt8tgul+n3Hk4rLQ)" Received: from conversion-daemon.fe-emea-09.sun.com by fe-emea-09.sun.com (Sun Java(tm) System Messaging Server 7u2-7.02 64bit (built Apr 16 2009)) id <0KKC00L00INZWI00@fe-emea-09.sun.com> for pgsql-hackers@postgresql.org; Thu, 28 May 2009 10:10:27 +0100 (BST) Received: from [192.168.1.100] ([unknown] [89.102.157.161]) by fe-emea-09.sun.com (Sun Java(tm) System Messaging Server 7u2-7.02 64bit (built Apr 16 2009)) with ESMTPSA id <0KKC008CJK53ZC90@fe-emea-09.sun.com> for pgsql-hackers@postgresql.org; Thu, 28 May 2009 10:10:16 +0100 (BST) Date: Thu, 28 May 2009 11:11:20 +0200 From: Zdenek Kotala Subject: Compiler warning cleanup - unitilized const variables, pointer type mismatch To: "pgsql-hackers@postgresql.org" Message-id: <1243501880.1372.23.camel@localhost> X-Mailer: Evolution 2.26.1.1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200905/1212 X-Sequence-Number: 138754 --Boundary_(ID_j/AsoXNt8tgul+n3Hk4rLQ) Content-type: text/plain; CHARSET=US-ASCII Content-transfer-encoding: 7BIT I attached another cleanup patch which fixes following warnings reported by Sun Studio: "zic.c", line 1534: warning: const object should have initializer: tzh0 "dynloader.c", line 7: warning: empty translation unit "pgstat.c", line 666: warning: const object should have initializer: all_zeroes "pgstat.c", line 799: warning: const object should have initializer: all_zeroes "pgstat.c", line 2552: warning: const object should have initializer: all_zeroes "preproc.c", line 39569: warning: pointer expression or its operand do not point to the same object yyerror_range, result is undefined and non-portable "tab-complete.c", line 587: warning: assignment type mismatch: pointer to function(pointer to const char, int, int) returning pointer to pointer to char "=" pointer to void Following list is still unfixed plus see my comments: "gram.c", line 28487: warning: pointer expression or its operand do not point to the same object yyerror_range, result is undefined and non-portable - This is really strange warning. The code is really strange because it points to -1 index of array, but I'm not bison guru. Maybe it is correct, but it would be good if somebody check it. "../../../src/include/pg_config.h", line 782: warning: macro redefined: _FILE_OFFSET_BITS - This probably needs some extra love in configure. "regc_lex.c", line 401: warning: loop not entered at top "regc_lex.c", line 484: warning: loop not entered at top "regc_lex.c", line 578: warning: loop not entered at top "regc_lex.c", line 610: warning: loop not entered at top "regc_lex.c", line 870: warning: loop not entered at top "regc_lex.c", line 1073: warning: loop not entered at top "postgres.c", line 3845: warning: loop not entered at top - Assert on not reached place probably confuse compiler. I'm not sure if it make sense nowadays? Most compiler should optimize this anyway and code is removed. I suppose to remove these asserts. Zdenek --Boundary_(ID_j/AsoXNt8tgul+n3Hk4rLQ) Content-type: text/x-patch; CHARSET=US-ASCII; name=warning.patch Content-transfer-encoding: 7BIT Content-disposition: attachment; filename=warning.patch diff -Nrc pgsql.orig.8fc4f032818a/src/backend/port/dynloader/solaris.c pgsql.orig/src/backend/port/dynloader/solaris.c *** pgsql.orig.8fc4f032818a/src/backend/port/dynloader/solaris.c 2009-05-28 11:09:24.874020865 +0200 --- pgsql.orig/src/backend/port/dynloader/solaris.c 2009-05-28 11:09:24.893688008 +0200 *************** *** 5,7 **** --- 5,11 ---- * * see solaris.h */ + + /* compiler complains about empty unit, let compiler quite */ + extern int no_such_variable; + diff -Nrc pgsql.orig.8fc4f032818a/src/backend/postmaster/pgstat.c pgsql.orig/src/backend/postmaster/pgstat.c *** pgsql.orig.8fc4f032818a/src/backend/postmaster/pgstat.c 2009-05-28 11:09:24.882883806 +0200 --- pgsql.orig/src/backend/postmaster/pgstat.c 2009-05-28 11:09:24.894106321 +0200 *************** *** 662,669 **** void pgstat_report_stat(bool force) { ! /* we assume this inits to all zeroes: */ ! static const PgStat_TableCounts all_zeroes; static TimestampTz last_report = 0; TimestampTz now; --- 662,668 ---- void pgstat_report_stat(bool force) { ! static const PgStat_TableCounts all_zeroes = {0,0,0,0,0,0,0,0,0,0,0}; static TimestampTz last_report = 0; TimestampTz now; *************** *** 795,802 **** static void pgstat_send_funcstats(void) { ! /* we assume this inits to all zeroes: */ ! static const PgStat_FunctionCounts all_zeroes; PgStat_MsgFuncstat msg; PgStat_BackendFunctionEntry *entry; --- 794,800 ---- static void pgstat_send_funcstats(void) { ! static const PgStat_FunctionCounts all_zeroes = {0,{0,0},{0,0}}; PgStat_MsgFuncstat msg; PgStat_BackendFunctionEntry *entry; *************** *** 2548,2555 **** void pgstat_send_bgwriter(void) { ! /* We assume this initializes to zeroes */ ! static const PgStat_MsgBgWriter all_zeroes; /* * This function can be called even if nothing at all has happened. In --- 2546,2552 ---- void pgstat_send_bgwriter(void) { ! static const PgStat_MsgBgWriter all_zeroes = { {0,0},0,0,0,0,0,0,0}; /* * This function can be called even if nothing at all has happened. In diff -Nrc pgsql.orig.8fc4f032818a/src/bin/psql/tab-complete.c pgsql.orig/src/bin/psql/tab-complete.c *** pgsql.orig.8fc4f032818a/src/bin/psql/tab-complete.c 2009-05-28 11:09:24.890322342 +0200 --- pgsql.orig/src/bin/psql/tab-complete.c 2009-05-28 11:09:24.894581639 +0200 *************** *** 557,563 **** /* Forward declaration of functions */ ! static char **psql_completion(char *text, int start, int end); static char *create_command_generator(const char *text, int state); static char *drop_command_generator(const char *text, int state); static char *complete_from_query(const char *text, int state); --- 557,563 ---- /* Forward declaration of functions */ ! static char **psql_completion(const char *text, int start, int end); static char *create_command_generator(const char *text, int state); static char *drop_command_generator(const char *text, int state); static char *complete_from_query(const char *text, int state); *************** *** 584,590 **** initialize_readline(void) { rl_readline_name = (char *) pset.progname; ! rl_attempted_completion_function = (void *) psql_completion; rl_basic_word_break_characters = "\t\n@$><=;|&{( "; --- 584,590 ---- initialize_readline(void) { rl_readline_name = (char *) pset.progname; ! rl_attempted_completion_function = psql_completion; rl_basic_word_break_characters = "\t\n@$><=;|&{( "; *************** *** 603,609 **** libraries completion_matches() function, so we don't have to worry about it. */ static char ** ! psql_completion(char *text, int start, int end) { /* This is the variable we'll return. */ char **matches = NULL; --- 603,609 ---- libraries completion_matches() function, so we don't have to worry about it. */ static char ** ! psql_completion(const char *text, int start, int end) { /* This is the variable we'll return. */ char **matches = NULL; diff -Nrc pgsql.orig.8fc4f032818a/src/timezone/zic.c pgsql.orig/src/timezone/zic.c *** pgsql.orig.8fc4f032818a/src/timezone/zic.c 2009-05-28 11:09:24.893104510 +0200 --- pgsql.orig/src/timezone/zic.c 2009-05-28 11:09:24.894905527 +0200 *************** *** 1531,1537 **** int timecnt32, timei32; int pass; static char *fullname; ! static const struct tzhead tzh0; static struct tzhead tzh; zic_t ats[TZ_MAX_TIMES]; unsigned char types[TZ_MAX_TIMES]; --- 1531,1537 ---- int timecnt32, timei32; int pass; static char *fullname; ! static const struct tzhead tzh0 = {0,0,0,0,0,0,0,0,0}; static struct tzhead tzh; zic_t ats[TZ_MAX_TIMES]; unsigned char types[TZ_MAX_TIMES]; --Boundary_(ID_j/AsoXNt8tgul+n3Hk4rLQ)--