YARN-5719. Enforce a C standard for native container-executor. Contributed by Chris Douglas.
This commit is contained in:
parent
f6715b26b6
commit
972da46cb4
|
@ -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}")
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue