Hi Padraig,

What is the exact error message you get?

Are you compiling on a 64-bit machine?

I believe I have the following (simplyfied) code:

off_t a;
size_t b;
off_t c;

if (a + (off_t) b > c)
  c = a + (off_t) b;

And the line "if (a + (off_t) b > c)" is generating the warning.

Maybe you can confirm this, with this simple example.

On Nov 11, 2009, at 3:22 PM, Padraig O'Sullivan wrote:

On Wed, Nov 11, 2009 at 9:07 AM, Paul McCullagh
<[email protected]> wrote:
Hi Padraig,

On Nov 11, 2009, at 2:56 PM, Padraig O'Sullivan wrote:


Just one change I am not sure of:

datalog_xt.cc: line 1206

#ifdef DEBUG
if (dlb_buffer_offset + (xtLogOffset) dlb_buffer_len >
dlb_max_write_offset)
                      dlb_max_write_offset = dlb_buffer_offset +
(xtLogOffset) dlb_buffer_len;
#endif

-->

#ifdef DEBUG
              if (dlb_buffer_offset + dlb_buffer_len >
dlb_max_write_offset)
                      dlb_max_write_offset = dlb_buffer_offset +
(xtLogOffset) dlb_buffer_len;
#endif

This is a case of "off_t + size_t > off_t".

The size_t was cast to an off_t in case size_t is 4 bytes and off_t is 8.

So we want to make sure that the calculation is done using 8 byte values
in
this case.

Did you get a warning on this line? Maybe due to signed to unsigned
conversion?

Sorry, that's my bad. I meant to revert that change before commiting.
Yes, I had gotten a warning to do with comparison of signed and
unsigned integers in a few places in that file. I was going to try and fix those warnings but then decided it would be better to not do that
and just updated the compiler flags to include -Wno-sign-compare
instead.

Turning the warning off is a quick solution, but I would really like to know
how to write this code so that all compilers are happy!

I have no problem with changing the code, but I don't want to change it,
just to run into a warning on some other system.

Ah, ok. I didn't change anything as I wasn't sure if things were done
like that for a certain reason or not. The warning pops up in quite a
few places in that file for me when I compile with debug symbols.


In particular, I am wondering why the compiler is generating a warning in
this case where we have an explicit conversion?

I'm not sure either and would be interested in learning if someone
could provide an answer.


Any ideas?






--
Paul McCullagh
PrimeBase Technologies
www.primebase.org
www.blobstreaming.org
pbxt.blogspot.com







--
Paul McCullagh
PrimeBase Technologies
www.primebase.org
www.blobstreaming.org
pbxt.blogspot.com




_______________________________________________
Mailing list: https://launchpad.net/~drizzle-discuss
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~drizzle-discuss
More help   : https://help.launchpad.net/ListHelp

Reply via email to