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

Side by Side Diff: src/wasm/module-decoder.cc

Issue 2806313002: Ignore result from fwrite (Closed)
Patch Set: Print message on error Created 3 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 | « 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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project 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 "src/wasm/module-decoder.h" 5 #include "src/wasm/module-decoder.h"
6 #include "src/wasm/function-body-decoder-impl.h" 6 #include "src/wasm/function-body-decoder-impl.h"
7 7
8 #include "src/base/functional.h" 8 #include "src/base/functional.h"
9 #include "src/base/platform/platform.h" 9 #include "src/base/platform/platform.h"
10 #include "src/counters.h" 10 #include "src/counters.h"
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 // File are named `HASH.{ok,failed}.wasm`. 238 // File are named `HASH.{ok,failed}.wasm`.
239 size_t hash = base::hash_range(start_, end_); 239 size_t hash = base::hash_range(start_, end_);
240 char buf[32] = {'\0'}; 240 char buf[32] = {'\0'};
241 #if V8_OS_WIN && _MSC_VER < 1900 241 #if V8_OS_WIN && _MSC_VER < 1900
242 #define snprintf sprintf_s 242 #define snprintf sprintf_s
243 #endif 243 #endif
244 snprintf(buf, sizeof(buf) - 1, "%016zx.%s.wasm", hash, 244 snprintf(buf, sizeof(buf) - 1, "%016zx.%s.wasm", hash,
245 result.ok() ? "ok" : "failed"); 245 result.ok() ? "ok" : "failed");
246 std::string name(buf); 246 std::string name(buf);
247 if (FILE* wasm_file = base::OS::FOpen((path + name).c_str(), "wb")) { 247 if (FILE* wasm_file = base::OS::FOpen((path + name).c_str(), "wb")) {
248 fwrite(start_, end_ - start_, 1, wasm_file); 248 if (fwrite(start_, end_ - start_, 1, wasm_file) != 1) {
249 OFStream os(stderr);
250 os << "Error while dumping wasm file" << std::endl;
251 }
249 fclose(wasm_file); 252 fclose(wasm_file);
250 } 253 }
251 } 254 }
252 255
253 // Decodes an entire module. 256 // Decodes an entire module.
254 ModuleResult DecodeModule(bool verify_functions = true) { 257 ModuleResult DecodeModule(bool verify_functions = true) {
255 pc_ = start_; 258 pc_ = start_;
256 WasmModule* module = new WasmModule(module_zone); 259 WasmModule* module = new WasmModule(module_zone);
257 module->min_mem_pages = 0; 260 module->min_mem_pages = 0;
258 module->max_mem_pages = 0; 261 module->max_mem_pages = 0;
(...skipping 1041 matching lines...) Expand 10 before | Expand all | Expand 10 after
1300 result.push_back({section_start, name_offset, name_length, payload_offset, 1303 result.push_back({section_start, name_offset, name_length, payload_offset,
1301 payload_length, section_length}); 1304 payload_length, section_length});
1302 } 1305 }
1303 1306
1304 return result; 1307 return result;
1305 } 1308 }
1306 1309
1307 } // namespace wasm 1310 } // namespace wasm
1308 } // namespace internal 1311 } // namespace internal
1309 } // namespace v8 1312 } // namespace v8
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