Skip to content

Commit

Permalink
Bug 1643557 - Add PORT_AssertNotReached and use it instead of PORT_As…
Browse files Browse the repository at this point in the history
…sert(!"str"), which may warn about vacuous string literal to boolean conversions. r=kjacobs

Depends on D78449

Differential Revision: https://phabricator.services.mozilla.com/D78450

--HG--
extra : moz-landing-system : lando
  • Loading branch information
jswalden committed Jun 5, 2020
1 parent 6a7d113 commit b66477b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/pk11wrap/pk11skey.c
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/ssl/sslsnce.c
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
3 changes: 3 additions & 0 deletions lib/util/secport.h
Expand Up @@ -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)))
Expand Down

0 comments on commit b66477b

Please sign in to comment.