summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Walden <jwalden@mit.edu>2020-06-05 20:52:42 +0000
committerJeff Walden <jwalden@mit.edu>2020-06-05 20:52:42 +0000
commitfeff10c787fd7be8dfdb70fbb8d6e51c84eb8081 (patch)
tree12b4c9d6050ae77f442d7cd3652c0c1520971bd2
parent0028e5cfd3712efb5f1b74bf2ec75e66e18f9643 (diff)
downloadnss-hg-feff10c787fd7be8dfdb70fbb8d6e51c84eb8081.tar.gz
Bug 1643557 - Add PORT_AssertNotReached and use it instead of PORT_Assert(!"str"), which may warn about vacuous string literal to boolean conversions. r=kjacobs
Depends on D78449 Differential Revision: https://phabricator.services.mozilla.com/D78450
-rw-r--r--lib/pk11wrap/pk11skey.c2
-rw-r--r--lib/ssl/sslsnce.c4
-rw-r--r--lib/util/secport.h3
3 files changed, 6 insertions, 3 deletions
diff --git a/lib/pk11wrap/pk11skey.c b/lib/pk11wrap/pk11skey.c
index 6a1e39644..ee17b60bd 100644
--- a/lib/pk11wrap/pk11skey.c
+++ b/lib/pk11wrap/pk11skey.c
@@ -2374,7 +2374,7 @@ pk11_PubDeriveECKeyWithKDF(
key_size = SHA512_LENGTH;
break;
default:
- PORT_Assert(!"Invalid CKD");
+ PORT_AssertNotReached("Invalid CKD");
PORT_SetError(SEC_ERROR_INVALID_ALGORITHM);
return NULL;
}
diff --git a/lib/ssl/sslsnce.c b/lib/ssl/sslsnce.c
index 2f43c05c0..acb51a145 100644
--- a/lib/ssl/sslsnce.c
+++ b/lib/ssl/sslsnce.c
@@ -703,7 +703,7 @@ ServerSessionIDLookup(PRTime sslNow, const PRIPv6Addr *addr,
/* what the ??. Didn't get the cert cache lock.
** Don't invalidate the SID cache entry, but don't find it.
*/
- PORT_Assert(!("Didn't get cert Cache Lock!"));
+ PORT_AssertNotReached("Didn't get cert Cache Lock!");
psce = 0;
pcce = 0;
}
@@ -730,7 +730,7 @@ ServerSessionIDLookup(PRTime sslNow, const PRIPv6Addr *addr,
/* what the ??. Didn't get the cert cache lock.
** Don't invalidate the SID cache entry, but don't find it.
*/
- PORT_Assert(!("Didn't get name Cache Lock!"));
+ PORT_AssertNotReached("Didn't get name Cache Lock!");
psce = 0;
psnce = 0;
}
diff --git a/lib/util/secport.h b/lib/util/secport.h
index d6f53f5e3..b3021afaf 100644
--- a/lib/util/secport.h
+++ b/lib/util/secport.h
@@ -126,6 +126,9 @@ SEC_END_PROTOS
* ignored. See more details in Bug 1588015. */
#define PORT_AssertArg PR_ASSERT_ARG
+/* Assert the current location can't be reached, passing a reason-string. */
+#define PORT_AssertNotReached(reasonStr) PR_NOT_REACHED(reasonStr)
+
/* macros to handle endian based byte conversion */
#define PORT_GET_BYTE_BE(value, offset, len) \
((unsigned char)(((len) - (offset)-1) >= sizeof(value) ? 0 : (((value) >> (((len) - (offset)-1) * PR_BITS_PER_BYTE)) & 0xff)))