Whamcloud - gitweb
LU-14093 lutf: fix build with gcc10 84/44484/7
authorJames Simmons <jsimmons@infradead.org>
Wed, 4 Aug 2021 13:39:19 +0000 (09:39 -0400)
committerOleg Drokin <green@whamcloud.com>
Wed, 18 Aug 2021 02:00:21 +0000 (02:00 +0000)
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 <jsimmons@infradead.org>
Reviewed-on: https://review.whamcloud.com/44484
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Serguei Smirnov <ssmirnov@whamcloud.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Amir Shehata <ashehata@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/lutf/src/liblutf_global.c
lustre/tests/lutf/src/lutf.h
lustre/tests/lutf/src/lutf_listener.c
lustre/tests/lutf/src/lutf_python.c

index 0225516..b099a6c 100644 (file)
@@ -10,6 +10,8 @@
 #include <unistd.h>
 #include "lutf.h"
 
+lutf_config_params_t g_lutf_cfg;
+
 char *get_lutf_path(void)
 {
        return g_lutf_cfg.lutf_path;
index 65546cb..00b887b 100644 (file)
@@ -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)
 {
index 781e52e..3d0939b 100644 (file)
@@ -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;
index 20682c1..1c1d64f 100644 (file)
@@ -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;