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

Side by Side Diff: samples/process.cc

Issue 1111733002: [clang] Use -Wshorten-64-to-32 to enable warnings about 64bit to 32bit truncations. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix Win warnings. 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
« no previous file with comments | « build/standalone.gypi ('k') | samples/shell.cc » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 } 588 }
589 } 589 }
590 590
591 591
592 // Reads a file into a v8 string. 592 // Reads a file into a v8 string.
593 Handle<String> ReadFile(Isolate* isolate, const string& name) { 593 Handle<String> ReadFile(Isolate* isolate, const string& name) {
594 FILE* file = fopen(name.c_str(), "rb"); 594 FILE* file = fopen(name.c_str(), "rb");
595 if (file == NULL) return Handle<String>(); 595 if (file == NULL) return Handle<String>();
596 596
597 fseek(file, 0, SEEK_END); 597 fseek(file, 0, SEEK_END);
598 int size = ftell(file); 598 size_t size = ftell(file);
599 rewind(file); 599 rewind(file);
600 600
601 char* chars = new char[size + 1]; 601 char* chars = new char[size + 1];
602 chars[size] = '\0'; 602 chars[size] = '\0';
603 for (int i = 0; i < size;) { 603 for (size_t i = 0; i < size;) {
604 int read = static_cast<int>(fread(&chars[i], 1, size - i, file)); 604 i += fread(&chars[i], 1, size - i, file);
605 i += read; 605 if (ferror(file)) {
606 fclose(file);
607 return Handle<String>();
608 }
606 } 609 }
607 fclose(file); 610 fclose(file);
608 Handle<String> result = 611 Handle<String> result = String::NewFromUtf8(
609 String::NewFromUtf8(isolate, chars, String::kNormalString, size); 612 isolate, chars, String::kNormalString, static_cast<int>(size));
610 delete[] chars; 613 delete[] chars;
611 return result; 614 return result;
612 } 615 }
613 616
614 617
615 const int kSampleSize = 6; 618 const int kSampleSize = 6;
616 StringHttpRequest kSampleRequests[kSampleSize] = { 619 StringHttpRequest kSampleRequests[kSampleSize] = {
617 StringHttpRequest("/process.cc", "localhost", "google.com", "firefox"), 620 StringHttpRequest("/process.cc", "localhost", "google.com", "firefox"),
618 StringHttpRequest("/", "localhost", "google.net", "firefox"), 621 StringHttpRequest("/", "localhost", "google.net", "firefox"),
619 StringHttpRequest("/", "localhost", "google.org", "safari"), 622 StringHttpRequest("/", "localhost", "google.org", "safari"),
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 JsHttpRequestProcessor processor(isolate, source); 667 JsHttpRequestProcessor processor(isolate, source);
665 map<string, string> output; 668 map<string, string> output;
666 if (!processor.Initialize(&options, &output)) { 669 if (!processor.Initialize(&options, &output)) {
667 fprintf(stderr, "Error initializing processor.\n"); 670 fprintf(stderr, "Error initializing processor.\n");
668 return 1; 671 return 1;
669 } 672 }
670 if (!ProcessEntries(&processor, kSampleSize, kSampleRequests)) 673 if (!ProcessEntries(&processor, kSampleSize, kSampleRequests))
671 return 1; 674 return 1;
672 PrintMap(&output); 675 PrintMap(&output);
673 } 676 }
OLDNEW
« no previous file with comments | « build/standalone.gypi ('k') | samples/shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698