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

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

Issue 2205963002: C bindings: Fix signed comparsion. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: oops 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 | « no previous file | no next file » | 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/lib/type_descriptor.h" 5 #include "mojo/public/c/bindings/lib/type_descriptor.h"
6 6
7 #include <assert.h> 7 #include <assert.h>
8 #include <stddef.h>
8 9
9 #include "mojo/public/c/bindings/array.h" 10 #include "mojo/public/c/bindings/array.h"
10 #include "mojo/public/c/bindings/interface.h" 11 #include "mojo/public/c/bindings/interface.h"
11 #include "mojo/public/c/bindings/lib/util.h" 12 #include "mojo/public/c/bindings/lib/util.h"
12 #include "mojo/public/c/bindings/map.h" 13 #include "mojo/public/c/bindings/map.h"
13 #include "mojo/public/c/bindings/struct.h" 14 #include "mojo/public/c/bindings/struct.h"
14 #include "mojo/public/c/bindings/union.h" 15 #include "mojo/public/c/bindings/union.h"
15 16
16 const struct MojomTypeDescriptorArray g_mojom_string_type_description = { 17 const struct MojomTypeDescriptorArray g_mojom_string_type_description = {
17 MOJOM_TYPE_DESCRIPTOR_TYPE_POD, // elem_type 18 MOJOM_TYPE_DESCRIPTOR_TYPE_POD, // elem_type
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 break; 79 break;
79 } 80 }
80 return size; 81 return size;
81 } 82 }
82 83
83 static void encode_pointer(union MojomPointer* pointer, uint32_t max_offset) { 84 static void encode_pointer(union MojomPointer* pointer, uint32_t max_offset) {
84 if (pointer->ptr == NULL) { 85 if (pointer->ptr == NULL) {
85 pointer->offset = 0; 86 pointer->offset = 0;
86 } else { 87 } else {
87 assert((char*)pointer->ptr > (char*)pointer); 88 assert((char*)pointer->ptr > (char*)pointer);
88 assert((char*)pointer->ptr - (char*)pointer < max_offset); 89 assert((char*)pointer->ptr - (char*)pointer < (ptrdiff_t)max_offset);
viettrungluu 2016/08/02 20:10:29 Hmmm. So if ptrdiff_t is 32-bit, and max_offset is
vardhan 2016/08/02 20:28:30 Done.
89 pointer->offset = (char*)(pointer->ptr) - (char*)pointer; 90 pointer->offset = (char*)(pointer->ptr) - (char*)pointer;
90 } 91 }
91 } 92 }
92 93
93 static void decode_pointer(union MojomPointer* pointer) { 94 static void decode_pointer(union MojomPointer* pointer) {
94 if (pointer->offset == 0) { 95 if (pointer->offset == 0) {
95 pointer->ptr = NULL; 96 pointer->ptr = NULL;
96 } else { 97 } else {
97 pointer->ptr = (char*)pointer + pointer->offset; 98 pointer->ptr = (char*)pointer + pointer->offset;
98 } 99 }
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 return validate_handle(*(const MojoHandle*)in_buf, in_num_handles, 393 return validate_handle(*(const MojoHandle*)in_buf, in_num_handles,
393 in_nullable, inout_context); 394 in_nullable, inout_context);
394 case MOJOM_TYPE_DESCRIPTOR_TYPE_INTERFACE: 395 case MOJOM_TYPE_DESCRIPTOR_TYPE_INTERFACE:
395 return validate_handle(((const struct MojomInterfaceData*)in_buf)->handle, 396 return validate_handle(((const struct MojomInterfaceData*)in_buf)->handle,
396 in_num_handles, in_nullable, inout_context); 397 in_num_handles, in_nullable, inout_context);
397 case MOJOM_TYPE_DESCRIPTOR_TYPE_POD: 398 case MOJOM_TYPE_DESCRIPTOR_TYPE_POD:
398 break; 399 break;
399 } 400 }
400 return MOJOM_VALIDATION_ERROR_NONE; 401 return MOJOM_VALIDATION_ERROR_NONE;
401 } 402 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698