Dear Mark: You are right. Thank you. It really works. I will try to set -Werror option to see if all reported warning. can be fixed.
On 9/20/06, Mark Hindess <[EMAIL PROTECTED]> wrote:
On 20 September 2006 at 10:06, Mark Hindess <[EMAIL PROTECTED] > wrote: > > On 20 September 2006 at 10:03, "Leo Li" <[EMAIL PROTECTED]> 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: > > JNIEXPORT jlong JNICALL > > Java_org_apache_harmony_luni_platform_OSFileSystem_readDirectImpl > > (JNIEnv * env, jobject thiz, jlong fd, jlong buf, jint offset, jint > > nbytes) > > { > > PORT_ACCESS_FROM_ENV (env); > > 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. Oops. I meant "isn't going to". -Mark. > > 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.) > > Regards, > Mark. > > > > --------------------------------------------------------------------- > Terms of use : http://incubator.apache.org/harmony/mailing.html > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- Terms of use : http://incubator.apache.org/harmony/mailing.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- Leo Li China Software Development Lab, IBM