Changeset: efcf91847829 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=efcf91847829
Modified Files:
gdk/gdk_calc.c
gdk/gdk_calc_compare.h
monetdb5/mal/mal_authorize.c
monetdb5/modules/atoms/json.c
monetdb5/modules/kernel/batstr.c
monetdb5/modules/mal/mal_mapi.c
monetdb5/modules/mal/remote.c
sql/backends/monet5/UDF/capi/capi.c
sql/backends/monet5/UDF/udf/udf.c
sql/backends/monet5/sql.c
sql/backends/monet5/sql_cat.c
sql/backends/monet5/sql_transaction.c
sql/server/rel_schema.c
sql/server/sql_privileges.c
sql/storage/store.c
Branch: Nov2019
Log Message:
Remove superfluous NULL pointer checks.
strNil already does it.
diffs (truncated from 571 to 300 lines):
diff --git a/gdk/gdk_calc.c b/gdk/gdk_calc.c
--- a/gdk/gdk_calc.c
+++ b/gdk/gdk_calc.c
@@ -14534,7 +14534,7 @@ VARconvert(ValPtr ret, const ValRecord *
if (VALinit(ret, ret->vtype, ATOMnilptr(ret->vtype)) == NULL)
nils = BUN_NONE;
} else if (v->vtype == TYPE_str) {
- if (v->val.sval == NULL || strNil(v->val.sval)) {
+ if (strNil(v->val.sval)) {
if (VALinit(ret, ret->vtype, ATOMnilptr(ret->vtype)) ==
NULL)
nils = BUN_NONE;
} else if (ATOMstorage(ret->vtype) == TYPE_ptr) {
diff --git a/gdk/gdk_calc_compare.h b/gdk/gdk_calc_compare.h
--- a/gdk/gdk_calc_compare.h
+++ b/gdk/gdk_calc_compare.h
@@ -705,12 +705,10 @@ op_typeswitchloop(const void *lft, int t
CHECKCAND(dst, k, candoff, TPE_nil);
s1 = hp1 ? hp1 + VarHeapVal(lft, i, wd1) : (const char
*) lft;
s2 = hp2 ? hp2 + VarHeapVal(rgt, j, wd2) : (const char
*) rgt;
- if (s1 == NULL || strNil(s1) ||
- s2 == NULL || strNil(s2)) {
+ if (strNil(s1) || strNil(s2)) {
#ifdef NIL_MATCHES_FLAG
if (nil_matches) {
- dst[k] = OP(s1 == NULL || strNil(s1),
- s2 == NULL || strNil(s2));
+ dst[k] = OP(strNil(s1), strNil(s2));
} else
#endif
{
diff --git a/monetdb5/mal/mal_authorize.c b/monetdb5/mal/mal_authorize.c
--- a/monetdb5/mal/mal_authorize.c
+++ b/monetdb5/mal/mal_authorize.c
@@ -424,7 +424,7 @@ AUTHcheckCredentials(
assert(user);
assert(pass);
- if (username == NULL || strNil(username))
+ if (strNil(username))
throw(INVCRED, "checkCredentials", "invalid credentials for
unknown user");
p = AUTHfindUser(username);
@@ -436,7 +436,7 @@ AUTHcheckCredentials(
/* a NULL password is impossible (since we should be dealing with
* hashes here) so we can bail out immediately
*/
- if (passwd == NULL || strNil(passwd)) {
+ if (strNil(passwd)) {
/* DO NOT reveal that the password is NULL here! */
throw(INVCRED, "checkCredentials", INVCRED_INVALID_USER "
'%s'", username);
}
@@ -481,9 +481,9 @@ AUTHaddUser(oid *uid, Client cntxt, cons
rethrow("addUser", tmp, AUTHrequireAdmin(cntxt));
/* some pre-condition checks */
- if (username == NULL || strNil(username))
+ if (strNil(username))
throw(ILLARG, "addUser", "username should not be nil");
- if (passwd == NULL || strNil(passwd))
+ if (strNil(passwd))
throw(ILLARG, "addUser", "password should not be nil");
rethrow("addUser", tmp, AUTHverifyPassword(passwd));
@@ -527,7 +527,7 @@ AUTHremoveUser(Client cntxt, const char
assert(pass);
/* pre-condition check */
- if (username == NULL || strNil(username))
+ if (strNil(username))
throw(ILLARG, "removeUser", "username should not be nil");
/* ensure that the username exists */
@@ -563,9 +563,9 @@ AUTHchangeUsername(Client cntxt, const c
rethrow("addUser", tmp, AUTHrequireAdminOrUser(cntxt, olduser));
/* precondition checks */
- if (olduser == NULL || strNil(olduser))
+ if (strNil(olduser))
throw(ILLARG, "changeUsername", "old username should not be
nil");
- if (newuser == NULL || strNil(newuser))
+ if (strNil(newuser))
throw(ILLARG, "changeUsername", "new username should not be
nil");
/* see if the olduser is valid */
@@ -600,9 +600,9 @@ AUTHchangePassword(Client cntxt, const c
str msg= MAL_SUCCEED;
/* precondition checks */
- if (oldpass == NULL || strNil(oldpass))
+ if (strNil(oldpass))
throw(ILLARG, "changePassword", "old password should not be
nil");
- if (passwd == NULL || strNil(passwd))
+ if (strNil(passwd))
throw(ILLARG, "changePassword", "password should not be nil");
rethrow("changePassword", tmp, AUTHverifyPassword(passwd));
@@ -657,9 +657,9 @@ AUTHsetPassword(Client cntxt, const char
rethrow("setPassword", tmp, AUTHrequireAdmin(cntxt));
/* precondition checks */
- if (username == NULL || strNil(username))
+ if (strNil(username))
throw(ILLARG, "setPassword", "username should not be nil");
- if (passwd == NULL || strNil(passwd))
+ if (strNil(passwd))
throw(ILLARG, "setPassword", "password should not be nil");
rethrow("setPassword", tmp, AUTHverifyPassword(passwd));
@@ -786,7 +786,7 @@ AUTHgetPasswordHash(str *ret, Client cnt
rethrow("getPasswordHash", tmp, AUTHrequireAdmin(cntxt));
- if (username == NULL || strNil(username))
+ if (strNil(username))
throw(ILLARG, "getPasswordHash", "username should not be nil");
p = AUTHfindUser(username);
@@ -818,7 +818,7 @@ AUTHgetPasswordHash(str *ret, Client cnt
str
AUTHunlockVault(const char *password)
{
- if (password == NULL || strNil(password))
+ if (strNil(password))
throw(ILLARG, "unlockVault", "password should not be nil");
/* even though I think this function should be called only once, it
@@ -996,7 +996,7 @@ AUTHgetRemoteTableCredentials(const char
str tmp;
str pwhash;
- if (local_table == NULL || strNil(local_table)) {
+ if (strNil(local_table)) {
throw(ILLARG, "getRemoteTableCredentials", "local table should
not be nil");
}
@@ -1034,9 +1034,9 @@ AUTHaddRemoteTableCredentials(const char
str tmp, output = MAL_SUCCEED;
BUN p;
- if (uri == NULL || strNil(uri))
+ if (strNil(uri))
throw(ILLARG, "addRemoteTableCredentials", "URI cannot be nil");
- if (local_user == NULL || strNil(local_user))
+ if (strNil(local_user))
throw(ILLARG, "addRemoteTableCredentials", "local user name
cannot be nil");
assert(rt_key);
@@ -1158,7 +1158,7 @@ AUTHdeleteRemoteTableCredentials(const c
assert(rt_hashedpwd);
/* pre-condition check */
- if (local_table == NULL || strNil(local_table))
+ if (strNil(local_table))
throw(ILLARG, "deleteRemoteTableCredentials", "local table
cannot be nil");
/* ensure that the username exists */
diff --git a/monetdb5/modules/atoms/json.c b/monetdb5/modules/atoms/json.c
--- a/monetdb5/modules/atoms/json.c
+++ b/monetdb5/modules/atoms/json.c
@@ -2203,7 +2203,7 @@ JSONjsonaggr(BAT **bnp, BAT *b, BAT *g,
}
break;
}
- if (!v || strNil(v)) {
+ if (strNil(v)) {
if (skip_nils) {
/*
* if q is 1 and the value is
@@ -2292,7 +2292,7 @@ JSONjsonaggr(BAT **bnp, BAT *b, BAT *g,
}
break;
}
- if (!v || strNil(v)) {
+ if (strNil(v)) {
if (skip_nils)
continue;
strncpy(buf, str_nil, buflen);
@@ -2349,7 +2349,7 @@ JSONjsonaggr(BAT **bnp, BAT *b, BAT *g,
break;
}
- if (!v || strNil(v)) {
+ if (strNil(v)) {
if (skip_nils)
continue;
strncpy(buf, str_nil, buflen);
diff --git a/monetdb5/modules/kernel/batstr.c b/monetdb5/modules/kernel/batstr.c
--- a/monetdb5/modules/kernel/batstr.c
+++ b/monetdb5/modules/kernel/batstr.c
@@ -131,7 +131,7 @@ do_batstr_int(bat *ret, const bat *l, co
BATloop(b, p, q) {
x = (str) BUNtvar(bi, p);
- if (x == 0 || strNil(x)) {
+ if (strNil(x)) {
y = int_nil;
bn->tnonil = false;
bn->tnil = true;
@@ -179,7 +179,7 @@ do_batstr_str(bat *ret, const bat *l, co
BATloop(b, p, q) {
y = NULL;
x = (str) BUNtvar(bi, p);
- if (x != 0 && !strNil(x) &&
+ if (!strNil(x) &&
(msg = (*func)(&y, &x)) != MAL_SUCCEED)
goto bunins_failed1;
if (y == NULL)
@@ -224,7 +224,7 @@ do_batstr_conststr_str(bat *ret, const b
BATloop(b, p, q) {
y = NULL;
x = (str) BUNtvar(bi, p);
- if (x != 0 && !strNil(x) &&
+ if (!strNil(x) &&
(msg = (*func)(&y, &x, s2)) != MAL_SUCCEED)
goto bunins_failed1;
if (y == NULL)
@@ -276,8 +276,8 @@ do_batstr_batstr_str(bat *ret, const bat
y = NULL;
x = (str) BUNtvar(bi, p);
x2 = (str) BUNtvar(bi2, p);
- if (x != 0 && !strNil(x) &&
- x2 != 0 && !strNil(x2) &&
+ if (!strNil(x) &&
+ !strNil(x2) &&
(msg = (*func)(&y, &x, &x2)) != MAL_SUCCEED)
goto bunins_failed1;
if (y == NULL)
@@ -323,7 +323,7 @@ do_batstr_constint_str(bat *ret, const b
BATloop(b, p, q) {
y = NULL;
x = (str) BUNtvar(bi, p);
- if (x != 0 && !strNil(x) &&
+ if (!strNil(x) &&
(msg = (*func)(&y, &x, n)) != MAL_SUCCEED)
goto bunins_failed1;
if (y == NULL)
@@ -376,7 +376,7 @@ do_batstr_batint_str(bat *ret, const bat
y = NULL;
x = (str) BUNtvar(bi, p);
nn = *(int *)BUNtloc(bi2, p);
- if (x != 0 && !strNil(x) &&
+ if (!strNil(x) &&
(msg = (*func)(&y, &x, &nn)) != MAL_SUCCEED)
goto bunins_failed1;
if (y == NULL)
@@ -422,7 +422,7 @@ do_batstr_constint_conststr_str(bat *ret
BATloop(b, p, q) {
y = NULL;
x = (str) BUNtvar(bi, p);
- if (x != 0 && !strNil(x) &&
+ if (!strNil(x) &&
(msg = (*func)(&y, &x, n, s2)) != MAL_SUCCEED)
goto bunins_failed1;
if (y == NULL)
@@ -475,7 +475,7 @@ do_batstr_batint_conststr_str(bat *ret,
y = NULL;
x = (str) BUNtvar(bi, p);
nn = *(int *)BUNtloc(bi2, p);
- if (x != 0 && !strNil(x) &&
+ if (!strNil(x) &&
(msg = (*func)(&y, &x, &nn, s2)) != MAL_SUCCEED)
goto bunins_failed1;
if (y == NULL)
@@ -528,8 +528,8 @@ do_batstr_constint_batstr_str(bat *ret,
y = NULL;
x = (str) BUNtvar(bi, p);
x2 = (str) BUNtvar(bi2, p);
- if (x != 0 && !strNil(x) &&
- x2 != 0 && !strNil(x2) &&
+ if (!strNil(x) &&
+ !strNil(x2) &&
(msg = (*func)(&y, &x, n, &x2)) != MAL_SUCCEED)
goto bunins_failed1;
if (y == NULL)
@@ -595,8 +595,8 @@ do_batstr_batint_batstr_str(bat *ret, co
x = (str) BUNtvar(bi, p);
nn = *(int *)BUNtloc(bi2, p);
x2 = (str) BUNtvar(bi3, p);
- if (x != 0 && !strNil(x) &&
- x2 != 0 && !strNil(x2) &&
+ if (!strNil(x) &&
+ !strNil(x2) &&
(msg = (*func)(&y, &x, &nn, &x2)) != MAL_SUCCEED)
goto bunins_failed1;
if (y == NULL)
@@ -1175,7 +1175,7 @@ STRbatSubstitutecst(bat *ret, const bat
BATloop(b, p, q) {
y = (str) str_nil;
x = (str) BUNtvar(bi, p);
- if (x != 0 && !strNil(x) &&
+ if (!strNil(x) &&
(err = STRSubstitute(&y, &x, arg2, arg3, rep)) !=
MAL_SUCCEED)
goto bunins_failed;
bunfastappVAR(bn, y);
diff --git a/monetdb5/modules/mal/mal_mapi.c b/monetdb5/modules/mal/mal_mapi.c
--- a/monetdb5/modules/mal/mal_mapi.c
+++ b/monetdb5/modules/mal/mal_mapi.c
@@ -574,7 +574,7 @@ SERVERlisten(int port, const char *usock
if (psock == NULL)
throw(MAL,"mal_mapi.listen", SQLSTATE(HY013) MAL_MALLOC_FAIL);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list