浏览代码

HDFS-3673. libhdfs: fix some compiler warnings. Contributed by Colin Patrick McCabe

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1363457 13f79535-47bb-0310-9956-ffa450edef68
Eli Collins 13 年之前
父节点
当前提交
15eec42316

+ 2 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

@@ -345,6 +345,8 @@ Branch-2 ( Unreleased changes )
 
     HDFS-3666. Plumb more exception messages to terminate. (eli)
 
+    HDFS-3673. libhdfs: fix some compiler warnings. (Colin Patrick McCabe via eli)
+
   OPTIMIZATIONS
 
     HDFS-2982. Startup performance suffers when there are many edit log

+ 3 - 3
hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/hdfs.c

@@ -275,7 +275,7 @@ done:
  */
 static int jStrToCstr(JNIEnv *env, jstring jstr, char **cstr)
 {
-    char *tmp;
+    const char *tmp;
 
     tmp = (*env)->GetStringUTFChars(env, jstr, NULL);
     *cstr = strdup(tmp);
@@ -632,7 +632,7 @@ done:
 
     if (ret)
         errno = ret;
-    return gFsRef;
+    return (hdfsFS)gFsRef;
 }
 
 int hdfsDisconnect(hdfsFS fs)
@@ -667,7 +667,7 @@ int hdfsDisconnect(hdfsFS fs)
     }
 
     //Release unnecessary references
-    (*env)->DeleteGlobalRef(env, fs);
+    (*env)->DeleteGlobalRef(env, jFS);
 
     return 0;
 }

+ 0 - 10
hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/hdfs.h

@@ -81,15 +81,6 @@ extern  "C" {
      */
     int hdfsFileIsOpenForWrite(hdfsFile file);
 
-    /**
-     * Disable the direct read optimization for a file.
-     *
-     * This is mainly provided for unit testing purposes.
-     *
-     * @param file     The HDFS file
-     */
-    void hdfsFileDisableDirectRead(hdfsFile file);
-
     /** 
      * hdfsConnectAsUser - Connect to a hdfs file system as a specific user
      * Connect to the hdfs.
@@ -101,7 +92,6 @@ extern  "C" {
      */
      hdfsFS hdfsConnectAsUser(const char* nn, tPort port, const char *user);
 
-
     /** 
      * hdfsConnect - Connect to a hdfs file system.
      * Connect to the hdfs.

+ 11 - 2
hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/hdfs_test.h

@@ -19,7 +19,7 @@
 #ifndef LIBHDFS_HDFS_TEST_H
 #define LIBHDFS_HDFS_TEST_H
 
-struct hdfs_internal;
+struct hdfsFile_internal;
 
 /**
  * Some functions that are visible only for testing.
@@ -38,7 +38,16 @@ extern  "C" {
      * @return         1 if the file is using the direct read optimization,
      *                 0 otherwise.
      */
-    int hdfsFileUsesDirectRead(struct hdfs_internal *file);
+    int hdfsFileUsesDirectRead(struct hdfsFile_internal *file);
+
+    /**
+     * Disable the direct read optimization for a file.
+     *
+     * This is mainly provided for unit testing purposes.
+     *
+     * @param file     The HDFS file
+     */
+    void hdfsFileDisableDirectRead(struct hdfsFile_internal *file);
 #ifdef __cplusplus
 }
 #endif

+ 3 - 2
hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/jni_helper.c

@@ -550,7 +550,8 @@ JNIEnv* getJNIEnv(void)
         ret = pthread_key_create(&gTlsKey, hdfsThreadDestructor);
         if (ret) {
             pthread_mutex_unlock(&jvmMutex);
-            fprintf("pthread_key_create failed with error %d\n", ret);
+            fprintf(stderr, "getJNIEnv: pthread_key_create failed with "
+                "error %d\n", ret);
             return NULL;
         }
         gTlsKeyInitialized = 1;
@@ -569,7 +570,7 @@ JNIEnv* getJNIEnv(void)
     }
     tls = calloc(1, sizeof(struct hdfsTls));
     if (!tls) {
-        fprintf(stderr, "getJNIEnv: OOM allocating %d bytes\n",
+        fprintf(stderr, "getJNIEnv: OOM allocating %zd bytes\n",
                 sizeof(struct hdfsTls));
         return NULL;
     }

+ 0 - 1
hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/test/test_libhdfs_read.c

@@ -35,7 +35,6 @@ int main(int argc, char **argv) {
     } 
  
     const char* rfile = argv[1];
-    tSize fileTotalSize = strtoul(argv[2], NULL, 10);
     tSize bufferSize = strtoul(argv[3], NULL, 10);
    
     hdfsFile readFile = hdfsOpenFile(fs, rfile, O_RDONLY, bufferSize, 0, 0);

+ 1 - 0
hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/test_libhdfs_threaded.c

@@ -25,6 +25,7 @@
 #include <pthread.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
 #define TLH_MAX_THREADS 100