From 291b55ca2ce1342759caa838ff795b762f864a0a Mon Sep 17 00:00:00 2001 From: Andrew McCreight Date: Mon, 20 Apr 2015 12:48:15 -0700 Subject: [PATCH] Bug 1144298 - Eliminate gratuitous gotos from Directory::RemoveInternal(). r=baku --HG-- extra : rebase_source : c9194f875c3cff90649b80e5904812597934968f --- dom/filesystem/Directory.cpp | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/dom/filesystem/Directory.cpp b/dom/filesystem/Directory.cpp index 3bdacc0017e2..916d243df43d 100644 --- a/dom/filesystem/Directory.cpp +++ b/dom/filesystem/Directory.cpp @@ -198,29 +198,20 @@ Directory::RemoveInternal(const StringOrFileOrDirectory& aPath, bool aRecursive, if (aPath.IsFile()) { file = aPath.GetAsFile().Impl(); - goto parameters_check_done; - } - - if (aPath.IsString()) { + } else if (aPath.IsString()) { if (!DOMPathToRealPath(aPath.GetAsString(), realPath)) { error = NS_ERROR_DOM_FILESYSTEM_INVALID_PATH_ERR; } - goto parameters_check_done; - } - - if (!mFileSystem->IsSafeDirectory(&aPath.GetAsDirectory())) { + } else if (!mFileSystem->IsSafeDirectory(&aPath.GetAsDirectory())) { error = NS_ERROR_DOM_SECURITY_ERR; - goto parameters_check_done; + } else { + realPath = aPath.GetAsDirectory().mPath; + // The target must be a descendant of this directory. + if (!FileSystemUtils::IsDescendantPath(mPath, realPath)) { + error = NS_ERROR_DOM_FILESYSTEM_NO_MODIFICATION_ALLOWED_ERR; + } } - realPath = aPath.GetAsDirectory().mPath; - // The target must be a descendant of this directory. - if (!FileSystemUtils::IsDescendantPath(mPath, realPath)) { - error = NS_ERROR_DOM_FILESYSTEM_NO_MODIFICATION_ALLOWED_ERR; - } - -parameters_check_done: - nsRefPtr task = new RemoveTask(mFileSystem, mPath, file, realPath, aRecursive, aRv); if (aRv.Failed()) {