Skip site navigation (1)Skip section navigation (2)
Date:      03 Jun 2003 19:19:24 +0200
From:      Kern Sibbald <kern@sibbald.com>
To:        "Justin T. Gibbs" <gibbs@scsiguy.com>
Cc:        mjacob@feral.com
Subject:   Re: SCSI tape data loss
Message-ID:  <1054660763.13630.279.camel@rufus>
In-Reply-To: <900070000.1054659860@aslan.btc.adaptec.com>
References:  <3EDB31AB.16420.C8964B7D@localhost> <3EDB59A4.27599.C93270FB@localhost> <20030602110836.H71034@beppo> <20030602131225.F71034@beppo> <1054645616.13630.161.camel@rufus>  <20030603072944.U44880@beppo> <1054652678.13630.209.camel@rufus> <882210000.1054657530@aslan.btc.adaptec.com> <1054658432.13630.252.camel@rufus> <900070000.1054659860@aslan.btc.adaptec.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 2003-06-03 at 19:04, Justin T. Gibbs wrote:
> > 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.

Yes, you are right. I'll fix it. However, this is not
the problem because the only side effect that can
occur is that Bacula would abort. The -1 second argument
guarantees that.

> 
> > 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).

If I remove the (uint32_t) cast, I get an error message:

c++   -c   -I. -I..  -g -O2 -Wall  block.c
block.c: In function `int write_block_to_dev (JCR *, DEVICE *, 
DEV_BLOCK *)':
block.c:381: warning: comparison between signed and unsigned integer 
expressions

Line 381 reads:

   if ((stat=write(dev->fd, block->buf, (size_t)wlen)) != wlen) {

so I will stick with my funny casting.



> 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1054660763.13630.279.camel>