Re: clang's static checker report. - Mailing list pgsql-hackers

From Grzegorz Jaskiewicz
Subject Re: clang's static checker report.
Date
Msg-id 2A66594A-E5A0-47DE-A41C-5EB41E1147EC@pointblue.com.pl
Whole thread Raw
In response to Re: clang's static checker report.  (Greg Stark <gsstark@mit.edu>)
List pgsql-hackers
On 29 Aug 2009, at 18:05, Greg Stark wrote:

> Oh, I think I see what's happening. Our assertions can still be turned
> off at run-time with the variable assert_enabled.

Index: src/include/postgres.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/include/postgres.h,v
retrieving revision 1.92
diff -b -u -r1.92 postgres.h
--- src/include/postgres.h    1 Jan 2009 17:23:55 -0000    1.92
+++ src/include/postgres.h    30 Aug 2009 11:17:50 -0000
@@ -639,6 +639,7 @@  */
 extern PGDLLIMPORT bool assert_enabled;
+#define assert_enabled (1)
 /*  * USE_ASSERT_CHECKING, if defined, turns on all the assertions.
@@ -666,7 +667,7 @@  *    Isn't CPP fun?  */ #define TrapMacro(condition, errorType) \
-    ((bool) ((! assert_enabled) || ! (condition) || \
+    ((bool) ( ! (condition) || \              (ExceptionalCondition(CppAsString(condition), (errorType), \
                      __FILE__, __LINE__))))
 

@@ -689,8 +690,10 @@         Trap(!(condition), "BadState") #endif   /* USE_ASSERT_CHECKING */

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



like that ?
This is another excerpt from my local mods, that I use before running  
clang-checker over it.

but looking at Assert() macros in code (it expands macros if you  
hoover mouse pointer over one) - it still keeps 'assert_enabled'  
literal there. damn...



pgsql-hackers by date:

Previous
From: Jan Otto
Date:
Subject: Re: drop tablespace error: invalid argument
Next
From: Tatsuo Ishii
Date:
Subject: PQexecPrepared() behavior