Repository: hadoop
Updated Branches:
  refs/heads/HDFS-8707 6df167c85 -> 2e0dd25cb


HDFS-9679: Fix inconsistencies with libhdfs C API.  Contributed by James 
Clampffer


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/b0485f0a
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/b0485f0a
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/b0485f0a

Branch: refs/heads/HDFS-8707
Commit: b0485f0a02c7088a209617c8714e603532f282ae
Parents: 6df167c
Author: Bob Hansen <[email protected]>
Authored: Mon Feb 1 07:49:41 2016 -0500
Committer: Bob Hansen <[email protected]>
Committed: Mon Feb 1 07:49:41 2016 -0500

----------------------------------------------------------------------
 .../main/native/libhdfspp/lib/bindings/c/hdfs.cc    | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/b0485f0a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/bindings/c/hdfs.cc
----------------------------------------------------------------------
diff --git 
a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/bindings/c/hdfs.cc
 
b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/bindings/c/hdfs.cc
index d5b5d6e..3262c66 100644
--- 
a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/bindings/c/hdfs.cc
+++ 
b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/bindings/c/hdfs.cc
@@ -121,6 +121,9 @@ static int Error(const Status &stat) {
     case Status::Code::kException:
       ReportError(EINTR, "Exception raised");
       break;
+    case Status::Code::kOperationCanceled:
+      ReportError(EINTR, "Operation canceled");
+      break;
     default:
       ReportError(ENOSYS, "Error: unrecognised code");
   }
@@ -147,9 +150,9 @@ bool CheckSystemAndHandle(hdfsFS fs, hdfsFile file) {
 int hdfsFileIsOpenForRead(hdfsFile file) {
   /* files can only be open for reads at the moment, do a quick check */
   if (file) {
-    return true; // Update implementation when we get file writing
+    return 1; // Update implementation when we get file writing
   }
-  return false;
+  return 0;
 }
 
 hdfsFS hdfsConnect(const char *nn, tPort port) {
@@ -239,6 +242,7 @@ tSize hdfsRead(hdfsFS fs, hdfsFile file, void *buffer, 
tSize length) {
   return (tSize)len;
 }
 
+/* 0 on success, -1 on error*/
 int hdfsSeek(hdfsFS fs, hdfsFile file, tOffset desiredPos) {
   if (!CheckSystemAndHandle(fs, file)) {
     return -1;
@@ -250,7 +254,7 @@ int hdfsSeek(hdfsFS fs, hdfsFile file, tOffset desiredPos) {
     return Error(stat);
   }
 
-  return (int)desired;
+  return 0;
 }
 
 tOffset hdfsTell(hdfsFS fs, hdfsFile file) {
@@ -267,6 +271,7 @@ tOffset hdfsTell(hdfsFS fs, hdfsFile file) {
   return offset;
 }
 
+/* extended API */
 int hdfsCancel(hdfsFS fs, hdfsFile file) {
   if (!CheckSystemAndHandle(fs, file)) {
     return -1;
@@ -340,10 +345,7 @@ int hdfsBuilderConfSetStr(struct hdfsBuilder *bld, const 
char *key,
 
 void hdfsConfStrFree(char *val)
 {
-  if (val)
-  {
-    free(val);
-  }
+  free(val);
 }
 
 hdfsFS hdfsBuilderConnect(struct hdfsBuilder *bld) {

Reply via email to