diff --git a/jdk/src/macosx/bin/java_md_macosx.c b/jdk/src/macosx/bin/java_md_macosx.c index 6aa0eb588ae..b2179825b7c 100644 --- a/jdk/src/macosx/bin/java_md_macosx.c +++ b/jdk/src/macosx/bin/java_md_macosx.c @@ -881,7 +881,7 @@ ContinueInNewThread0(int (JNICALL *continuation)(void *), jlong stack_size, void if (pthread_create(&tid, &attr, (void *(*)(void*))continuation, (void*)args) == 0) { void * tmp; pthread_join(tid, &tmp); - rslt = (int)tmp; + rslt = (int)(intptr_t)tmp; } else { /* * Continue execution in current thread if for some reason (e.g. out of diff --git a/jdk/src/share/bin/java.c b/jdk/src/share/bin/java.c index d74b185deb6..a15a174aa06 100644 --- a/jdk/src/share/bin/java.c +++ b/jdk/src/share/bin/java.c @@ -729,7 +729,7 @@ SetJvmEnvironment(int argc, char **argv) { static int parse_size(const char *s, jlong *result) { jlong n = 0; - int args_read = sscanf(s, jlong_format_specifier(), &n); + int args_read = sscanf(s, JLONG_FORMAT_SPECIFIER, &n); if (args_read != 1) { return 0; } diff --git a/jdk/src/share/bin/java.h b/jdk/src/share/bin/java.h index 9dc0e16f6a0..ce609f56cf4 100644 --- a/jdk/src/share/bin/java.h +++ b/jdk/src/share/bin/java.h @@ -146,8 +146,6 @@ void JLI_ReportMessage(const char * message, ...); void JLI_ReportExceptionDescription(JNIEnv * env); void PrintMachineDependentOptions(); -const char *jlong_format_specifier(); - /* * Block current thread and continue execution in new thread */ diff --git a/jdk/src/share/bin/parse_manifest.c b/jdk/src/share/bin/parse_manifest.c index 4926824e36b..1b8014ec57b 100644 --- a/jdk/src/share/bin/parse_manifest.c +++ b/jdk/src/share/bin/parse_manifest.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -174,7 +174,7 @@ find_end(int fd, Byte *eb) */ if ((pos = JLI_Lseek(fd, -ENDHDR, SEEK_END)) < (jlong)0) return (-1); - if ((bytes = read(fd, eb, ENDHDR)) < 0) + if (read(fd, eb, ENDHDR) < 0) return (-1); if (GETSIG(eb) == ENDSIG) { return haveZIP64(eb) ? find_end64(fd, eb, pos) : pos; @@ -193,7 +193,13 @@ find_end(int fd, Byte *eb) return (-1); if ((buffer = malloc(END_MAXLEN)) == NULL) return (-1); - if ((bytes = read(fd, buffer, len)) < 0) { + + /* + * read() on windows takes an unsigned int for count. Casting len + * to an unsigned int here is safe since it is guaranteed to be + * less than END_MAXLEN. + */ + if ((bytes = read(fd, buffer, (unsigned int)len)) < 0) { free(buffer); return (-1); } @@ -577,7 +583,7 @@ JLI_ParseManifest(char *jarfile, manifest_info *info) info->jre_version = NULL; info->jre_restrict_search = 0; info->splashscreen_image_file_name = NULL; - if (rc = find_file(fd, &entry, manifest_name) != 0) { + if ((rc = find_file(fd, &entry, manifest_name)) != 0) { close(fd); return (-2); } @@ -677,7 +683,7 @@ JLI_ManifestIterate(const char *jarfile, attribute_closure ac, void *user_data) return (-1); } - if (rc = find_file(fd, &entry, manifest_name) != 0) { + if ((rc = find_file(fd, &entry, manifest_name)) != 0) { close(fd); return (-2); } diff --git a/jdk/src/share/bin/splashscreen_stubs.c b/jdk/src/share/bin/splashscreen_stubs.c index 9c1f5148c45..f741ccf807a 100644 --- a/jdk/src/share/bin/splashscreen_stubs.c +++ b/jdk/src/share/bin/splashscreen_stubs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -61,11 +61,11 @@ typedef char* (*SplashGetScaledImageName_t)(const char* fileName, #define INVOKEV(name) _INVOKE(name, ,;) int DoSplashLoadMemory(void* pdata, int size) { - INVOKE(SplashLoadMemory, NULL)(pdata, size); + INVOKE(SplashLoadMemory, 0)(pdata, size); } int DoSplashLoadFile(const char* filename) { - INVOKE(SplashLoadFile, NULL)(filename); + INVOKE(SplashLoadFile, 0)(filename); } void DoSplashInit(void) { @@ -87,4 +87,4 @@ void DoSplashSetScaleFactor(float scaleFactor) { char* DoSplashGetScaledImageName(const char* fileName, const char* jarName, float* scaleFactor) { INVOKE(SplashGetScaledImageName, NULL)(fileName, jarName, scaleFactor); -} \ No newline at end of file +} diff --git a/jdk/src/share/bin/wildcard.c b/jdk/src/share/bin/wildcard.c index 96dac738aa0..d8c9df02109 100644 --- a/jdk/src/share/bin/wildcard.c +++ b/jdk/src/share/bin/wildcard.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -274,7 +274,7 @@ FileList_add(FileList fl, char *file) } static void -FileList_addSubstring(FileList fl, const char *beg, int len) +FileList_addSubstring(FileList fl, const char *beg, size_t len) { char *filename = (char *) JLI_MemAlloc(len+1); memcpy(filename, beg, len); @@ -310,7 +310,7 @@ static FileList FileList_split(const char *path, char sep) { const char *p, *q; - int len = (int)JLI_StrLen(path); + size_t len = JLI_StrLen(path); int count; FileList fl; for (count = 1, p = path; p < path + len; p++) diff --git a/jdk/src/solaris/bin/java_md.h b/jdk/src/solaris/bin/java_md.h index ec0615c1320..82fb43a411b 100644 --- a/jdk/src/solaris/bin/java_md.h +++ b/jdk/src/solaris/bin/java_md.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,6 +43,12 @@ #define MAXNAMELEN PATH_MAX #endif +#ifdef _LP64 +#define JLONG_FORMAT_SPECIFIER "%ld" +#else +#define JLONG_FORMAT_SPECIFIER "%lld" +#endif + /* * Common function prototypes and sundries. */ diff --git a/jdk/src/solaris/bin/java_md_common.c b/jdk/src/solaris/bin/java_md_common.c index fb446db739a..37458758b8b 100644 --- a/jdk/src/solaris/bin/java_md_common.c +++ b/jdk/src/solaris/bin/java_md_common.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -463,11 +463,6 @@ UnsetEnv(char *name) return(borrowed_unsetenv(name)); } -const char * -jlong_format_specifier() { - return "%lld"; -} - jboolean IsJavaw() { diff --git a/jdk/src/solaris/bin/java_md_solinux.c b/jdk/src/solaris/bin/java_md_solinux.c index a96713757d8..e5056c44a73 100644 --- a/jdk/src/solaris/bin/java_md_solinux.c +++ b/jdk/src/solaris/bin/java_md_solinux.c @@ -1043,7 +1043,7 @@ ContinueInNewThread0(int (JNICALL *continuation)(void *), jlong stack_size, void if (pthread_create(&tid, &attr, (void *(*)(void*))continuation, (void*)args) == 0) { void * tmp; pthread_join(tid, &tmp); - rslt = (int)tmp; + rslt = (int)(intptr_t)tmp; } else { /* * Continue execution in current thread if for some reason (e.g. out of @@ -1061,7 +1061,7 @@ ContinueInNewThread0(int (JNICALL *continuation)(void *), jlong stack_size, void if (thr_create(NULL, stack_size, (void *(*)(void *))continuation, args, flags, &tid) == 0) { void * tmp; thr_join(tid, NULL, &tmp); - rslt = (int)tmp; + rslt = (int)(intptr_t)tmp; } else { /* See above. Continue in current thread if thr_create() failed */ rslt = continuation(args); diff --git a/jdk/src/windows/bin/cmdtoargs.c b/jdk/src/windows/bin/cmdtoargs.c index 29e5e77ae1f..dc00e8346e2 100644 --- a/jdk/src/windows/bin/cmdtoargs.c +++ b/jdk/src/windows/bin/cmdtoargs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -77,7 +77,7 @@ static char* next_arg(char* cmdline, char* arg, jboolean* wildcard) { USHORT ch = 0; int i; jboolean done = JNI_FALSE; - int charLength; + ptrdiff_t charLength; *wildcard = JNI_FALSE; while (!done) { @@ -209,10 +209,12 @@ void JLI_CmdToArgs(char* cmdline) { argv = (StdArg*) JLI_MemRealloc(argv, (nargs+1) * sizeof(StdArg)); argv[nargs].arg = JLI_StringDup(arg); argv[nargs].has_wildcard = wildcard; - *arg = NULL; + *arg = '\0'; nargs++; } while (src != NULL); + JLI_MemFree(arg); + stdargc = nargs; stdargs = argv; } diff --git a/jdk/src/windows/bin/java_md.c b/jdk/src/windows/bin/java_md.c index 20dd104a8ac..99a00a7e59b 100644 --- a/jdk/src/windows/bin/java_md.c +++ b/jdk/src/windows/bin/java_md.c @@ -108,7 +108,7 @@ int awtPreloadD3D = -1; * GetParamValue("theParam", "theParam=value") returns pointer to "value". */ const char * GetParamValue(const char *paramName, const char *arg) { - int nameLen = JLI_StrLen(paramName); + size_t nameLen = JLI_StrLen(paramName); if (JLI_StrNCmp(paramName, arg, nameLen) == 0) { /* arg[nameLen] is valid (may contain final NULL) */ if (arg[nameLen] == '=') { @@ -583,7 +583,7 @@ JLI_Snprintf(char* buffer, size_t size, const char* format, ...) { if (rc < 0) { /* apply ansi semantics */ buffer[size - 1] = '\0'; - return size; + return (int)size; } else if (rc == size) { /* force a null terminator */ buffer[size - 1] = '\0'; @@ -1164,11 +1164,6 @@ void SplashFreeLibrary() { } } -const char * -jlong_format_specifier() { - return "%I64d"; -} - /* * Block current thread and continue execution in a new thread */ @@ -1318,7 +1313,7 @@ int AWTPreload(const char *funcName) if (hPreloadAwt == NULL) { /* awt.dll is not loaded yet */ char libraryPath[MAXPATHLEN]; - int jrePathLen = 0; + size_t jrePathLen = 0; HMODULE hJava = NULL; HMODULE hVerify = NULL; @@ -1460,7 +1455,8 @@ filterArgs(StdArg *stdargs, const int nargc, StdArg **pargv) { jobjectArray CreateApplicationArgs(JNIEnv *env, char **strv, int argc) { - int i, j, idx, tlen; + int i, j, idx; + size_t tlen; jobjectArray outArray, inArray; char *ostart, *astart, **nargv; jboolean needs_expansion = JNI_FALSE; diff --git a/jdk/src/windows/bin/java_md.h b/jdk/src/windows/bin/java_md.h index 72151b92e50..878952dca53 100644 --- a/jdk/src/windows/bin/java_md.h +++ b/jdk/src/windows/bin/java_md.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,6 +39,7 @@ #define MAXPATHLEN MAX_PATH #define MAXNAMELEN MAX_PATH +#define JLONG_FORMAT_SPECIFIER "%I64d" /* * Support for doing cheap, accurate interval timing.