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

Side by Side Diff: tests/libc/memcpy_move_set.c

Issue 1148953002: Cast pointers used with %p format strings to void * (Closed) Base URL: https://chromium.googlesource.com/native_client/src/native_client.git@master
Patch Set: Created 5 years, 7 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2013 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 /* 7 /*
8 * Simple test to verify that memcpy, memmove and memset are found and 8 * Simple test to verify that memcpy, memmove and memset are found and
9 * work properly. 9 * work properly.
10 */ 10 */
(...skipping 26 matching lines...) Expand all
37 void reset_buf(void) { 37 void reset_buf(void) {
38 unsigned char *bufptr = (unsigned char *) buf; 38 unsigned char *bufptr = (unsigned char *) buf;
39 unsigned i; 39 unsigned i;
40 for (i = 0; i < total_buf_len; ++i) 40 for (i = 0; i < total_buf_len; ++i)
41 bufptr[i] = i; 41 bufptr[i] = i;
42 } 42 }
43 43
44 void dump_buf(void) { 44 void dump_buf(void) {
45 unsigned char *bufptr = (unsigned char *) buf; 45 unsigned char *bufptr = (unsigned char *) buf;
46 for (int i = 0; i < total_buf_len; ++i) 46 for (int i = 0; i < total_buf_len; ++i)
47 printf("buf[%u] (%p) = %u\n", i, &bufptr[i], bufptr[0]); 47 printf("buf[%u] (%p) = %u\n", i, (void *) &bufptr[i], bufptr[0]);
48 } 48 }
49 49
50 /* 50 /*
51 * Each function we're testing has a "checked" version that runs it and makes 51 * Each function we're testing has a "checked" version that runs it and makes
52 * sure the destination pointer is returned correctly. For memcpy, additionally 52 * sure the destination pointer is returned correctly. For memcpy, additionally
53 * check that the source and the destination match after the call. 53 * check that the source and the destination match after the call.
54 */ 54 */
55 void checked_memcpy(void *dst, void *src, unsigned n) { 55 void checked_memcpy(void *dst, void *src, unsigned n) {
56 assert((unsigned char *)dst + n < (unsigned char *)buf + total_buf_len); 56 assert((unsigned char *)dst + n < (unsigned char *)buf + total_buf_len);
57 void *ret = memcpy(dst, src, n); 57 void *ret = memcpy(dst, src, n);
(...skipping 20 matching lines...) Expand all
78 void checked_memset(void *s, int c, unsigned n) { 78 void checked_memset(void *s, int c, unsigned n) {
79 void *ret = memset(s, c, n); 79 void *ret = memset(s, c, n);
80 if (ret != s) { 80 if (ret != s) {
81 printf("Wrong memset return value: %p != %p\n", ret, s); 81 printf("Wrong memset return value: %p != %p\n", ret, s);
82 exit(1); 82 exit(1);
83 } 83 }
84 char *s_char = (char *)s; 84 char *s_char = (char *)s;
85 char *dst_char = s_char; 85 char *dst_char = s_char;
86 for (unsigned i = 0; i < n; ++i, ++dst_char) { 86 for (unsigned i = 0; i < n; ++i, ++dst_char) {
87 if (*dst_char != c) { 87 if (*dst_char != c) {
88 printf("memset failure: index %d (%p) = %u\n", i, dst_char, *dst_char); 88 printf("memset failure: index %d (%p) = %u\n",
89 i, (void *) dst_char, *dst_char);
89 dump_buf(); 90 dump_buf();
90 exit(1); 91 exit(1);
91 } 92 }
92 } 93 }
93 if (*dst_char == c) { 94 if (*dst_char == c) {
94 printf("memset failure: wrote %d past the end of buffer\n", c); 95 printf("memset failure: wrote %d past the end of buffer\n", c);
95 exit(1); 96 exit(1);
96 } 97 }
97 } 98 }
98 99
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 /* Test 204: memmove at edge */ 273 /* Test 204: memmove at edge */
273 reset_buf(); 274 reset_buf();
274 src = arrptr + 1; 275 src = arrptr + 1;
275 dst = arrptr; 276 dst = arrptr;
276 checked_memmove(dst, src, medium_length * 4 - 1); 277 checked_memmove(dst, src, medium_length * 4 - 1);
277 /* expect length-1 */ 278 /* expect length-1 */
278 printf("204: %u\n", (unsigned)dst[medium_length * 4 - 2]); 279 printf("204: %u\n", (unsigned)dst[medium_length * 4 - 2]);
279 280
280 return 0; 281 return 0;
281 } 282 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698