diotest: modify the confusing that function not failed but the errno is still negative

some code logic in diotest4.c likes below:
----
    ret = lseek(fd, offset, SEEK_SET);
    if ((ret >= 0) || (errno != EINVAL)) {
        tst_resm(TFAIL, "lseek allows negative offset. returns %d:%s", ret, strerror(errno));
        failed = TRUE;
        fail_count++;
    } else
        tst_resm(TPASS, "Negative Offset");

    ....
    ....

    ret = read(fd, buf, count);
    if (ret >= 0 || errno != errnum) {
        tst_resm(TFAIL, "read allows %s. returns %d: %s", msg, ret, strerror(errno));
        l_fail = TRUE;
    }
----

After lseek() return EINVAL, if read() return >= 0, the errno will not be setted to 0. The
errno will still be EINVAL.
The test failure message of read will be confusing in case that read() haven't failed as
expected but the errno is still set.

I hit this problem when test on nfs. In NFS, lseek() return EINVAL as excepted,
but the read() will return 1, when count = 1. But the errno is still EINVAL.
That's incorrect.

So I set errno = 0, before read() and all other functions which like this.

Signed-off-by: Zorro Lang <zlang@redhat.com>
1 file changed