Changeset 8e3498b in mainline for uspace/app/tester/vfs/vfs1.c


Ignore:
Timestamp:
2017-12-04T18:44:24Z (7 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bde5c04
Parents:
40feeac
Message:

vfs_read/write() should return error code separately from number of bytes transferred.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/tester/vfs/vfs1.c

    r40feeac r8e3498b  
    8484       
    8585        size_t size = sizeof(text);
    86         ssize_t cnt = vfs_write(fd0, &pos, text, size);
    87         if (cnt < 0)
     86        size_t cnt;
     87        rc  = vfs_write(fd0, &pos, text, size, &cnt);
     88        if (rc != EOK)
    8889                return "write() failed";
    8990        TPRINTF("Written %zd bytes\n", cnt);
     
    9394        char buf[BUF_SIZE];
    9495        TPRINTF("read..\n");
    95         while ((cnt = vfs_read(fd0, &pos, buf, BUF_SIZE))) {
    96                 TPRINTF("read returns %zd\n", cnt);
    97                 if (cnt < 0)
     96        while ((rc = vfs_read(fd0, &pos, buf, BUF_SIZE, &cnt))) {
     97                TPRINTF("read returns rc = %d, cnt = %zu\n", rc, cnt);
     98                if (rc != EOK)
    9899                        return "read() failed";
    99100               
    100                 int _cnt = (int) cnt;
    101                 if (_cnt != cnt) {
     101                int icnt = (int) cnt;
     102                if ((size_t) icnt != cnt) {
    102103                        /* Count overflow, just to be sure. */
    103104                        TPRINTF("Read %zd bytes\n", cnt);
    104105                } else {
    105                         TPRINTF("Read %zd bytes: \"%.*s\"\n", cnt, _cnt, buf);
     106                        TPRINTF("Read %zd bytes: \"%.*s\"\n", cnt, icnt, buf);
    106107                }
    107108        }
Note: See TracChangeset for help on using the changeset viewer.