SCSI tape data loss

Justin T. Gibbs gibbs at scsiguy.com
Tue Jun 3 10:03:43 PDT 2003


> Yes, I probably should move the clrerror() and the
> check/set of errno inside the check for "stat == -1". 
> However, the code though odd is correct since 
> I do not use errno unless the status is -1.

No, the code is not correct.  clrerror() has side effects
in many cases when errno is non-zero.

> By the way, the funny casting is mandatory in C++,
> because ssize_t as returned by the write is not the 
> same as size_t (what is written).

Integer type conversions are still valid in C++:

#include <stdio.h>
#include <inttypes.h>

int
subroutine(uint8_t small_type)
{
        printf("small_type is %d\n", small_type);

        return (0);
}

int
main(int argc, char *argv[])
{
        uint8_t  foo;
        uint32_t bigger_foo;

        foo = 100;
        bigger_foo = argc;

        if (foo != bigger_foo) {
                printf("Foos differ\n");
        }

        subroutine(bigger_foo);

        return (0);
}

% g++ -Wall -pedantic foo.cc

Produces no output.

--
Justin



More information about the freebsd-scsi mailing list