Hi all, Coverity is pointing out $subject, with the following stuff in gbt_var_same(): GBT_VARKEY *t1 = (GBT_VARKEY *) DatumGetPointer(d1); GBT_VARKEY *t2 = (GBT_VARKEY *) DatumGetPointer(d2); GBT_VARKEY_R r1, r2;
r1 = gbt_var_key_readable(t1); <= t1 dereferenced r2 = gbt_var_key_readable(t2); <= t2 dereferenced if (t1 && t2) result = ((*tinfo->f_cmp) (r1.lower, r2.lower, collation) == 0 && (*tinfo->f_cmp) (r1.upper, r2.upper, collation) == 0); else result = (t1 == NULL && t2 == NULL); <= Coverity complains here return result; As Heikki pointed me out on IM, the lack of crash report in this area, as well as similar coding style in cube/ seem to be sufficient arguments to simply remove those NULL checks instead of doing more solid checks on them. Patch is attached. Regards, -- Michael
diff --git a/contrib/btree_gist/btree_utils_var.c b/contrib/btree_gist/btree_utils_var.c index b7dd060..6ad3347 100644 --- a/contrib/btree_gist/btree_utils_var.c +++ b/contrib/btree_gist/btree_utils_var.c @@ -337,7 +337,6 @@ bool gbt_var_same(Datum d1, Datum d2, Oid collation, const gbtree_vinfo *tinfo) { - bool result; GBT_VARKEY *t1 = (GBT_VARKEY *) DatumGetPointer(d1); GBT_VARKEY *t2 = (GBT_VARKEY *) DatumGetPointer(d2); GBT_VARKEY_R r1, @@ -346,13 +345,8 @@ gbt_var_same(Datum d1, Datum d2, Oid collation, r1 = gbt_var_key_readable(t1); r2 = gbt_var_key_readable(t2); - if (t1 && t2) - result = ((*tinfo->f_cmp) (r1.lower, r2.lower, collation) == 0 && - (*tinfo->f_cmp) (r1.upper, r2.upper, collation) == 0); - else - result = (t1 == NULL && t2 == NULL); - - return result; + return ((*tinfo->f_cmp) (r1.lower, r2.lower, collation) == 0 && + (*tinfo->f_cmp) (r1.upper, r2.upper, collation) == 0); }
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers