Get rid of unnecessary barrier. Improve comment.
[pintos-anon] / grading / userprog / read-normal.c
1 #include <stdio.h>
2 #include <string.h>
3 #include <syscall.h>
4 #include "sample.inc"
5
6 char actual[sizeof sample];
7
8 int
9 main (void) 
10 {
11   int handle, byte_cnt;
12   printf ("(read-normal) begin\n");
13
14   handle = open ("sample.txt");
15   if (handle < 2)
16     printf ("(read-normal) fail: open() returned %d\n", handle);
17
18   byte_cnt = read (handle, actual, sizeof actual - 1);
19   if (byte_cnt != sizeof actual - 1)
20     printf ("(read-normal) fail: read() returned %d instead of %zu\n",
21             byte_cnt, sizeof actual - 1);
22   else if (strcmp (sample, actual))
23     printf ("(read-normal) fail: expected text differs from actual:\n%s",
24             actual);
25   
26   printf ("(read-normal) end\n");
27   return 0;
28 }