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

Unified Diff: native_client_sdk/src/examples/demo/nacl_io/handlers.c

Issue 14623012: [NaCl SDK] nacl_io example: Check ferror() after reading/writing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: native_client_sdk/src/examples/demo/nacl_io/handlers.c
diff --git a/native_client_sdk/src/examples/demo/nacl_io/handlers.c b/native_client_sdk/src/examples/demo/nacl_io/handlers.c
index 062a41fb341343b7a4a2034da55d0e86254c44aa..5c2a6ab85ef725e6301fb55d795e30136c2dc493 100644
--- a/native_client_sdk/src/examples/demo/nacl_io/handlers.c
+++ b/native_client_sdk/src/examples/demo/nacl_io/handlers.c
@@ -164,6 +164,12 @@ int HandleFwrite(int num_params, char** params, char** output) {
bytes_written = fwrite(data, 1, data_len, file);
+ if (ferror(file)) {
+ *output = PrintfToNewString(
+ "Error: Wrote %d bytes, but ferror() returns true.", bytes_written);
+ return 3;
+ }
+
*output = PrintfToNewString("fwrite\1%s\1%d", file_index_string,
bytes_written);
return 0;
@@ -211,6 +217,12 @@ int HandleFread(int num_params, char** params, char** output) {
bytes_read = fread(buffer, 1, data_len, file);
buffer[bytes_read] = 0;
+ if (ferror(file)) {
+ *output = PrintfToNewString(
+ "Error: Read %d bytes, but ferror() returns true.", bytes_read);
+ return 3;
+ }
+
*output = PrintfToNewString("fread\1%s\1%s", file_index_string, buffer);
free(buffer);
return 0;
« 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