Whamcloud - gitweb
LU-11233 build: support for gcc8 60/34660/7
authorAlex Zhuravlev <bzzz@whamcloud.com>
Mon, 15 Apr 2019 12:58:59 +0000 (15:58 +0300)
committerOleg Drokin <green@whamcloud.com>
Sat, 4 May 2019 05:57:09 +0000 (05:57 +0000)
this patch covers kernel portion of Lustre

Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Change-Id: I3fac8b89eef2291b5cb91ea05ee0b6ff32d11741
Reviewed-on: https://review.whamcloud.com/34660
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
config/lustre-build.m4
lustre/lmv/lmv_obd.c
lustre/mgs/mgs_handler.c
lustre/obdclass/genops.c
lustre/osd-ldiskfs/osd_handler.c
lustre/ptlrpc/nodemap_storage.c
lustre/quota/qsd_lib.c

index 9110b4d..b0bc8b3 100644 (file)
@@ -362,6 +362,50 @@ AC_DEFUN([LB_CC_NO_FORMAT_TRUNCATION], [
 ])
 
 #
+# Check if gcc supports -Wno-stringop-truncation
+#
+# To supress many warnings with gcc8
+#
+AC_DEFUN([LB_CC_NO_STRINGOP_TRUNCATION], [
+       AC_MSG_CHECKING([for -Wno-stringop-truncation support])
+
+       saved_flags="$CFLAGS"
+       CFLAGS="$CFLAGS -Wno-stringop-truncation"
+
+       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [
+               EXTRA_KCFLAGS="$EXTRA_KCFLAGS -Wno-stringop-truncation"
+               AC_SUBST(EXTRA_KCFLAGS)
+               AC_MSG_RESULT([yes])
+       ], [
+               AC_MSG_RESULT([no])
+       ])
+
+       CFLAGS="$saved_flags"
+])
+
+#
+# Check if gcc supports -Wno-stringop-overflow
+#
+# To supress many warnings with gcc8
+#
+AC_DEFUN([LB_CC_NO_STRINGOP_OVERFLOW], [
+       AC_MSG_CHECKING([for -Wno-stringop-overflow support])
+
+       saved_flags="$CFLAGS"
+       CFLAGS="$CFLAGS -Wno-stringop-overflow"
+
+       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [
+               EXTRA_KCFLAGS="$EXTRA_KCFLAGS -Wno-stringop-overflow"
+               AC_SUBST(EXTRA_KCFLAGS)
+               AC_MSG_RESULT([yes])
+       ], [
+               AC_MSG_RESULT([no])
+       ])
+
+       CFLAGS="$saved_flags"
+])
+
+#
 # LB_CONDITIONALS
 #
 # AM_CONDITIONAL instances for everything
@@ -583,6 +627,8 @@ LB_PATH_DEFAULTS
 
 LB_PROG_CC
 LB_CC_NO_FORMAT_TRUNCATION
+LB_CC_NO_STRINGOP_TRUNCATION
+LB_CC_NO_STRINGOP_OVERFLOW
 
 LC_OSD_ADDON
 
index b04d5a3..2df8aa3 100644 (file)
@@ -660,6 +660,7 @@ repeat_fid2path:
        if (remote_gf != NULL) {
                struct getinfo_fid2path *ori_gf;
                char *ptr;
+               int len;
 
                ori_gf = (struct getinfo_fid2path *)karg;
                if (strlen(ori_gf->gf_u.gf_path) + 1 +
@@ -668,13 +669,12 @@ repeat_fid2path:
 
                ptr = ori_gf->gf_u.gf_path;
 
-               memmove(ptr + strlen(gf->gf_u.gf_path) + 1, ptr,
-                       strlen(ori_gf->gf_u.gf_path));
-
-               strncpy(ptr, gf->gf_u.gf_path,
-                       strlen(gf->gf_u.gf_path));
-               ptr += strlen(gf->gf_u.gf_path);
-               *ptr = '/';
+               len = strlen(gf->gf_u.gf_path);
+               /* move the current path to the right to release space
+                * for closer-to-root part */
+               memmove(ptr + len + 1, ptr, strlen(ori_gf->gf_u.gf_path));
+               memcpy(ptr, gf->gf_u.gf_path, len);
+               ptr[len] = '/';
        }
 
        CDEBUG(D_INFO, "%s: get path %s "DFID" rec: %llu ln: %u\n",
index 926b30f..c262706 100644 (file)
@@ -742,7 +742,7 @@ static int mgs_extract_fs_pool(char *arg, char *fsname, char *poolname)
        /* Also make sure poolname is not to long. */
        if (strlen(ptr) > LOV_MAXPOOLNAME)
                return -ENAMETOOLONG;
-       strncpy(poolname, ptr, strlen(ptr));
+       strncpy(poolname, ptr, LOV_MAXPOOLNAME);
 
        /* Test if fsname is empty */
        len = strlen(arg) - strlen(ptr) - 1;
index ebed3cc..0a840c9 100644 (file)
@@ -445,7 +445,7 @@ struct obd_device *class_newdev(const char *type_name, const char *name,
 
        newdev->obd_conn_inprogress = 0;
 
-       strncpy(newdev->obd_uuid.uuid, uuid, strlen(uuid));
+       strncpy(newdev->obd_uuid.uuid, uuid, UUID_MAX);
 
        CDEBUG(D_IOCTL, "Allocate new device %s (%p)\n",
               newdev->obd_name, newdev);
index b28dd17..3eae25f 100644 (file)
@@ -7592,7 +7592,7 @@ static int osd_mount(const struct lu_env *env,
                        "force_over_512tb",
                        NULL
                };
-               strcat(options, opts);
+               strncat(options, opts, PAGE_SIZE);
                for (rc = 0, str = options; sout[rc]; ) {
                        char *op = strstr(str, sout[rc]);
 
@@ -7612,13 +7612,13 @@ static int osd_mount(const struct lu_env *env,
                                ;
                }
        } else {
-               strncat(options, "user_xattr,acl", 14);
+               strncat(options, "user_xattr,acl", PAGE_SIZE);
        }
 
        /* Glom up mount options */
        if (*options != '\0')
-               strcat(options, ",");
-       strlcat(options, "no_mbcache,nodelalloc", PAGE_SIZE);
+               strncat(options, ",", PAGE_SIZE);
+       strncat(options, "no_mbcache,nodelalloc", PAGE_SIZE);
 
        type = get_fs_type("ldiskfs");
        if (!type) {
index 33e6570..72ce072 100644 (file)
@@ -89,7 +89,7 @@ static void nodemap_cluster_rec_init(union nodemap_rec *nr,
 {
        CLASSERT(sizeof(nr->ncr.ncr_name) == sizeof(nodemap->nm_name));
 
-       strncpy(nr->ncr.ncr_name, nodemap->nm_name, sizeof(nodemap->nm_name));
+       strncpy(nr->ncr.ncr_name, nodemap->nm_name, sizeof(nr->ncr.ncr_name));
        nr->ncr.ncr_squash_uid = cpu_to_le32(nodemap->nm_squash_uid);
        nr->ncr.ncr_squash_gid = cpu_to_le32(nodemap->nm_squash_gid);
        nr->ncr.ncr_flags = cpu_to_le32(
index 6aaed49..f2c460a 100644 (file)
@@ -137,13 +137,13 @@ static int qsd_enabled_seq_show(struct seq_file *m, void *data)
 
        memset(enabled, 0, sizeof(enabled));
        if (qsd_type_enabled(qsd, USRQUOTA))
-               strcat(enabled, "u");
+               strncat(enabled, "u", sizeof(enabled) - strlen(enabled));
        if (qsd_type_enabled(qsd, GRPQUOTA))
-               strcat(enabled, "g");
+               strncat(enabled, "g", sizeof(enabled) - strlen(enabled));
        if (qsd_type_enabled(qsd, PRJQUOTA))
-               strncat(enabled, "p", 1);
+               strncat(enabled, "p", sizeof(enabled) - strlen(enabled));
        if (strlen(enabled) == 0)
-               strcat(enabled, "none");
+               strncat(enabled, "none", sizeof(enabled) - strlen(enabled));
 
        seq_printf(m, "%s\n", enabled);
        return 0;