From 5220160648140800ced6466a1f75071ca80162da Mon Sep 17 00:00:00 2001 From: James Simmons Date: Wed, 4 Aug 2021 09:39:19 -0400 Subject: [PATCH] LU-14093 lutf: fix build with gcc10 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The new LUTF code has build issues with gcc10. I see the following build errors. ld: lutf-lutf_listener.o:lutf.h:88: multiple definition of `g_lutf_cfg' ld: lutf-lutf_listener.o:lutf.h:22: multiple definition of `debugtimestr' ld: lutf-lutf_listener.o:lutf.h:21: multiple definition of `di' ld: lutf-lutf_listener.o:lutf.h:20: multiple definition of `debugnow' In function ‘snprintf’, inlined from ‘python_run_interactive_shell’ at lutf_python.c:45:2: stdio2.h:71:10: error: ‘%s’ directive argument is null [-Werror=format-truncation=] 71 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 72 | __glibc_objsize (__s), __fmt, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 73 | __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~ This patch resolves these warnings. Without this patch LUTF will not build on Ubuntu 20 LTS. Test-Parameters: trivial Change-Id: Ie3c99f8c6cf2f5de583dc95a0dc63fcde1aa6ffd Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/44484 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Serguei Smirnov Reviewed-by: Alex Zhuravlev Reviewed-by: Amir Shehata Reviewed-by: Oleg Drokin --- lustre/tests/lutf/src/liblutf_global.c | 2 ++ lustre/tests/lutf/src/lutf.h | 6 +----- lustre/tests/lutf/src/lutf_listener.c | 8 +++++--- lustre/tests/lutf/src/lutf_python.c | 10 +++++----- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lustre/tests/lutf/src/liblutf_global.c b/lustre/tests/lutf/src/liblutf_global.c index 0225516..b099a6c 100644 --- a/lustre/tests/lutf/src/liblutf_global.c +++ b/lustre/tests/lutf/src/liblutf_global.c @@ -10,6 +10,8 @@ #include #include "lutf.h" +lutf_config_params_t g_lutf_cfg; + char *get_lutf_path(void) { return g_lutf_cfg.lutf_path; diff --git a/lustre/tests/lutf/src/lutf.h b/lustre/tests/lutf/src/lutf.h index 65546cb..00b887b 100644 --- a/lustre/tests/lutf/src/lutf.h +++ b/lustre/tests/lutf/src/lutf.h @@ -17,10 +17,6 @@ extern char *outlog; #define OUT_PY_LOG "lutf_py.log" #define LARGE_LOG_FILE 400000000 /* 400 MB */ -time_t debugnow; -int di; -char debugtimestr[30]; - static inline void lutf_log_print(bool error, char *color1, char *color2, char *file, int line, char *fmt, ...) { @@ -85,7 +81,7 @@ typedef struct lutf_config_params_s { */ } lutf_config_params_t; -lutf_config_params_t g_lutf_cfg; +extern lutf_config_params_t g_lutf_cfg; static inline const char *lutf_rc2str(lutf_rc_t rc) { diff --git a/lustre/tests/lutf/src/lutf_listener.c b/lustre/tests/lutf/src/lutf_listener.c index 781e52e..3d0939b 100644 --- a/lustre/tests/lutf/src/lutf_listener.c +++ b/lustre/tests/lutf/src/lutf_listener.c @@ -547,9 +547,11 @@ void *lutf_listener_main(void *usr_data) memcpy(&master->addr, &info->hb_info.master_address, sizeof(master->addr)); - strncpy(master->name, g_lutf_cfg.master_name, - MAX_STR_LEN); - master->name[MAX_STR_LEN-1] = '\0'; + if (g_lutf_cfg.master_name) { + strncpy(master->name, g_lutf_cfg.master_name, + MAX_STR_LEN); + master->name[MAX_STR_LEN-1] = '\0'; + } master->node_type = EN_LUTF_MASTER; gethostname(master->hostname, MAX_STR_LEN); master->telnet_port = info->hb_info.agent_telnet_port; diff --git a/lustre/tests/lutf/src/lutf_python.c b/lustre/tests/lutf/src/lutf_python.c index 20682c1..1c1d64f 100644 --- a/lustre/tests/lutf/src/lutf_python.c +++ b/lustre/tests/lutf/src/lutf_python.c @@ -42,14 +42,14 @@ static lutf_rc_t python_run_interactive_shell(void) PyRun_SimpleString("import readline\n"); /* all other paths are figured out within python */ - snprintf(buf, MAX_STR_LEN, + snprintf(buf, sizeof(buf), "sys.path.append(os.path.join('%s', 'python', 'infra'))", - g_lutf_cfg.lutf_path); + g_lutf_cfg.lutf_path ? : "NULL"); PyRun_SimpleString(buf); - snprintf(buf, MAX_STR_LEN, + snprintf(buf, sizeof(buf), "sys.path.append(\"%s/src\")\n", - g_lutf_cfg.lutf_path); + g_lutf_cfg.lutf_path ? : "NULL"); PyRun_SimpleString(buf); while (more != NULL) { @@ -152,7 +152,7 @@ static lutf_rc_t python_run_interactive_shell(void) */ PDEBUG("Running in Daemon mode"); sprintf(segment, "fname = os.path.join('%s', '%s')\n", - g_lutf_cfg.tmp_dir, OUT_PY_LOG); + g_lutf_cfg.tmp_dir ? : "NULL", OUT_PY_LOG); if (PyRun_SimpleString(segment)) { PERROR("Failed to create log file"); rc = EN_LUTF_RC_FAIL; -- 1.8.3.1