harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Hindess <mark.hind...@googlemail.com>
Subject Re: [classlib][build] failure?
Date Wed, 20 Sep 2006 09:06:21 GMT

On 20 September 2006 at 10:03, "Leo Li" <liyilei1979@gmail.com> wrote:
> Hi, all:
> Since I am not an expert of gcc, I think we need a guru to set the flags in
> makefile of linux:
> 1. It will report any required warnings and regard it as error to lead a
> failure build so that it is forced for us to correct it.
> 2. It can avoid to stop building due to such warnings:
> In OSFileSystem.c, we have:
> Java_org_apache_harmony_luni_platform_OSFileSystem_readDirectImpl
>   (JNIEnv * env, jobject thiz, jlong fd, jlong buf, jint offset, jint
> nbytes)
> {
>   return (jlong) hyfile_read ((IDATA) fd, (void *) (buf+offset), (IDATA)
> nbytes);
> }
> Actually, the hyfile_read returns a int32 while the jlong is int64. I think
> the warning seems to be not avoidable.

I don't think that is the problem.  Casting from 32bit to 64bit is going
to lead to a loss of information.

> I have had tried some flags, but I have not got what I want.
> Any good suggestion?

The problem occurs because (buf+offset) is a 64bit value (since buf is
64bit) and void* is a 32bit value (on x86).  If we cast (buf+offset) to
a 32bit value before casting to (void*) the warning will be removed.

IDATA (and UDATA) are defined to be integers of the same size as 
pointers for a given platform so if them for the cast then the warning
can be avoided (and the code will still be correct on x86_64).

So something like:

  return (jlong) hyfile_read ((IDATA) fd,
                              (void *) ((IDATA)(buf+offset)),
                              (IDATA) nbytes);

(I've not tested this and each case should be looked at to see if the
cast is really valid.)


Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org

View raw message