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

Side by Side Diff: base/rand_util_posix.cc

Issue 10767: RandUInt -> RandUint to match the style of other Uint functions. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years, 1 month 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 | « base/rand_util.cc ('k') | base/rand_util_win.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) 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/rand_util.h" 5 #include "base/rand_util.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <sys/stat.h> 8 #include <sys/stat.h>
9 #include <unistd.h> 9 #include <unistd.h>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 12
13 namespace base { 13 namespace base {
14 14
15 uint64 RandUInt64() { 15 uint64 RandUint64() {
16 uint64 number; 16 uint64 number;
17 17
18 int urandom_fd = open("/dev/urandom", O_RDONLY); 18 int urandom_fd = open("/dev/urandom", O_RDONLY);
19 CHECK(urandom_fd >= 0); 19 CHECK(urandom_fd >= 0);
20 ssize_t bytes_read = read(urandom_fd, &number, sizeof(number)); 20 ssize_t bytes_read = read(urandom_fd, &number, sizeof(number));
21 CHECK(bytes_read == sizeof(number)); 21 CHECK(bytes_read == sizeof(number));
22 close(urandom_fd); 22 close(urandom_fd);
23 23
24 return number; 24 return number;
25 } 25 }
26 26
27 } // namespace base 27 } // namespace base
OLDNEW
« no previous file with comments | « base/rand_util.cc ('k') | base/rand_util_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698