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

Side by Side Diff: base/file_util_posix.cc

Issue 17019: Try to consistently use arraysize() with strlcpy(). (Closed)
Patch Set: Created 11 years, 11 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 | « no previous file | net/disk_cache/backend_unittest.cc » ('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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-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_util.h" 5 #include "base/file_util.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <fnmatch.h> 9 #include <fnmatch.h>
10 #include <fts.h> 10 #include <fts.h>
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 return FilePath(); 453 return FilePath();
454 454
455 // The last find FindFirstFile operation is done, prepare a new one. 455 // The last find FindFirstFile operation is done, prepare a new one.
456 root_path_ = pending_paths_.top(); 456 root_path_ = pending_paths_.top();
457 root_path_ = root_path_.StripTrailingSeparators(); 457 root_path_ = root_path_.StripTrailingSeparators();
458 pending_paths_.pop(); 458 pending_paths_.pop();
459 459
460 // Start a new find operation. 460 // Start a new find operation.
461 int ftsflags = FTS_LOGICAL; 461 int ftsflags = FTS_LOGICAL;
462 char top_dir[PATH_MAX]; 462 char top_dir[PATH_MAX];
463 base::strlcpy(top_dir, root_path_.value().c_str(), sizeof(top_dir)); 463 base::strlcpy(top_dir, root_path_.value().c_str(), arraysize(top_dir));
464 char* dir_list[2] = { top_dir, NULL }; 464 char* dir_list[2] = { top_dir, NULL };
465 fts_ = fts_open(dir_list, ftsflags, NULL); 465 fts_ = fts_open(dir_list, ftsflags, NULL);
466 if (!fts_) 466 if (!fts_)
467 return Next(); 467 return Next();
468 is_in_find_op_ = true; 468 is_in_find_op_ = true;
469 } 469 }
470 470
471 fts_ent_ = fts_read(fts_); 471 fts_ent_ = fts_read(fts_);
472 if (fts_ent_ == NULL) { 472 if (fts_ent_ == NULL) {
473 fts_close(fts_); 473 fts_close(fts_);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 munmap(data_, length_); 534 munmap(data_, length_);
535 if (file_ != -1) 535 if (file_ != -1)
536 close(file_); 536 close(file_);
537 537
538 data_ = NULL; 538 data_ = NULL;
539 length_ = 0; 539 length_ = 0;
540 file_ = -1; 540 file_ = -1;
541 } 541 }
542 542
543 } // namespace file_util 543 } // namespace file_util
OLDNEW
« no previous file with comments | « no previous file | net/disk_cache/backend_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698