commit 9398bd6f4378 Author: Eric Rahm Date: Tue Aug 22 19:30:46 2017 -0700 Bug 1393235 - Fix improper usages of string functions. r=njn This fixes usages of `Find`, `RFind` and the equality operator that kind of work right now but will break with the proper type checking of a templatized version of the string classes. For `Find` and `RFind` it appears that `nsCString::(R)Find("foo", 0)` calls were being coerced to the `Find(char*, bool, int, int)` versions. The intent was probably to just start searching from position zero. For the equality operator, the type of nullptr is nullptr_t rather than char(16_t)* so we'd need to add an operator overload that takes nullptr_t. In this case just using `IsVoid` is probably more appropriate. --HG-- extra : rebase_source : 50f78519084012ca669da0a211c489520c11d6b6 --- docshell/base/nsDefaultURIFixup.cpp | 2 +- dom/media/gmp/ChromiumCDMChild.cpp | 2 +- toolkit/components/places/nsNavHistory.cpp | 2 +- toolkit/components/url-classifier/Classifier.cpp | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git docshell/base/nsDefaultURIFixup.cpp docshell/base/nsDefaultURIFixup.cpp index 77e008b15a17..a1a893b8efb2 100644 --- docshell/base/nsDefaultURIFixup.cpp +++ docshell/base/nsDefaultURIFixup.cpp @@ -687,7 +687,7 @@ nsDefaultURIFixup::FixupURIProtocol(const nsACString& aURIString, // no-scheme.com/query?foo=http://www.foo.com // user:pass@no-scheme.com // - int32_t schemeDelim = uriString.Find("://", 0); + int32_t schemeDelim = uriString.Find("://"); int32_t firstDelim = uriString.FindCharInSet("/:"); if (schemeDelim <= 0 || (firstDelim != -1 && schemeDelim > firstDelim)) { diff --git dom/media/gmp/ChromiumCDMChild.cpp dom/media/gmp/ChromiumCDMChild.cpp index e99f913622ab..8dc288b4c57e 100644 --- dom/media/gmp/ChromiumCDMChild.cpp +++ dom/media/gmp/ChromiumCDMChild.cpp @@ -232,7 +232,7 @@ ChromiumCDMChild::OnResolveNewSessionPromiseInternal(uint32_t aPromiseId, // a session it calls OnResolveNewSessionPromise with nullptr as the sessionId. // We can safely assume this means that we have failed to load a session // as the other methods specify calling 'OnRejectPromise' when they fail. - bool loadSuccessful = aSessionId != nullptr; + bool loadSuccessful = !aSessionId.IsEmpty(); GMP_LOG("ChromiumCDMChild::OnResolveNewSessionPromise(pid=%u, sid=%s) " "resolving %s load session ", aPromiseId, diff --git toolkit/components/places/nsNavHistory.cpp toolkit/components/places/nsNavHistory.cpp index 4e52752529fa..0b01d904b2f7 100644 --- toolkit/components/places/nsNavHistory.cpp +++ toolkit/components/places/nsNavHistory.cpp @@ -1939,7 +1939,7 @@ PlacesSQLQueryBuilder::Where() // If we used WHERE already, we inject the conditions // in place of {ADDITIONAL_CONDITIONS} - if (mQueryString.Find("{ADDITIONAL_CONDITIONS}", 0) != kNotFound) { + if (mQueryString.Find("{ADDITIONAL_CONDITIONS}") != kNotFound) { nsAutoCString innerCondition; // If we have condition AND it if (!mConditions.IsEmpty()) { diff --git toolkit/components/url-classifier/Classifier.cpp toolkit/components/url-classifier/Classifier.cpp index 500780150a91..68169925d2d0 100644 --- toolkit/components/url-classifier/Classifier.cpp +++ toolkit/components/url-classifier/Classifier.cpp @@ -992,7 +992,7 @@ Classifier::ScanStoreDir(nsIFile* aDirectory, nsTArray& aTables) // Both v2 and v4 contain .pset file nsCString suffix(NS_LITERAL_CSTRING(".pset")); - int32_t dot = leafName.RFind(suffix, 0); + int32_t dot = leafName.RFind(suffix); if (dot != -1) { leafName.Cut(dot, suffix.Length()); aTables.AppendElement(leafName); @@ -1582,7 +1582,7 @@ Classifier::LoadMetadata(nsIFile* aDirectory, nsACString& aResult) rv = file->GetNativeLeafName(tableName); NS_ENSURE_SUCCESS(rv, rv); - int32_t dot = tableName.RFind(METADATA_SUFFIX, 0); + int32_t dot = tableName.RFind(METADATA_SUFFIX); if (dot == -1) { continue; }