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

Side by Side Diff: mojo/public/c/lib/bindings/message.c

Issue 2232833003: Change the canonical way to include the C bindings headers to <mojo/bindings/*.h>. (Closed) Base URL: https://github.com/domokit/mojo.git@work791_mojo_tests
Patch Set: rebased Created 4 years, 4 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 | « mojo/public/c/lib/bindings/map.c ('k') | mojo/public/c/lib/bindings/struct.c » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "mojo/public/c/bindings/message.h" 5 #include <mojo/bindings/message.h>
6 6
7 #include <mojo/bindings/struct.h>
7 #include <stdint.h> 8 #include <stdint.h>
8 9
9 #include "mojo/public/c/bindings/struct.h"
10
11 MojomValidationResult MojomMessage_ValidateHeader(const void* in_buf, 10 MojomValidationResult MojomMessage_ValidateHeader(const void* in_buf,
12 uint32_t in_buf_size) { 11 uint32_t in_buf_size) {
13 const struct MojomStructHeader* header = 12 const struct MojomStructHeader* header =
14 (const struct MojomStructHeader*)in_buf; 13 (const struct MojomStructHeader*)in_buf;
15 14
16 if (in_buf_size < sizeof(struct MojomStructHeader) || 15 if (in_buf_size < sizeof(struct MojomStructHeader) ||
17 in_buf_size < header->num_bytes) 16 in_buf_size < header->num_bytes)
18 return MOJOM_VALIDATION_ILLEGAL_MEMORY_RANGE; 17 return MOJOM_VALIDATION_ILLEGAL_MEMORY_RANGE;
19 18
20 const struct MojomMessage* msg = (const struct MojomMessage*)in_buf; 19 const struct MojomMessage* msg = (const struct MojomMessage*)in_buf;
21 if (header->version == 0u) { 20 if (header->version == 0u) {
22 if (header->num_bytes != sizeof(struct MojomMessage)) { 21 if (header->num_bytes != sizeof(struct MojomMessage)) {
23 return MOJOM_VALIDATION_UNEXPECTED_STRUCT_HEADER; 22 return MOJOM_VALIDATION_UNEXPECTED_STRUCT_HEADER;
24 } 23 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 : MOJOM_VALIDATION_MESSAGE_HEADER_INVALID_FLAGS; 64 : MOJOM_VALIDATION_MESSAGE_HEADER_INVALID_FLAGS;
66 } 65 }
67 66
68 MojomValidationResult MojomMessage_ValidateResponse( 67 MojomValidationResult MojomMessage_ValidateResponse(
69 const void* in_buf) { 68 const void* in_buf) {
70 const struct MojomMessage* msg = (const struct MojomMessage*)in_buf; 69 const struct MojomMessage* msg = (const struct MojomMessage*)in_buf;
71 return (msg->flags & MOJOM_MESSAGE_FLAGS_IS_RESPONSE) 70 return (msg->flags & MOJOM_MESSAGE_FLAGS_IS_RESPONSE)
72 ? MOJOM_VALIDATION_ERROR_NONE 71 ? MOJOM_VALIDATION_ERROR_NONE
73 : MOJOM_VALIDATION_MESSAGE_HEADER_INVALID_FLAGS; 72 : MOJOM_VALIDATION_MESSAGE_HEADER_INVALID_FLAGS;
74 } 73 }
OLDNEW
« no previous file with comments | « mojo/public/c/lib/bindings/map.c ('k') | mojo/public/c/lib/bindings/struct.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698