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

Side by Side Diff: base/file_path.cc

Issue 155022: Fix few trivial Coverity issues, mainly PASS_BY_VALUE. (Closed)
Patch Set: Created 11 years, 5 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 unified diff | Download patch
« no previous file with comments | « base/directory_watcher_unittest.cc ('k') | base/simple_thread.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/file_path.h" 5 #include "base/file_path.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 7
8 // These includes are just for the *Hack functions, and should be removed 8 // These includes are just for the *Hack functions, and should be removed
9 // when those functions are removed. 9 // when those functions are removed.
10 #include "base/string_piece.h" 10 #include "base/string_piece.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 } 76 }
77 // Look for a pair of leading separators. 77 // Look for a pair of leading separators.
78 return path.length() > 1 && 78 return path.length() > 1 &&
79 FilePath::IsSeparator(path[0]) && FilePath::IsSeparator(path[1]); 79 FilePath::IsSeparator(path[0]) && FilePath::IsSeparator(path[1]);
80 #else // FILE_PATH_USES_DRIVE_LETTERS 80 #else // FILE_PATH_USES_DRIVE_LETTERS
81 // Look for a separator in the first position. 81 // Look for a separator in the first position.
82 return path.length() > 0 && FilePath::IsSeparator(path[0]); 82 return path.length() > 0 && FilePath::IsSeparator(path[0]);
83 #endif // FILE_PATH_USES_DRIVE_LETTERS 83 #endif // FILE_PATH_USES_DRIVE_LETTERS
84 } 84 }
85 85
86 bool AreAllSeparators(FilePath::StringType input) { 86 bool AreAllSeparators(const FilePath::StringType& input) {
87 for (FilePath::StringType::const_iterator it = input.begin(); 87 for (FilePath::StringType::const_iterator it = input.begin();
88 it != input.end(); ++it) { 88 it != input.end(); ++it) {
89 if (!FilePath::IsSeparator(*it)) 89 if (!FilePath::IsSeparator(*it))
90 return false; 90 return false;
91 } 91 }
92 92
93 return true; 93 return true;
94 } 94 }
95 95
96 } // namespace 96 } // namespace
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 --pos) { 445 --pos) {
446 // If the string only has two separators and they're at the beginning, 446 // If the string only has two separators and they're at the beginning,
447 // don't strip them, unless the string began with more than two separators. 447 // don't strip them, unless the string began with more than two separators.
448 if (pos != start + 1 || last_stripped == start + 2 || 448 if (pos != start + 1 || last_stripped == start + 2 ||
449 !IsSeparator(path_[start - 1])) { 449 !IsSeparator(path_[start - 1])) {
450 path_.resize(pos - 1); 450 path_.resize(pos - 1);
451 last_stripped = pos; 451 last_stripped = pos;
452 } 452 }
453 } 453 }
454 } 454 }
OLDNEW
« no previous file with comments | « base/directory_watcher_unittest.cc ('k') | base/simple_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698