Bug 940329: fix spammy implicit type-conversion warnings in nsTSubstring.h r=ehsan
authorNathan Froyd <froydnj@gmail.com>
Sun, 27 Apr 2014 00:29:25 -0400
changeset 180864 f656d5bc051e2f69615e33b62fa5e117bfe3e7be
parent 180863 18034a2d0732a1cefd859c5d576ffa2abf1a27dd
child 180865 ec96cdad9097020373fb78bdaafdaef492891c07
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewersehsan
bugs940329
milestone31.0a1
Bug 940329: fix spammy implicit type-conversion warnings in nsTSubstring.h r=ehsan
xpcom/string/public/nsTSubstring.h
--- a/xpcom/string/public/nsTSubstring.h
+++ b/xpcom/string/public/nsTSubstring.h
@@ -1,15 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 // IWYU pragma: private, include "nsString.h"
 
+#include "mozilla/Casting.h"
 #include "mozilla/MemoryReporting.h"
 
 #ifndef MOZILLA_INTERNAL_API
 #error Cannot use internal string classes without MOZILLA_INTERNAL_API defined. Use the frozen header nsStringAPI.h instead.
 #endif
 
   /**
    * The base for string comparators
@@ -372,21 +373,21 @@ class nsTSubstring_CharT
         }
 #endif
 
       void NS_FASTCALL AssignASCII( const char* data, size_type length );
       bool NS_FASTCALL AssignASCII( const char* data, size_type length, const fallible_t& ) NS_WARN_UNUSED_RESULT;
 
       void NS_FASTCALL AssignASCII( const char* data )
         {
-          AssignASCII(data, strlen(data));
+          AssignASCII(data, mozilla::SafeCast<size_type, size_t>(strlen(data)));
         }
       bool NS_FASTCALL AssignASCII( const char* data, const fallible_t& ) NS_WARN_UNUSED_RESULT
         {
-          return AssignASCII(data, strlen(data), fallible_t());
+          return AssignASCII(data, mozilla::SafeCast<size_type, size_t>(strlen(data)), 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
     // apply to small allocations that we wouldn't want to check anyway.