Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1363)

Unified Diff: mozilla/nsprpub/pr/src/io/prlayer.c

Issue 12089033: Update to NSPR 4.9.5 Beta 2, part 2: actual changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/nss/
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mozilla/nsprpub/pr/src/io/prfile.c ('k') | mozilla/nsprpub/pr/src/io/prmapopt.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mozilla/nsprpub/pr/src/io/prlayer.c
===================================================================
--- mozilla/nsprpub/pr/src/io/prlayer.c (revision 179237)
+++ mozilla/nsprpub/pr/src/io/prlayer.c (working copy)
@@ -523,6 +523,11 @@
*stack = *fd;
*fd = copy;
fd->higher = stack;
+ if (fd->lower)
+ {
+ PR_ASSERT(fd->lower->higher == stack);
+ fd->lower->higher = fd;
+ }
stack->lower = fd;
stack->higher = NULL;
} else {
@@ -561,6 +566,10 @@
*stack = *extract;
*extract = copy;
stack->higher = NULL;
+ if (stack->lower) {
+ PR_ASSERT(stack->lower->higher == extract);
+ stack->lower->higher = stack;
+ }
} else if ((PR_IO_LAYER_HEAD == stack->identity) &&
(extract == stack->lower) && (extract->lower == NULL)) {
/*
@@ -612,8 +621,15 @@
/* this initial code runs unsafe */
retry:
PR_ASSERT(NULL == names);
+ /*
+ * In the initial round, both identity_cache.ident and
+ * identity_cache.length are 0, so (identity_cache.ident + 1) is greater
+ * than length. In later rounds, identity_cache.ident is always less
+ * than length, so (identity_cache.ident + 1) can be equal to but cannot
+ * be greater than length.
+ */
length = identity_cache.length;
- if (length < (identity_cache.ident + 1))
+ if ((identity_cache.ident + 1) >= length)
{
length += ID_CACHE_INCREMENT;
names = (char**)PR_CALLOC(length * sizeof(char*));
@@ -627,12 +643,13 @@
/* now we get serious about thread safety */
PR_Lock(identity_cache.ml);
- PR_ASSERT(identity_cache.ident <= identity_cache.length);
+ PR_ASSERT(identity_cache.length == 0 ||
+ identity_cache.ident < identity_cache.length);
identity = identity_cache.ident + 1;
- if (identity > identity_cache.length) /* there's no room */
+ if (identity >= identity_cache.length) /* there's no room */
{
/* we have to do something - hopefully it's already done */
- if ((NULL != names) && (length >= identity))
+ if ((NULL != names) && (identity < length))
{
/* what we did is still okay */
memcpy(
@@ -645,7 +662,6 @@
}
else
{
- PR_ASSERT(identity_cache.ident <= identity_cache.length);
PR_Unlock(identity_cache.ml);
if (NULL != names) PR_DELETE(names);
goto retry;
@@ -656,7 +672,7 @@
identity_cache.name[identity] = name;
}
identity_cache.ident = identity;
- PR_ASSERT(identity_cache.ident <= identity_cache.length);
+ PR_ASSERT(identity_cache.ident < identity_cache.length);
PR_Unlock(identity_cache.ml);
if (NULL != old) PR_DELETE(old);
« no previous file with comments | « mozilla/nsprpub/pr/src/io/prfile.c ('k') | mozilla/nsprpub/pr/src/io/prmapopt.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698