From 168c72143509ac9071b1a50f7a7cd8e0d8f622bc Mon Sep 17 00:00:00 2001 From: Chris Nauroth Date: Mon, 14 Jul 2014 20:57:33 +0000 Subject: [PATCH] HADOOP-10810. Merging change r1610524 from trunk to branch-2. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1610526 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-common-project/hadoop-common/CHANGES.txt | 2 ++ .../hadoop/io/compress/zlib/ZlibCompressor.c | 1 + .../org/apache/hadoop/io/nativeio/NativeIO.c | 17 +++++++++-------- .../hadoop/net/unix/DomainSocketWatcher.c | 10 ++++++---- .../security/JniBasedUnixGroupsMappingWin.c | 2 +- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index ce9ef402747..937eb1bdf2a 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -25,6 +25,8 @@ Release 2.6.0 - UNRELEASED HADOOP-10780. hadoop_user_info_alloc fails on FreeBSD due to incorrect sysconf use (Dmitry Sivachenko via Colin Patrick McCabe) + HADOOP-10810. Clean up native code compilation warnings. (cnauroth) + Release 2.5.0 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/zlib/ZlibCompressor.c b/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/zlib/ZlibCompressor.c index 142f5eb4064..f7c0cb9db99 100644 --- a/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/zlib/ZlibCompressor.c +++ b/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/zlib/ZlibCompressor.c @@ -379,6 +379,7 @@ Java_org_apache_hadoop_io_compress_zlib_ZlibCompressor_getLibraryName(JNIEnv *en return (*env)->NewStringUTF(env, dl_info.dli_fname); } } + return (*env)->NewStringUTF(env, "Unavailable"); #endif #ifdef WINDOWS diff --git a/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/nativeio/NativeIO.c b/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/nativeio/NativeIO.c index e3ad3272423..95bb987602f 100644 --- a/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/nativeio/NativeIO.c +++ b/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/nativeio/NativeIO.c @@ -580,6 +580,8 @@ Java_org_apache_hadoop_io_nativeio_NativeIO_00024POSIX_getUserName( JNIEnv *env, jclass clazz, jint uid) { #ifdef UNIX + jstring jstr_username = NULL; + char *pw_buf = NULL; int pw_lock_locked = 0; if (pw_lock_object != NULL) { if ((*env)->MonitorEnter(env, pw_lock_object) != JNI_OK) { @@ -588,7 +590,6 @@ Java_org_apache_hadoop_io_nativeio_NativeIO_00024POSIX_getUserName( pw_lock_locked = 1; } - char *pw_buf = NULL; int rc; size_t pw_buflen = get_pw_buflen(); if ((pw_buf = malloc(pw_buflen)) == NULL) { @@ -623,7 +624,7 @@ Java_org_apache_hadoop_io_nativeio_NativeIO_00024POSIX_getUserName( goto cleanup; } - jstring jstr_username = (*env)->NewStringUTF(env, pwd.pw_name); + jstr_username = (*env)->NewStringUTF(env, pwd.pw_name); cleanup: if (pw_lock_locked) { @@ -664,7 +665,7 @@ Java_org_apache_hadoop_io_nativeio_NativeIO_00024POSIX_mmap( #ifdef WINDOWS THROW(env, "java/io/IOException", "The function POSIX.mmap() is not supported on Windows"); - return NULL; + return (jlong)(intptr_t)NULL; #endif } @@ -684,7 +685,6 @@ Java_org_apache_hadoop_io_nativeio_NativeIO_00024POSIX_munmap( #ifdef WINDOWS THROW(env, "java/io/IOException", "The function POSIX.munmap() is not supported on Windows"); - return NULL; #endif } @@ -700,6 +700,8 @@ Java_org_apache_hadoop_io_nativeio_NativeIO_00024POSIX_getGroupName( JNIEnv *env, jclass clazz, jint gid) { #ifdef UNIX + jstring jstr_groupname = NULL; + char *pw_buf = NULL; int pw_lock_locked = 0; if (pw_lock_object != NULL) { @@ -709,7 +711,6 @@ Java_org_apache_hadoop_io_nativeio_NativeIO_00024POSIX_getGroupName( pw_lock_locked = 1; } - char *pw_buf = NULL; int rc; size_t pw_buflen = get_pw_buflen(); if ((pw_buf = malloc(pw_buflen)) == NULL) { @@ -744,7 +745,7 @@ Java_org_apache_hadoop_io_nativeio_NativeIO_00024POSIX_getGroupName( goto cleanup; } - jstring jstr_groupname = (*env)->NewStringUTF(env, grp.gr_name); + jstr_groupname = (*env)->NewStringUTF(env, grp.gr_name); PASS_EXCEPTIONS_GOTO(env, cleanup); cleanup: @@ -922,7 +923,7 @@ Java_org_apache_hadoop_io_nativeio_NativeIO_00024Windows_setFilePointer #ifdef UNIX THROW(env, "java/io/IOException", "The function setFilePointer(FileDescriptor) is not supported on Unix"); - return NULL; + return (jlong)(intptr_t)NULL; #endif #ifdef WINDOWS @@ -957,7 +958,7 @@ JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_io_nativeio_NativeIO_00024Wind #ifdef UNIX THROW(env, "java/io/IOException", "The function access0(path, access) is not supported on Unix"); - return NULL; + return (jlong)(intptr_t)NULL; #endif #ifdef WINDOWS diff --git a/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/net/unix/DomainSocketWatcher.c b/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/net/unix/DomainSocketWatcher.c index 8281e643672..dbaa4fefed6 100644 --- a/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/net/unix/DomainSocketWatcher.c +++ b/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/net/unix/DomainSocketWatcher.c @@ -120,17 +120,19 @@ Java_org_apache_hadoop_net_unix_DomainSocketWatcher_00024FdSet_remove( JNIEnv *env, jobject obj, jint fd) { struct fd_set_data *sd; - struct pollfd *pollfd, *last_pollfd; + struct pollfd *pollfd = NULL, *last_pollfd; int used_size, i; sd = (struct fd_set_data*)(intptr_t)(*env)-> GetLongField(env, obj, fd_set_data_fid); used_size = sd->used_size; for (i = 0; i < used_size; i++) { - pollfd = sd->pollfd + i; - if (pollfd->fd == fd) break; + if (sd->pollfd[i].fd == fd) { + pollfd = sd->pollfd + i; + break; + } } - if (i == used_size) { + if (pollfd == NULL) { (*env)->Throw(env, newRuntimeException(env, "failed to remove fd %d " "from the FdSet because it was never present.", fd)); return; diff --git a/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/security/JniBasedUnixGroupsMappingWin.c b/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/security/JniBasedUnixGroupsMappingWin.c index 28148d09c96..5d0e449aa9f 100644 --- a/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/security/JniBasedUnixGroupsMappingWin.c +++ b/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/security/JniBasedUnixGroupsMappingWin.c @@ -45,7 +45,7 @@ static void throw_ioexception(JNIEnv* env, DWORD errnum) FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, *(DWORD*) (&errnum), // reinterpret cast MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPSTR*)&buffer, 0, NULL); + buffer, 0, NULL); if (len > 0) {