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

Side by Side Diff: base/rand_util_fuchsia.cc

Issue 2941283002: fuchsia: Use new, qualified error names, disable old names. (Closed)
Patch Set: don have Created 3 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
« no previous file with comments | « base/process/process_util_unittest.cc ('k') | build/config/fuchsia/BUILD.gn » ('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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 <magenta/syscalls.h> 7 #include <magenta/syscalls.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 10 matching lines...) Expand all
21 void RandBytes(void* output, size_t output_length) { 21 void RandBytes(void* output, size_t output_length) {
22 size_t remaining = output_length; 22 size_t remaining = output_length;
23 unsigned char* cur = reinterpret_cast<unsigned char*>(output); 23 unsigned char* cur = reinterpret_cast<unsigned char*>(output);
24 do { 24 do {
25 // The syscall has a maximum number of bytes that can be read at once. 25 // The syscall has a maximum number of bytes that can be read at once.
26 size_t read_len = 26 size_t read_len =
27 std::min(remaining, static_cast<size_t>(MX_CPRNG_DRAW_MAX_LEN)); 27 std::min(remaining, static_cast<size_t>(MX_CPRNG_DRAW_MAX_LEN));
28 28
29 size_t actual; 29 size_t actual;
30 mx_status_t status = mx_cprng_draw(cur, read_len, &actual); 30 mx_status_t status = mx_cprng_draw(cur, read_len, &actual);
31 CHECK(status == NO_ERROR && read_len == actual); 31 CHECK(status == MX_OK && read_len == actual);
32 32
33 CHECK(remaining >= actual); 33 CHECK(remaining >= actual);
34 remaining -= actual; 34 remaining -= actual;
35 cur += actual; 35 cur += actual;
36 } while (remaining > 0); 36 } while (remaining > 0);
37 } 37 }
38 38
39 } // namespace base 39 } // namespace base
OLDNEW
« no previous file with comments | « base/process/process_util_unittest.cc ('k') | build/config/fuchsia/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698