Skip site navigation (1) Skip section navigation (2)

Re: clang's static checker report.

From: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Greg Stark <gsstark(at)mit(dot)edu>, 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-27 11:57:06
Message-ID: 75F43AD6-F88E-4F92-87F5-D3E12676E417@pointblue.com.pl (view raw or flat)
Thread:
Lists: pgsql-hackers
On 24 Aug 2009, at 14:40, Peter Eisentraut wrote:

> On mån, 2009-08-24 at 00:42 +0100, Grzegorz Jaskiewicz wrote:
>> --enable-cassert,  enabled, and also added exit_* in pg_dump to list
>> of functions that never return.
>
> A few more functions to mark noreturn: DateTimeParseError(), and
> die_horribly() in pg_dump

done.

new scan at: http://zlew.org/postgresql_static_check/scan-build-2009-08-27-2/
archive at: http://zlew.org/postgresql_static_check/postgresql_static_check_27thAugust2009.tar.xz

If people find it useful (altho, I've only seen single commit as  
result of that checker, and nothing fancy either) - I can write a  
script that would update it on daily basis.

what you people say ?

New Patch :

Index: src/Makefile.global.in
===================================================================
RCS file: /projects/cvsroot/pgsql/src/Makefile.global.in,v
retrieving revision 1.258
diff -u -b -r1.258 Makefile.global.in
--- src/Makefile.global.in	26 Aug 2009 22:24:42 -0000	1.258
+++ src/Makefile.global.in	27 Aug 2009 11:54:36 -0000
@@ -205,7 +205,10 @@
  endif
  endif # not PGXS

+ifndef CC
  CC = @CC@
+endif
+
  GCC = @GCC@
  SUN_STUDIO_CC = @SUN_STUDIO_CC@
  CFLAGS = @CFLAGS@
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	27 Aug 2009 11:54:37 -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_backup_archiver.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.h,v
retrieving revision 1.82
diff -u -b -r1.82 pg_backup_archiver.h
--- src/bin/pg_dump/pg_backup_archiver.h	7 Aug 2009 22:48:34 -0000	1.82
+++ src/bin/pg_dump/pg_backup_archiver.h	27 Aug 2009 11:54:37 -0000
@@ -325,7 +325,7 @@
  /* Used everywhere */
  extern const char *progname;

-extern void die_horribly(ArchiveHandle *AH, const char *modulename,  
const char *fmt,...) __attribute__((format(printf, 3, 4)));
+extern void die_horribly(ArchiveHandle *AH, const char *modulename,  
const char *fmt,...) __attribute__((format(printf, 3, 4)))  
__attribute__((analyzer_noreturn));
  extern void warn_or_die_horribly(ArchiveHandle *AH, const char  
*modulename, const char *fmt,...) __attribute__((format(printf, 3, 4)));
  extern void write_msg(const char *modulename, const char *fmt,...)  
__attribute__((format(printf, 2, 3)));

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	27 Aug 2009 11:54:37 -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	27 Aug 2009 11:54:37 -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/datetime.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/include/utils/datetime.h,v
retrieving revision 1.75
diff -u -b -r1.75 datetime.h
--- src/include/utils/datetime.h	11 Jun 2009 14:49:13 -0000	1.75
+++ src/include/utils/datetime.h	27 Aug 2009 11:54:37 -0000
@@ -300,7 +300,7 @@
  					  int *dtype, struct pg_tm * tm, fsec_t *fsec);

  extern void DateTimeParseError(int dterr, const char *str,
-				   const char *datatype);
+				   const char *datatype) __attribute__((__noreturn__));

  extern int	DetermineTimeZoneOffset(struct pg_tm * tm, pg_tz *tzp);

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	27 Aug 2009 11:54:37 -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);
  extern void





In response to

Responses

pgsql-hackers by date

Next:From: Grzegorz JaskiewiczDate: 2009-08-27 12:08:33
Subject: Re: Patches for static check on geo_ops.c
Previous:From: Boszormenyi ZoltanDate: 2009-08-27 11:21:09
Subject: Re: Build system problem in 8.3.x

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group