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

Unified Diff: runtime/bin/dartutils.cc

Issue 139043003: - Address warnings about 64-bit to 32-bit conversions. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/dartutils.h ('k') | runtime/bin/eventhandler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/dartutils.cc
===================================================================
--- runtime/bin/dartutils.cc (revision 31864)
+++ runtime/bin/dartutils.cc (working copy)
@@ -127,7 +127,7 @@
void DartUtils::SetIntegerField(Dart_Handle handle,
const char* name,
- intptr_t val) {
+ int64_t val) {
Dart_Handle result = Dart_SetField(handle,
NewString(name),
Dart_NewInteger(val));
@@ -135,15 +135,6 @@
}
-intptr_t DartUtils::GetIntegerField(Dart_Handle handle,
- const char* name) {
- Dart_Handle result = Dart_GetField(handle, NewString(name));
- if (Dart_IsError(result)) Dart_PropagateError(result);
- intptr_t value = DartUtils::GetIntegerValue(result);
- return value;
-}
-
-
void DartUtils::SetStringField(Dart_Handle handle,
const char* name,
const char* val) {
@@ -224,19 +215,24 @@
void DartUtils::ReadFile(const uint8_t** data,
- intptr_t* file_len,
+ intptr_t* len,
void* stream) {
ASSERT(data != NULL);
- ASSERT(file_len != NULL);
+ ASSERT(len != NULL);
ASSERT(stream != NULL);
File* file_stream = reinterpret_cast<File*>(stream);
- *file_len = file_stream->Length();
- ASSERT(*file_len > 0);
- uint8_t* text_buffer = reinterpret_cast<uint8_t*>(malloc(*file_len));
+ int64_t file_len = file_stream->Length();
+ if ((file_len < 0) || (file_len > kIntptrMax)) {
+ *data = NULL;
+ *len = -1; // Indicates read was not successful.
+ return;
+ }
+ *len = static_cast<intptr_t>(file_len);
+ uint8_t* text_buffer = reinterpret_cast<uint8_t*>(malloc(*len));
ASSERT(text_buffer != NULL);
- if (!file_stream->ReadFully(text_buffer, *file_len)) {
+ if (!file_stream->ReadFully(text_buffer, *len)) {
*data = NULL;
- *file_len = -1; // Indicates read was not successful.
+ *len = -1; // Indicates read was not successful.
return;
}
*data = text_buffer;
@@ -300,7 +296,7 @@
if (Dart_IsError(result)) {
return result;
}
- intptr_t responseCode = DartUtils::GetIntegerValue(result);
+ int64_t responseCode = DartUtils::GetIntegerValue(result);
if (responseCode != HttpResponseCodeOK) {
// Return error.
Dart_Handle responseStatus =
@@ -1035,10 +1031,10 @@
// Make sure that we do not have an integer overflow here. Actual check
// against max elements will be done at the time of writing, as the constant
// is not part of the public API.
- if (length > kIntptrMax) {
+ if ((length < 0) || (length > kIntptrMax)) {
return NULL;
}
- uint8_t* data = IOBuffer::Allocate(length);
+ uint8_t* data = IOBuffer::Allocate(static_cast<intptr_t>(length));
ASSERT(data != NULL);
return NewExternalUint8Array(
static_cast<intptr_t>(length), data, data, IOBuffer::Finalizer);
« no previous file with comments | « runtime/bin/dartutils.h ('k') | runtime/bin/eventhandler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698