]> granicus.if.org Git - postgresql/commitdiff
Tweak a couple of macros in the regex code to suppress compiler warnings
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 2 Aug 2010 02:29:39 +0000 (02:29 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 2 Aug 2010 02:29:39 +0000 (02:29 +0000)
from "clang".  The VERR changes make an assignment unconditional, which is
probably easier to read/understand anyway, and one can hardly argue that
it's worth shaving cycles off the case of reporting another error when
one has already been detected.  The INSIST change limits where that macro
can be used, but not in a way that creates a problem for any existing call.

src/backend/regex/regcomp.c
src/backend/regex/regexec.c

index cb2c687aa0954de9ab44a2438262ec73fc26c506..d15bea7150dcb4a400d8cb8c26004405dd1c676d 100644 (file)
@@ -28,7 +28,7 @@
  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $PostgreSQL: pgsql/src/backend/regex/regcomp.c,v 1.48 2010/02/26 02:00:57 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/regex/regcomp.c,v 1.49 2010/08/02 02:29:39 tgl Exp $
  *
  */
 
@@ -232,13 +232,13 @@ struct vars
 #define EAT(t) (SEE(t) && next(v))             /* if next is this, swallow it */
 #define VISERR(vv)     ((vv)->err != 0)        /* have we seen an error yet? */
 #define ISERR() VISERR(v)
-#define VERR(vv,e)     ((vv)->nexttype = EOS, ((vv)->err) ? (vv)->err :\
-                                                       ((vv)->err = (e)))
+#define VERR(vv,e)     ((vv)->nexttype = EOS, \
+                                        (vv)->err = ((vv)->err ? (vv)->err : (e)))
 #define ERR(e) VERR(v, e)              /* record an error */
 #define NOERR() {if (ISERR()) return;} /* if error seen, return */
 #define NOERRN()       {if (ISERR()) return NULL;} /* NOERR with retval */
 #define NOERRZ()       {if (ISERR()) return 0;}        /* NOERR with retval */
-#define INSIST(c, e)   ((c) ? 0 : ERR(e))              /* if condition false, error */
+#define INSIST(c, e) do { if (!(c)) ERR(e); } while (0)        /* error if c false */
 #define NOTE(b) (v->re->re_info |= (b)) /* note visible condition */
 #define EMPTYARC(x, y) newarc(v->nfa, EMPTY, 0, x, y)
 
index 60a03a417ee593e1f35ac810662194187e705963..0e8b2fb2836fa1b4f314fa79c2580ac005c75c55 100644 (file)
@@ -27,7 +27,7 @@
  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $PostgreSQL: pgsql/src/backend/regex/regexec.c,v 1.28 2010/02/01 02:45:29 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/regex/regexec.c,v 1.29 2010/08/02 02:29:39 tgl Exp $
  *
  */
 
@@ -119,7 +119,7 @@ struct vars
 
 #define VISERR(vv)     ((vv)->err != 0)        /* have we seen an error yet? */
 #define ISERR() VISERR(v)
-#define VERR(vv,e)     (((vv)->err) ? (vv)->err : ((vv)->err = (e)))
+#define VERR(vv,e)     ((vv)->err = ((vv)->err ? (vv)->err : (e)))
 #define ERR(e) VERR(v, e)              /* record an error */
 #define NOERR() {if (ISERR()) return v->err;}  /* if error seen, return it */
 #define OFF(p) ((p) - v->start)