Changeset 132ab5d1 in mainline for uspace/app/tester/vfs/vfs1.c


Ignore:
Timestamp:
2018-01-30T03:20:45Z (8 years ago)
Author:
Jenda <jenda.jzqk73@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5a6cc679
Parents:
8bfb163 (diff), 6a5d05b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge commit '6a5d05bd2551e64111bea4f9332dd7448c26ce84' into forwardport

Separate return value from error code in gen_irq_code*().

File:
1 edited

Legend:

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

    r8bfb163 r132ab5d1  
    3131#include <stdlib.h>
    3232#include <stddef.h>
     33#include <str_error.h>
    3334#include <str.h>
    3435#include <vfs/vfs.h>
     
    7273        rc = vfs_link_path(TEST_DIRECTORY, KIND_DIRECTORY, NULL);
    7374        if (rc != EOK) {
    74                 TPRINTF("rc=%d\n", rc);
     75                TPRINTF("rc=%s\n", str_error_name(rc));
    7576                return "vfs_link_path() failed";
    7677        }
    7778        TPRINTF("Created directory %s\n", TEST_DIRECTORY);
    7879       
    79         int fd0 = vfs_lookup_open(TEST_FILE, WALK_REGULAR | WALK_MAY_CREATE,
    80             MODE_READ | MODE_WRITE);
    81         if (fd0 < 0)
     80        int fd0;
     81        rc = vfs_lookup_open(TEST_FILE, WALK_REGULAR | WALK_MAY_CREATE,
     82            MODE_READ | MODE_WRITE, &fd0);
     83        if (rc != EOK)
    8284                return "vfs_lookup_open() failed";
    8385        TPRINTF("Created file %s (fd=%d)\n", TEST_FILE, fd0);
    8486       
    8587        size_t size = sizeof(text);
    86         ssize_t cnt = vfs_write(fd0, &pos, text, size);
    87         if (cnt < 0)
     88        size_t cnt;
     89        rc  = vfs_write(fd0, &pos, text, size, &cnt);
     90        if (rc != EOK)
    8891                return "write() failed";
    8992        TPRINTF("Written %zd bytes\n", cnt);
     
    9396        char buf[BUF_SIZE];
    9497        TPRINTF("read..\n");
    95         while ((cnt = vfs_read(fd0, &pos, buf, BUF_SIZE))) {
    96                 TPRINTF("read returns %zd\n", cnt);
    97                 if (cnt < 0)
     98        while ((rc = vfs_read(fd0, &pos, buf, BUF_SIZE, &cnt))) {
     99                TPRINTF("read returns rc = %s, cnt = %zu\n", str_error_name(rc), cnt);
     100                if (rc != EOK)
    98101                        return "read() failed";
    99102               
    100                 int _cnt = (int) cnt;
    101                 if (_cnt != cnt) {
     103                int icnt = (int) cnt;
     104                if ((size_t) icnt != cnt) {
    102105                        /* Count overflow, just to be sure. */
    103106                        TPRINTF("Read %zd bytes\n", cnt);
    104107                } else {
    105                         TPRINTF("Read %zd bytes: \"%.*s\"\n", cnt, _cnt, buf);
     108                        TPRINTF("Read %zd bytes: \"%.*s\"\n", cnt, icnt, buf);
    106109                }
    107110        }
Note: See TracChangeset for help on using the changeset viewer.