You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by vv...@apache.org on 2016/12/28 10:00:02 UTC

hadoop git commit: YARN-5719. Enforce a C standard for native container-executor. Contributed by Chris Douglas.

Repository: hadoop
Updated Branches:
  refs/heads/trunk f6715b26b -> 972da46cb


YARN-5719. Enforce a C standard for native container-executor. Contributed by Chris Douglas.


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

Branch: refs/heads/trunk
Commit: 972da46cb48725ad49d3e0a033742bd1a8228f51
Parents: f6715b2
Author: Varun Vasudev <vv...@apache.org>
Authored: Wed Dec 28 14:59:57 2016 +0530
Committer: Varun Vasudev <vv...@apache.org>
Committed: Wed Dec 28 14:59:57 2016 +0530

----------------------------------------------------------------------
 .../src/CMakeLists.txt                              | 16 ++++++++++++++++
 .../container-executor/impl/container-executor.c    | 12 ++++++++----
 2 files changed, 24 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/972da46c/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/CMakeLists.txt b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/CMakeLists.txt
index fbc794c..f7fe83d 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/CMakeLists.txt
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/CMakeLists.txt
@@ -26,6 +26,22 @@ include(HadoopCommon)
 string(REGEX MATCH . HCD_ONE "${HADOOP_CONF_DIR}")
 string(COMPARE EQUAL ${HCD_ONE} / HADOOP_CONF_DIR_IS_ABS)
 
+if (CMAKE_VERSION VERSION_LESS "3.1")
+  # subset of CMAKE_<LANG>_COMPILER_ID
+  # https://cmake.org/cmake/help/v3.0/variable/CMAKE_LANG_COMPILER_ID.html
+  if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR
+      CMAKE_C_COMPILER_ID STREQUAL "Clang" OR
+      CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
+    set (CMAKE_C_FLAGS "-std=c99 -Wall -pedantic-errors ${CMAKE_C_FLAGS}")
+  elseif (CMAKE_C_COMPILER_ID STREQUAL "Intel")
+    set (CMAKE_C_FLAGS "-std=c99 -Wall ${CMAKE_C_FLAGS}")
+  elseif (CMAKE_C_COMPILER_ID STREQUAL "SunPro")
+    set (CMAKE_C_FLAGS "-xc99 ${CMAKE_C_FLAGS}")
+  endif ()
+else ()
+  set (CMAKE_C_STANDARD 99)
+endif ()
+
 # Note: can't use -D_FILE_OFFSET_BITS=64, see MAPREDUCE-4258
 string(REPLACE "-D_FILE_OFFSET_BITS=64" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
 string(REPLACE "-D_FILE_OFFSET_BITS=64" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")

http://git-wip-us.apache.org/repos/asf/hadoop/blob/972da46c/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/container-executor.c
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/container-executor.c b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/container-executor.c
index 25f01ea..9be8cf4 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/container-executor.c
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/container-executor.c
@@ -722,14 +722,18 @@ static int create_container_directories(const char* user, const char *app_id,
  * Load the user information for a given user name.
  */
 static struct passwd* get_user_info(const char* user) {
-  int string_size = sysconf(_SC_GETPW_R_SIZE_MAX);
+  size_t string_size = sysconf(_SC_GETPW_R_SIZE_MAX);
   struct passwd *result = NULL;
   if(string_size < 1024) {
     string_size = 1024;
   }
-  void* buffer = malloc(string_size + sizeof(struct passwd));
-  if (getpwnam_r(user, buffer, buffer + sizeof(struct passwd), string_size,
-		 &result) != 0) {
+  struct passwd* buffer = malloc(sizeof(struct passwd) + string_size);
+  if (NULL == buffer) {
+    fprintf(LOGFILE, "Failed malloc in get_user_info");
+    return NULL;
+  }
+  if (getpwnam_r(user, buffer, ((char*)buffer) + sizeof(struct passwd),
+        string_size, &result) != 0) {
     free(buffer);
     fprintf(LOGFILE, "Can't get user information %s - %s\n", user,
 	    strerror(errno));


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org