Skip to content

Commit 002e64b

Browse files
committed
Shorten user program
1 parent 8011eb0 commit 002e64b

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

client.c

+5-8
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,24 @@
99

1010
int main()
1111
{
12-
int fd;
1312
long long sz;
1413

1514
char buf[1];
1615
char write_buf[] = "testing writing";
17-
int offset = 100; // TODO: test something bigger than the limit
18-
int i = 0;
19-
20-
fd = open(FIB_DEV, O_RDWR);
16+
int offset = 100; /* TODO: try test something bigger than the limit */
2117

18+
int fd = open(FIB_DEV, O_RDWR);
2219
if (fd < 0) {
2320
perror("Failed to open character device");
2421
exit(1);
2522
}
2623

27-
for (i = 0; i <= offset; i++) {
24+
for (int i = 0; i <= offset; i++) {
2825
sz = write(fd, write_buf, strlen(write_buf));
2926
printf("Writing to " FIB_DEV ", returned the sequence %lld\n", sz);
3027
}
3128

32-
for (i = 0; i <= offset; i++) {
29+
for (int i = 0; i <= offset; i++) {
3330
lseek(fd, i, SEEK_SET);
3431
sz = read(fd, buf, 1);
3532
printf("Reading from " FIB_DEV
@@ -38,7 +35,7 @@ int main()
3835
i, sz);
3936
}
4037

41-
for (i = offset; i >= 0; i--) {
38+
for (int i = offset; i >= 0; i--) {
4239
lseek(fd, i, SEEK_SET);
4340
sz = read(fd, buf, 1);
4441
printf("Reading from " FIB_DEV

0 commit comments

Comments
 (0)