Re: clang's static checker report.

From: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-23 23:42:55
Message-ID: 34A9FFFB-7A60-48E1-A45E-066F61684466@pointblue.com.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 24 Aug 2009, at 00:15, Greg Stark wrote:

> On Sun, Aug 23, 2009 at 11:16 PM, Grzegorz
> Jaskiewicz<gj(at)pointblue(dot)com(dot)pl> wrote:
>> ok folks, here's the last one for Today:
>>
>> http://zlew.org/postgresql_static_check/scan-build-2009-08-23-29/
>
> This does look better. The first one I looked at looks like a
> legitimate bug. The nice thing is that this seems to be picking up a
> lot of error handling cases that we don't bother to have regression
> tests for.
true
>
> One more request though. Can you configure with --enable-assertions so

--enable-cassert, enabled, and also added exit_* in pg_dump to list
of functions that never return.

new report's at: http://zlew.org/postgresql_static_check/scan-build-2009-08-24-2/

the archive is at : http://zlew.org/postgresql_static_check/postgresql_static_check_24thAugust2009.tar.xz

So that the overall 'static check' patch now looks like this:

Index: src/bin/pg_dump/pg_backup.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/bin/pg_dump/pg_backup.h,v
retrieving revision 1.52
diff -u -b -r1.52 pg_backup.h
--- src/bin/pg_dump/pg_backup.h 11 Jun 2009 14:49:07 -0000 1.52
+++ src/bin/pg_dump/pg_backup.h 23 Aug 2009 23:31:43 -0000
@@ -150,7 +150,7 @@

extern void
exit_horribly(Archive *AH, const char *modulename, const char
*fmt,...)
-__attribute__((format(printf, 3, 4)));
+__attribute__((format(printf, 3, 4)))
__attribute__((analyzer_noreturn));

/* Lets the archive know we have a DB connection to shutdown if it
dies */
Index: src/bin/pg_dump/pg_dump.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/bin/pg_dump/pg_dump.h,v
retrieving revision 1.156
diff -u -b -r1.156 pg_dump.h
--- src/bin/pg_dump/pg_dump.h 2 Aug 2009 22:14:52 -0000 1.156
+++ src/bin/pg_dump/pg_dump.h 23 Aug 2009 23:31:43 -0000
@@ -481,7 +481,7 @@
extern void *pg_realloc(void *ptr, size_t size);

extern void check_conn_and_db(void);
-extern void exit_nicely(void);
+extern void exit_nicely(void) __attribute__((analyzer_noreturn));

extern void parseOidArray(const char *str, Oid *array, int arraysize);

Index: src/include/postgres.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/include/postgres.h,v
retrieving revision 1.92
diff -u -b -r1.92 postgres.h
--- src/include/postgres.h 1 Jan 2009 17:23:55 -0000 1.92
+++ src/include/postgres.h 23 Aug 2009 23:31:43 -0000
@@ -691,6 +691,6 @@

extern int ExceptionalCondition(const char *conditionName,
const char *errorType,
- const char *fileName, int lineNumber);
+ const char *fileName, int lineNumber)
__attribute__((analyzer_noreturn));

#endif /* POSTGRES_H */
Index: src/include/utils/elog.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/include/utils/elog.h,v
retrieving revision 1.101
diff -u -b -r1.101 elog.h
--- src/include/utils/elog.h 11 Jun 2009 14:49:13 -0000 1.101
+++ src/include/utils/elog.h 23 Aug 2009 23:31:43 -0000
@@ -104,7 +104,7 @@
*/
#define ereport_domain(elevel, domain, rest) \
(errstart(elevel, __FILE__, __LINE__, PG_FUNCNAME_MACRO, domain) ? \
- (errfinish rest) : (void) 0)
+ (errfinish rest) : (void) 0), (elevel >= ERROR) ? exit(1) : 0

#define ereport(elevel, rest) \
ereport_domain(elevel, TEXTDOMAIN, rest)
@@ -190,7 +190,7 @@
* elog(ERROR, "portal \"%s\" not found", stmt->portalname);
*----------
*/
-#define elog elog_start(__FILE__, __LINE__, PG_FUNCNAME_MACRO),
elog_finish
+#define elog(A, ...) elog_start(__FILE__, __LINE__,
PG_FUNCNAME_MACRO), elog_finish(A, __VA_ARGS__), (A >= ERROR) ?
exit(1) : 0

extern void elog_start(const char *filename, int lineno, const char
*funcname);

That's it folks for Today, gotta go to sleep.
Have fun...

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message 张中 2009-08-24 00:47:13 help:how to write a planner_hook and other hooks in pg
Previous Message Greg Stark 2009-08-23 23:15:43 Re: clang's static checker report.