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

Side by Side Diff: base/platform_file_posix.cc

Issue 7222010: Coverity fixes CID=15870,13529 Check pointer before assign, resource leak. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Revert to pre-79058 state Created 9 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | base/shared_memory_posix.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/platform_file.h" 5 #include "base/platform_file.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10 #include <unistd.h> 10 #include <unistd.h>
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 if (flags & PLATFORM_FILE_OPEN_TRUNCATED) { 48 if (flags & PLATFORM_FILE_OPEN_TRUNCATED) {
49 DCHECK(!open_flags); 49 DCHECK(!open_flags);
50 DCHECK(flags & PLATFORM_FILE_WRITE); 50 DCHECK(flags & PLATFORM_FILE_WRITE);
51 open_flags = O_TRUNC; 51 open_flags = O_TRUNC;
52 } 52 }
53 53
54 if (!open_flags && !(flags & PLATFORM_FILE_OPEN) && 54 if (!open_flags && !(flags & PLATFORM_FILE_OPEN) &&
55 !(flags & PLATFORM_FILE_OPEN_ALWAYS)) { 55 !(flags & PLATFORM_FILE_OPEN_ALWAYS)) {
56 NOTREACHED(); 56 NOTREACHED();
57 errno = EOPNOTSUPP; 57 errno = EOPNOTSUPP;
58 *error_code = error_code ? PLATFORM_FILE_ERROR_FAILED : PLATFORM_FILE_OK; 58 if (error_code)
59 *error_code = PLATFORM_FILE_ERROR_FAILED;
59 return kInvalidPlatformFileValue; 60 return kInvalidPlatformFileValue;
60 } 61 }
61 62
62 if (flags & PLATFORM_FILE_WRITE && flags & PLATFORM_FILE_READ) { 63 if (flags & PLATFORM_FILE_WRITE && flags & PLATFORM_FILE_READ) {
63 open_flags |= O_RDWR; 64 open_flags |= O_RDWR;
64 } else if (flags & PLATFORM_FILE_WRITE) { 65 } else if (flags & PLATFORM_FILE_WRITE) {
65 open_flags |= O_WRONLY; 66 open_flags |= O_WRONLY;
66 } else if (!(flags & PLATFORM_FILE_READ) && 67 } else if (!(flags & PLATFORM_FILE_READ) &&
67 !(flags & PLATFORM_FILE_WRITE_ATTRIBUTES) && 68 !(flags & PLATFORM_FILE_WRITE_ATTRIBUTES) &&
68 !(flags & PLATFORM_FILE_OPEN_ALWAYS)) { 69 !(flags & PLATFORM_FILE_OPEN_ALWAYS)) {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 info->is_directory = S_ISDIR(file_info.st_mode); 187 info->is_directory = S_ISDIR(file_info.st_mode);
187 info->is_symbolic_link = S_ISLNK(file_info.st_mode); 188 info->is_symbolic_link = S_ISLNK(file_info.st_mode);
188 info->size = file_info.st_size; 189 info->size = file_info.st_size;
189 info->last_modified = base::Time::FromTimeT(file_info.st_mtime); 190 info->last_modified = base::Time::FromTimeT(file_info.st_mtime);
190 info->last_accessed = base::Time::FromTimeT(file_info.st_atime); 191 info->last_accessed = base::Time::FromTimeT(file_info.st_atime);
191 info->creation_time = base::Time::FromTimeT(file_info.st_ctime); 192 info->creation_time = base::Time::FromTimeT(file_info.st_ctime);
192 return true; 193 return true;
193 } 194 }
194 195
195 } // namespace base 196 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/shared_memory_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698