Bug 1045801 - Rename SafeCast to AssertedCast. r=Waldo
authorBirunthan Mohanathas <birunthan@mohanathas.com>
Mon, 25 Aug 2014 12:17:32 -0700
changeset 201413 e8e520884505d30ba184c162bb30f15b5210645a
parent 201412 7afb7c612b5af06164e8495b12fa126b071c2a0e
child 201414 97c62ea49a7c0010ec7834ca377155c55b7bbf04
push id48166
push userbirunthan@mohanathas.com
push dateMon, 25 Aug 2014 19:18:39 +0000
treeherdermozilla-inbound@47ecfa3c421f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersWaldo
bugs1045801
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1045801 - Rename SafeCast to AssertedCast. r=Waldo
content/html/content/src/HTMLSelectElement.cpp
docshell/base/nsDocShell.cpp
dom/events/EventStateManager.cpp
editor/libeditor/nsEditor.cpp
editor/libeditor/nsWSRunObject.cpp
js/src/builtin/TypedObject.cpp
js/src/jit/IonBuilder.cpp
js/src/jsfriendapi.h
js/src/jsstr.cpp
js/src/vm/NumericConversions.h
layout/forms/nsListControlFrame.cpp
layout/style/CSSStyleSheet.cpp
layout/style/nsCSSRules.cpp
mfbt/Casting.h
mfbt/decimal/moz-decimal-utils.h
security/manager/ssl/src/PSMContentListener.cpp
security/manager/ssl/src/nsNSSIOLayer.cpp
xpcom/string/nsTSubstring.h
--- a/content/html/content/src/HTMLSelectElement.cpp
+++ b/content/html/content/src/HTMLSelectElement.cpp
@@ -968,18 +968,18 @@ HTMLSelectElement::SetOptionsSelectedByI
   bool optionsDeselected = false;
 
   nsISelectControlFrame* selectFrame = nullptr;
   bool didGetFrame = false;
   nsWeakFrame weakSelectFrame;
 
   if (aOptionsMask & IS_SELECTED) {
     // Setting selectedIndex to an out-of-bounds index means -1. (HTML5)
-    if (aStartIndex < 0 || SafeCast<uint32_t>(aStartIndex) >= numItems ||
-        aEndIndex < 0 || SafeCast<uint32_t>(aEndIndex) >= numItems) {
+    if (aStartIndex < 0 || AssertedCast<uint32_t>(aStartIndex) >= numItems ||
+        aEndIndex < 0 || AssertedCast<uint32_t>(aEndIndex) >= numItems) {
       aStartIndex = -1;
       aEndIndex = -1;
     }
 
     // Only select the first value if it's not multiple
     if (!isMultiple) {
       aEndIndex = aStartIndex;
     }
@@ -999,18 +999,18 @@ HTMLSelectElement::SetOptionsSelectedByI
     // Select the requested indices
     //
     // If index is -1, everything will be deselected (bug 28143)
     if (aStartIndex != -1) {
       MOZ_ASSERT(aStartIndex >= 0);
       MOZ_ASSERT(aEndIndex >= 0);
       // Loop through the options and select them (if they are not disabled and
       // if they are not already selected).
-      for (uint32_t optIndex = SafeCast<uint32_t>(aStartIndex);
-           optIndex <= SafeCast<uint32_t>(aEndIndex);
+      for (uint32_t optIndex = AssertedCast<uint32_t>(aStartIndex);
+           optIndex <= AssertedCast<uint32_t>(aEndIndex);
            optIndex++) {
         nsRefPtr<HTMLOptionElement> option = Item(optIndex);
 
         // Ignore disabled options.
         if (!(aOptionsMask & SET_DISABLED)) {
           if (option && IsOptionDisabled(option)) {
             continue;
           }
@@ -1035,17 +1035,17 @@ HTMLSelectElement::SetOptionsSelectedByI
     }
 
     // Next remove all other options if single select or all is clear
     // If index is -1, everything will be deselected (bug 28143)
     if (((!isMultiple && optionsSelected)
        || ((aOptionsMask & CLEAR_ALL) && !allDisabled)
        || aStartIndex == -1)
        && previousSelectedIndex != -1) {
-      for (uint32_t optIndex = SafeCast<uint32_t>(previousSelectedIndex);
+      for (uint32_t optIndex = AssertedCast<uint32_t>(previousSelectedIndex);
            optIndex < numItems;
            optIndex++) {
         if (static_cast<int32_t>(optIndex) < aStartIndex ||
             static_cast<int32_t>(optIndex) > aEndIndex) {
           HTMLOptionElement* option = Item(optIndex);
           // If the index is already selected, ignore it.
           if (option && option->Selected()) {
             if (!didGetFrame || (selectFrame && !weakSelectFrame.IsAlive())) {
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -872,17 +872,17 @@ nsDocShell::nsDocShell():
 #ifdef DEBUG
   // We're counting the number of |nsDocShells| to help find leaks
   ++gNumberOfDocShells;
   if (!PR_GetEnv("MOZ_QUIET")) {
       printf_stderr("++DOCSHELL %p == %ld [pid = %d] [id = %llu]\n",
                     (void*) this,
                     gNumberOfDocShells,
                     getpid(),
-                    SafeCast<unsigned long long>(mHistoryID));
+                    AssertedCast<unsigned long long>(mHistoryID));
   }
 #endif
 }
 
 nsDocShell::~nsDocShell()
 {
     Destroy();
 
@@ -904,17 +904,17 @@ nsDocShell::~nsDocShell()
 #ifdef DEBUG
     // We're counting the number of |nsDocShells| to help find leaks
     --gNumberOfDocShells;
     if (!PR_GetEnv("MOZ_QUIET")) {
         printf_stderr("--DOCSHELL %p == %ld [pid = %d] [id = %llu]\n",
                       (void*) this,
                       gNumberOfDocShells,
                       getpid(),
-                      SafeCast<unsigned long long>(mHistoryID));
+                      AssertedCast<unsigned long long>(mHistoryID));
     }
 #endif
 }
 
 nsresult
 nsDocShell::Init()
 {
     nsresult rv = nsDocLoader::Init();
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -1591,18 +1591,18 @@ EventStateManager::GenerateDragGesture(n
       if (!pixelThresholdY)
         pixelThresholdY = 5;
     }
 
     // fire drag gesture if mouse has moved enough
     LayoutDeviceIntPoint pt = aEvent->refPoint +
       LayoutDeviceIntPoint::FromUntyped(aEvent->widget->WidgetToScreenOffset());
     LayoutDeviceIntPoint distance = pt - mGestureDownPoint;
-    if (Abs(distance.x.value) > SafeCast<uint32_t>(pixelThresholdX) ||
-        Abs(distance.y.value) > SafeCast<uint32_t>(pixelThresholdY)) {
+    if (Abs(distance.x.value) > AssertedCast<uint32_t>(pixelThresholdX) ||
+        Abs(distance.y.value) > AssertedCast<uint32_t>(pixelThresholdY)) {
       if (Prefs::ClickHoldContextMenu()) {
         // stop the click-hold before we fire off the drag gesture, in case
         // it takes a long time
         KillClickHoldTimer();
       }
 
       nsCOMPtr<nsISupports> container = aPresContext->GetContainerWeak();
       nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(container);
--- a/editor/libeditor/nsEditor.cpp
+++ b/editor/libeditor/nsEditor.cpp
@@ -1684,24 +1684,25 @@ nsEditor::InsertContainerAbove(nsIConten
 ///////////////////////////////////////////////////////////////////////////
 // MoveNode:  move aNode to {aParent,aOffset}
 nsresult
 nsEditor::MoveNode(nsIContent* aNode, nsINode* aParent, int32_t aOffset)
 {
   MOZ_ASSERT(aNode);
   MOZ_ASSERT(aParent);
   MOZ_ASSERT(aOffset == -1 ||
-             (0 <= aOffset && SafeCast<uint32_t>(aOffset) <= aParent->Length()));
+             (0 <= aOffset &&
+              AssertedCast<uint32_t>(aOffset) <= aParent->Length()));
 
   nsCOMPtr<nsINode> oldParent = aNode->GetParentNode();
   int32_t oldOffset = oldParent ? oldParent->IndexOf(aNode) : -1;
 
   if (aOffset == -1) {
     // Magic value meaning "move to end of aParent"
-    aOffset = SafeCast<int32_t>(aParent->Length());
+    aOffset = AssertedCast<int32_t>(aParent->Length());
   }
 
   // Don't do anything if it's already in right place
   if (aParent == oldParent && aOffset == oldOffset) {
     return NS_OK;
   }
 
   // Notify our internal selection state listener
@@ -2865,17 +2866,17 @@ nsEditor::JoinNodesImpl(nsINode* aNodeTo
   }
 
   // delete the extra node
   ErrorResult err;
   aParent->RemoveChild(*aNodeToJoin, err);
 
   if (GetShouldTxnSetSelection()) {
     // editor wants us to set selection at join point
-    selection->Collapse(aNodeToKeep, SafeCast<int32_t>(firstNodeLength));
+    selection->Collapse(aNodeToKeep, AssertedCast<int32_t>(firstNodeLength));
   } else if (selStartNode) {
     // and adjust the selection if needed
     // HACK: this is overly simplified - multi-range selections need more work than this
     bool bNeedToAdjust = false;
 
     // check to see if we joined nodes where selection starts
     if (selStartNode == aNodeToJoin) {
       bNeedToAdjust = true;
--- a/editor/libeditor/nsWSRunObject.cpp
+++ b/editor/libeditor/nsWSRunObject.cpp
@@ -1353,23 +1353,25 @@ nsWSRunObject::DeleteChars(nsINode* aSta
     nsRefPtr<Text> node = mNodeArray[idx];
     if (!node) {
       // We ran out of ws nodes; must have been deleting to end
       return NS_OK;
     }
     if (node == aStartNode) {
       uint32_t len = node->Length();
       if (uint32_t(aStartOffset) < len) {
-        res = mHTMLEditor->DeleteText(*node, SafeCast<uint32_t>(aStartOffset),
+        res = mHTMLEditor->DeleteText(*node,
+                                      AssertedCast<uint32_t>(aStartOffset),
                                       len - aStartOffset);
         NS_ENSURE_SUCCESS(res, res);
       }
     } else if (node == aEndNode) {
       if (aEndOffset) {
-        res = mHTMLEditor->DeleteText(*node, 0, SafeCast<uint32_t>(aEndOffset));
+        res = mHTMLEditor->DeleteText(*node, 0,
+                                      AssertedCast<uint32_t>(aEndOffset));
         NS_ENSURE_SUCCESS(res, res);
       }
       break;
     } else {
       if (!range) {
         range = new nsRange(aStartNode);
         res = range->Set(aStartNode, aStartOffset, aEndNode, aEndOffset);
         NS_ENSURE_SUCCESS(res, res);
--- a/js/src/builtin/TypedObject.cpp
+++ b/js/src/builtin/TypedObject.cpp
@@ -22,19 +22,19 @@
 #include "vm/StringBuffer.h"
 #include "vm/TypedArrayObject.h"
 
 #include "jsatominlines.h"
 #include "jsobjinlines.h"
 
 #include "vm/Shape-inl.h"
 
+using mozilla::AssertedCast;
 using mozilla::CheckedInt32;
 using mozilla::DebugOnly;
-using mozilla::SafeCast;
 
 using namespace js;
 
 const Class js::TypedObjectModuleObject::class_ = {
     "TypedObject",
     JSCLASS_HAS_RESERVED_SLOTS(SlotCount) |
     JSCLASS_HAS_CACHED_PROTO(JSProto_TypedObject),
     JS_PropertyStub,         /* addProperty */
@@ -1157,26 +1157,26 @@ StructTypeDescr::fieldName(size_t index)
 }
 
 size_t
 StructTypeDescr::fieldOffset(size_t index) const
 {
     JSObject &fieldOffsets =
         getReservedSlot(JS_DESCR_SLOT_STRUCT_FIELD_OFFSETS).toObject();
     JS_ASSERT(index < fieldOffsets.getDenseInitializedLength());
-    return SafeCast<size_t>(fieldOffsets.getDenseElement(index).toInt32());
+    return AssertedCast<size_t>(fieldOffsets.getDenseElement(index).toInt32());
 }
 
 size_t
 StructTypeDescr::maybeForwardedFieldOffset(size_t index) const
 {
     JSObject &fieldOffsets =
         *MaybeForwarded(&getReservedSlot(JS_DESCR_SLOT_STRUCT_FIELD_OFFSETS).toObject());
     JS_ASSERT(index < fieldOffsets.getDenseInitializedLength());
-    return SafeCast<size_t>(fieldOffsets.getDenseElement(index).toInt32());
+    return AssertedCast<size_t>(fieldOffsets.getDenseElement(index).toInt32());
 }
 
 SizedTypeDescr&
 StructTypeDescr::fieldDescr(size_t index) const
 {
     JSObject &fieldDescrs =
         getReservedSlot(JS_DESCR_SLOT_STRUCT_FIELD_TYPES).toObject();
     JS_ASSERT(index < fieldDescrs.getDenseInitializedLength());
--- a/js/src/jit/IonBuilder.cpp
+++ b/js/src/jit/IonBuilder.cpp
@@ -28,19 +28,19 @@
 #include "jsscriptinlines.h"
 
 #include "jit/CompileInfo-inl.h"
 #include "jit/ExecutionMode-inl.h"
 
 using namespace js;
 using namespace js::jit;
 
+using mozilla::AssertedCast;
 using mozilla::DebugOnly;
 using mozilla::Maybe;
-using mozilla::SafeCast;
 
 class jit::BaselineFrameInspector
 {
   public:
     types::Type thisType;
     JSObject *singletonScopeChain;
 
     Vector<types::Type, 4, IonAllocPolicy> argTypes;
@@ -7547,17 +7547,17 @@ IonBuilder::addTypedArrayLengthAndData(M
             // The 'data' pointer can change in rare circumstances
             // (ArrayBufferObject::changeContents).
             types::TypeObjectKey *tarrType = types::TypeObjectKey::get(tarr);
             if (!tarrType->unknownProperties()) {
                 tarrType->watchStateChangeForTypedArrayData(constraints());
 
                 obj->setImplicitlyUsedUnchecked();
 
-                int32_t len = SafeCast<int32_t>(tarr->length());
+                int32_t len = AssertedCast<int32_t>(tarr->length());
                 *length = MConstant::New(alloc(), Int32Value(len));
                 current->add(*length);
 
                 if (index) {
                     if (checking == DoBoundsCheck)
                         *index = addBoundsCheck(*index, *length);
 
                     *elements = MConstantElements::New(alloc(), data);
--- a/js/src/jsfriendapi.h
+++ b/js/src/jsfriendapi.h
@@ -1652,17 +1652,17 @@ const size_t TypedArrayLengthSlot = 1;
  */
 
 #define JS_DEFINE_DATA_AND_LENGTH_ACCESSOR(Type, type) \
 inline void \
 Get ## Type ## ArrayLengthAndData(JSObject *obj, uint32_t *length, type **data) \
 { \
     JS_ASSERT(GetObjectClass(obj) == detail::Type ## ArrayClassPtr); \
     const JS::Value &slot = GetReservedSlot(obj, detail::TypedArrayLengthSlot); \
-    *length = mozilla::SafeCast<uint32_t>(slot.toInt32()); \
+    *length = mozilla::AssertedCast<uint32_t>(slot.toInt32()); \
     *data = static_cast<type*>(GetObjectPrivate(obj)); \
 }
 
 JS_DEFINE_DATA_AND_LENGTH_ACCESSOR(Int8, int8_t)
 JS_DEFINE_DATA_AND_LENGTH_ACCESSOR(Uint8, uint8_t)
 JS_DEFINE_DATA_AND_LENGTH_ACCESSOR(Uint8Clamped, uint8_t)
 JS_DEFINE_DATA_AND_LENGTH_ACCESSOR(Int16, int16_t)
 JS_DEFINE_DATA_AND_LENGTH_ACCESSOR(Uint16, uint16_t)
--- a/js/src/jsstr.cpp
+++ b/js/src/jsstr.cpp
@@ -53,25 +53,25 @@
 using namespace js;
 using namespace js::gc;
 using namespace js::types;
 using namespace js::unicode;
 
 using JS::Symbol;
 using JS::SymbolCode;
 
+using mozilla::AssertedCast;
 using mozilla::CheckedInt;
 using mozilla::IsNaN;
 using mozilla::IsNegativeZero;
 using mozilla::IsSame;
 using mozilla::Move;
 using mozilla::PodCopy;
 using mozilla::PodEqual;
 using mozilla::RangedPtr;
-using mozilla::SafeCast;
 using mozilla::UniquePtr;
 
 using JS::AutoCheckCannotGC;
 
 static JSLinearString *
 ArgToRootedString(JSContext *cx, CallArgs &args, unsigned argno)
 {
     if (argno >= args.length())
@@ -235,17 +235,17 @@ template <typename CharT>
 static bool
 Unescape(StringBuffer &sb, const mozilla::Range<const CharT> chars)
 {
     /*
      * NB: use signed integers for length/index to allow simple length
      * comparisons without unsigned-underflow hazards.
      */
     static_assert(JSString::MAX_LENGTH <= INT_MAX, "String length must fit in a signed integer");
-    int length = SafeCast<int>(chars.length());
+    int length = AssertedCast<int>(chars.length());
 
     /*
      * Note that the spec algorithm has been optimized to avoid building
      * a string in the case where no escapes are present.
      */
 
     /* Step 4. */
     int k = 0;
@@ -1009,17 +1009,17 @@ str_normalize(JSContext *cx, unsigned ar
     // Step 8.
     AutoStableStringChars stableChars(cx);
     if (!str->ensureFlat(cx) || !stableChars.initTwoByte(cx, str))
         return false;
 
     static const size_t INLINE_CAPACITY = 32;
 
     const UChar *srcChars = JSCharToUChar(stableChars.twoByteRange().start().get());
-    int32_t srcLen = SafeCast<int32_t>(str->length());
+    int32_t srcLen = AssertedCast<int32_t>(str->length());
     Vector<jschar, INLINE_CAPACITY> chars(cx);
     if (!chars.resize(INLINE_CAPACITY))
         return false;
 
     UErrorCode status = U_ZERO_ERROR;
     int32_t size = unorm_normalize(srcChars, srcLen, form, 0,
                                    JSCharToUChar(chars.begin()), INLINE_CAPACITY,
                                    &status);
--- a/js/src/vm/NumericConversions.h
+++ b/js/src/vm/NumericConversions.h
@@ -47,17 +47,17 @@ ToUintWidth(double d)
         int_fast16_t((bits & mozilla::FloatingPoint<double>::kExponentBits) >> DoubleExponentShift) -
         int_fast16_t(mozilla::FloatingPoint<double>::kExponentBias);
 
     // If the exponent's less than zero, abs(d) < 1, so the result is 0.  (This
     // also handles subnormals.)
     if (exp < 0)
         return 0;
 
-    uint_fast16_t exponent = mozilla::SafeCast<uint_fast16_t>(exp);
+    uint_fast16_t exponent = mozilla::AssertedCast<uint_fast16_t>(exp);
 
     // If the exponent is greater than or equal to the bits of precision of a
     // double plus ResultType's width, the number is either infinite, NaN, or
     // too large to have lower-order bits in the congruent value.  (Example:
     // 2**84 is exactly representable as a double.  The next exact double is
     // 2**84 + 2**32.  Thus if ResultType is int32_t, an exponent >= 84 implies
     // floor(abs(d)) == 0 mod 2**32.)  Return 0 in all these cases.
     const size_t ResultWidth = CHAR_BIT * sizeof(ResultType);
--- a/layout/forms/nsListControlFrame.cpp
+++ b/layout/forms/nsListControlFrame.cpp
@@ -1073,17 +1073,17 @@ dom::HTMLOptionElement*
 nsListControlFrame::GetCurrentOption()
 {
   // The mEndSelectionIndex is what is currently being selected. Use
   // the selected index if this is kNothingSelected.
   int32_t focusedIndex = (mEndSelectionIndex == kNothingSelected) ?
     GetSelectedIndex() : mEndSelectionIndex;
 
   if (focusedIndex != kNothingSelected) {
-    return GetOption(SafeCast<uint32_t>(focusedIndex));
+    return GetOption(AssertedCast<uint32_t>(focusedIndex));
   }
 
   // There is no selected item. Return the first non-disabled item.
   nsRefPtr<dom::HTMLSelectElement> selectElement =
     dom::HTMLSelectElement::FromContent(mContent);
 
   for (uint32_t i = 0, length = selectElement->Length(); i < length; ++i) {
     dom::HTMLOptionElement* node = selectElement->Item(i);
@@ -1901,17 +1901,17 @@ void
 nsListControlFrame::ScrollToIndex(int32_t aIndex)
 {
   if (aIndex < 0) {
     // XXX shouldn't we just do nothing if we're asked to scroll to
     // kNothingSelected?
     ScrollTo(nsPoint(0, 0), nsIScrollableFrame::INSTANT);
   } else {
     nsRefPtr<dom::HTMLOptionElement> option =
-      GetOption(SafeCast<uint32_t>(aIndex));
+      GetOption(AssertedCast<uint32_t>(aIndex));
     if (option) {
       ScrollToFrame(*option);
     }
   }
 }
 
 void
 nsListControlFrame::ScrollToFrame(dom::HTMLOptionElement& aOptElement)
--- a/layout/style/CSSStyleSheet.cpp
+++ b/layout/style/CSSStyleSheet.cpp
@@ -89,17 +89,17 @@ CSSRuleListImpl::GetParentObject()
 
 uint32_t
 CSSRuleListImpl::Length()
 {
   if (!mStyleSheet) {
     return 0;
   }
 
-  return SafeCast<uint32_t>(mStyleSheet->StyleRuleCount());
+  return AssertedCast<uint32_t>(mStyleSheet->StyleRuleCount());
 }
 
 nsIDOMCSSRule*    
 CSSRuleListImpl::IndexedGetter(uint32_t aIndex, bool& aFound)
 {
   aFound = false;
 
   if (mStyleSheet) {
--- a/layout/style/nsCSSRules.cpp
+++ b/layout/style/nsCSSRules.cpp
@@ -179,17 +179,17 @@ GroupRuleRuleList::GetParentObject()
 
 uint32_t
 GroupRuleRuleList::Length()
 {
   if (!mGroupRule) {
     return 0;
   }
 
-  return SafeCast<uint32_t>(mGroupRule->StyleRuleCount());
+  return AssertedCast<uint32_t>(mGroupRule->StyleRuleCount());
 }
 
 nsIDOMCSSRule*
 GroupRuleRuleList::IndexedGetter(uint32_t aIndex, bool& aFound)
 {
   aFound = false;
 
   if (mGroupRule) {
--- a/mfbt/Casting.h
+++ b/mfbt/Casting.h
@@ -205,17 +205,17 @@ IsInBounds(const From aFrom)
 
 /**
  * Cast a value of integral type |From| to a value of integral type |To|,
  * asserting that the cast will be a safe cast per C++ (that is, that |to| is in
  * the range of values permitted for the type |From|).
  */
 template<typename To, typename From>
 inline To
-SafeCast(const From aFrom)
+AssertedCast(const From aFrom)
 {
   MOZ_ASSERT((detail::IsInBounds<From, To>(aFrom)));
   return static_cast<To>(aFrom);
 }
 
 } // namespace mozilla
 
 #endif /* mozilla_Casting_h */
--- a/mfbt/decimal/moz-decimal-utils.h
+++ b/mfbt/decimal/moz-decimal-utils.h
@@ -49,17 +49,17 @@ namespace std {
 
 typedef std::string String;
 
 double mozToDouble(const String &aStr, bool *valid) {
   double_conversion::StringToDoubleConverter converter(
     double_conversion::StringToDoubleConverter::NO_FLAGS,
     mozilla::UnspecifiedNaN<double>(), mozilla::UnspecifiedNaN<double>(), nullptr, nullptr);
   const char* str = aStr.c_str();
-  int length = mozilla::SafeCast<int>(strlen(str));
+  int length = mozilla::AssertedCast<int>(strlen(str));
   int processed_char_count; // unused - NO_FLAGS requires the whole string to parse
   double result = converter.StringToDouble(str, length, &processed_char_count);
   *valid = mozilla::IsFinite(result);
   return result;
 }
 
 String mozToString(double aNum) {
   char buffer[64];
--- a/security/manager/ssl/src/PSMContentListener.cpp
+++ b/security/manager/ssl/src/PSMContentListener.cpp
@@ -89,17 +89,17 @@ PSMContentDownloader::OnStartRequest(nsI
   rv = channel->GetContentLength(&contentLength);
   if (NS_FAILED(rv) || contentLength <= 0)
     contentLength = kDefaultCertAllocLength;
   if (contentLength > INT32_MAX)
     return NS_ERROR_OUT_OF_MEMORY;
   
   mBufferOffset = 0;
   mBufferSize = 0;
-  mByteData = (char*) nsMemory::Alloc(SafeCast<size_t>(contentLength));
+  mByteData = (char*)nsMemory::Alloc(AssertedCast<size_t>(contentLength));
   if (!mByteData)
     return NS_ERROR_OUT_OF_MEMORY;
   
   mBufferSize = int32_t(contentLength);
   return NS_OK;
 }
 
 NS_IMETHODIMP
--- a/security/manager/ssl/src/nsNSSIOLayer.cpp
+++ b/security/manager/ssl/src/nsNSSIOLayer.cpp
@@ -633,17 +633,17 @@ nsNSSSocketInfo::SetCertVerificationResu
   }
 
   if (errorCode) {
     SetCanceled(errorCode, errorMessageType);
   }
 
   if (mPlaintextBytesRead && !errorCode) {
     Telemetry::Accumulate(Telemetry::SSL_BYTES_BEFORE_CERT_CALLBACK,
-                          SafeCast<uint32_t>(mPlaintextBytesRead));
+                          AssertedCast<uint32_t>(mPlaintextBytesRead));
   }
 
   mCertVerificationState = after_cert_verification;
 }
 
 SharedSSLState&
 nsNSSSocketInfo::SharedState()
 {
--- a/xpcom/string/nsTSubstring.h
+++ b/xpcom/string/nsTSubstring.h
@@ -399,23 +399,23 @@ public:
 
   void NS_FASTCALL AssignASCII(const char* aData, size_type aLength);
   NS_WARN_UNUSED_RESULT bool NS_FASTCALL AssignASCII(const char* aData,
                                                      size_type aLength,
                                                      const fallible_t&);
 
   void NS_FASTCALL AssignASCII(const char* aData)
   {
-    AssignASCII(aData, mozilla::SafeCast<size_type, size_t>(strlen(aData)));
+    AssignASCII(aData, mozilla::AssertedCast<size_type, size_t>(strlen(aData)));
   }
   NS_WARN_UNUSED_RESULT bool NS_FASTCALL AssignASCII(const char* aData,
                                                      const fallible_t&)
   {
     return AssignASCII(aData,
-                       mozilla::SafeCast<size_type, size_t>(strlen(aData)),
+                       mozilla::AssertedCast<size_type, size_t>(strlen(aData)),
                        fallible_t());
   }
 
   // AssignLiteral must ONLY be applied to an actual literal string, or
   // a char array *constant* declared without an explicit size.
   // Do not attempt to use it with a regular char* pointer, or with a
   // non-constant char array variable. Use AssignASCII for those.
   // There are not fallible version of these methods because they only really