Changeset: 474a4d84cc3a for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=474a4d84cc3a
Modified Files:
        gdk/gdk.h
        monetdb5/modules/mal/txtsim.c
Branch: default
Log Message:

Avoid constant expression in if condition.


diffs (79 lines):

diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -657,7 +657,7 @@ typedef uint64_t BUN8type;
  */
 typedef enum { GDK_FAIL, GDK_SUCCEED } gdk_return;
 
-#define ERRORcheck(tst,        msg, err) do if (tst) { if (msg) GDKerror(msg); 
return (err); } while (0)
+#define ERRORcheck(tst,        msg, err) do if (tst) { GDKerror(msg); return 
(err); } while (0)
 #define BATcheck(tst,  msg, err)                                       \
        do {                                                            \
                if ((tst) == NULL) {                                    \
diff --git a/monetdb5/modules/mal/txtsim.c b/monetdb5/modules/mal/txtsim.c
--- a/monetdb5/modules/mal/txtsim.c
+++ b/monetdb5/modules/mal/txtsim.c
@@ -912,10 +912,18 @@ CMDqgramselfjoin(bat *res1, bat *res2, b
                throw(MAL, "txtsim.qgramselfjoin", RUNTIME_OBJECT_MISSING);
        }
 
-       ERRORcheck((qgram->ttype != TYPE_oid), NULL, createException(MAL, 
"tstsim.qgramselfjoin", SEMANTIC_TYPE_MISMATCH ": tail of BAT qgram must be 
oid"));
-       ERRORcheck((id->ttype != TYPE_int), NULL, createException(MAL, 
"tstsim.qgramselfjoin", SEMANTIC_TYPE_MISMATCH ": tail of BAT id must be int"));
-       ERRORcheck((pos->ttype != TYPE_int), NULL, createException(MAL, 
"tstsim.qgramselfjoin", SEMANTIC_TYPE_MISMATCH ": tail of BAT pos must be 
int"));
-       ERRORcheck((len->ttype != TYPE_int), NULL, createException(MAL, 
"tstsim.qgramselfjoin", SEMANTIC_TYPE_MISMATCH ": tail of BAT len must be 
int"));
+       if (qgram->ttype != TYPE_oid)
+               throw(MAL, "tstsim.qgramselfjoin",
+                         SEMANTIC_TYPE_MISMATCH ": tail of BAT qgram must be 
oid");
+       if (id->ttype != TYPE_int)
+               throw(MAL, "tstsim.qgramselfjoin",
+                         SEMANTIC_TYPE_MISMATCH ": tail of BAT id must be 
int");
+       if (pos->ttype != TYPE_int)
+               throw(MAL, "tstsim.qgramselfjoin",
+                         SEMANTIC_TYPE_MISMATCH ": tail of BAT pos must be 
int");
+       if (len->ttype != TYPE_int)
+               throw(MAL, "tstsim.qgramselfjoin",
+                         SEMANTIC_TYPE_MISMATCH ": tail of BAT len must be 
int");
 
        n = BATcount(qgram);
        qbuf = (oid *) Tloc(qgram, BUNfirst(qgram));
@@ -923,18 +931,32 @@ CMDqgramselfjoin(bat *res1, bat *res2, b
        pbuf = (int *) Tloc(pos, BUNfirst(pos));
        lbuf = (int *) Tloc(len, BUNfirst(len));
 
-       /* ERRORcheck( (BATcount(qgram)>1 && !BATtordered(qgram)), 
"CMDqgramselfjoin: tail of qgram must be sorted.\n", createException(MAL, 
"tstsim.qgramselfjoin", SEMANTIC_TYPE_MISMATCH)); */
+       /* if (BATcount(qgram)>1 && !BATtordered(qgram)) throw(MAL, 
"tstsim.qgramselfjoin", SEMANTIC_TYPE_MISMATCH); */
 
-       ERRORcheck((ALIGNsynced(qgram, id) == 0), NULL, createException(MAL, 
"tstsim.qgramselfjoin", SEMANTIC_TYPE_MISMATCH ": qgram and id are not 
synced"));
+       if (ALIGNsynced(qgram, id) == 0)
+               throw(MAL, "tstsim.qgramselfjoin",
+                         SEMANTIC_TYPE_MISMATCH ": qgram and id are not 
synced");
 
-       ERRORcheck((ALIGNsynced(qgram, pos) == 0), NULL, createException(MAL, 
"tstsim.qgramselfjoin", SEMANTIC_TYPE_MISMATCH ": qgram and pos are not 
synced"));
-       ERRORcheck((ALIGNsynced(qgram, len) == 0), NULL, createException(MAL, 
"tstsim.qgramselfjoin", SEMANTIC_TYPE_MISMATCH ": qgram and len are not 
synced"));
+       if (ALIGNsynced(qgram, pos) == 0)
+               throw(MAL, "tstsim.qgramselfjoin",
+                         SEMANTIC_TYPE_MISMATCH ": qgram and pos are not 
synced");
+       if (ALIGNsynced(qgram, len) == 0)
+               throw(MAL, "tstsim.qgramselfjoin",
+                         SEMANTIC_TYPE_MISMATCH ": qgram and len are not 
synced");
 
-       ERRORcheck((Tsize(qgram) != ATOMsize(qgram->ttype)), NULL, 
createException(MAL, "tstsim.qgramselfjoin", SEMANTIC_TYPE_MISMATCH ": qgram is 
not a true void bat"));
-       ERRORcheck((Tsize(id) != ATOMsize(id->ttype)), NULL, 
createException(MAL, "tstsim.qgramselfjoin", SEMANTIC_TYPE_MISMATCH ": id is 
not a true void bat"));
+       if (Tsize(qgram) != ATOMsize(qgram->ttype))
+               throw(MAL, "tstsim.qgramselfjoin",
+                         SEMANTIC_TYPE_MISMATCH ": qgram is not a true void 
bat");
+       if (Tsize(id) != ATOMsize(id->ttype))
+               throw(MAL, "tstsim.qgramselfjoin",
+                         SEMANTIC_TYPE_MISMATCH ": id is not a true void bat");
 
-       ERRORcheck((Tsize(pos) != ATOMsize(pos->ttype)), NULL, 
createException(MAL, "tstsim.qgramselfjoin", SEMANTIC_TYPE_MISMATCH ": pos is 
not a true void bat"));
-       ERRORcheck((Tsize(len) != ATOMsize(len->ttype)), NULL, 
createException(MAL, "tstsim.qgramselfjoin", SEMANTIC_TYPE_MISMATCH ": len is 
not a true void bat"));
+       if (Tsize(pos) != ATOMsize(pos->ttype))
+               throw(MAL, "tstsim.qgramselfjoin",
+                         SEMANTIC_TYPE_MISMATCH ": pos is not a true void 
bat");
+       if (Tsize(len) != ATOMsize(len->ttype))
+               throw(MAL, "tstsim.qgramselfjoin",
+                         SEMANTIC_TYPE_MISMATCH ": len is not a true void 
bat");
 
        bn = BATnew(TYPE_void, TYPE_int, n, TRANSIENT);
        bn2 = BATnew(TYPE_void, TYPE_int, n, TRANSIENT);
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to