Whamcloud - gitweb
LU-9934 build: address issues raised by gcc7 76/30376/15
authorJames Simmons <uja.ornl@yahoo.com>
Sun, 14 Jan 2018 04:23:22 +0000 (23:23 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 25 Jan 2018 04:47:39 +0000 (04:47 +0000)
Starting with gcc version 7 several platforms have enabled new
flags to report potential problems when compling code. For lustre
much of the reported problems deal with potential buffer overruns.
Also we have unused data structures and are not properly
initializing some data structures.

Change-Id: I10243ea88f2c726032d179febdbf26f28de13715
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-on: https://review.whamcloud.com/30376
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
libcfs/libcfs/util/parser.c
lnet/lnet/router_proc.c
lustre/include/lustre_disk.h
lustre/ofd/ofd_obd.c
lustre/osd-ldiskfs/osd_oi.c
lustre/utils/lfs.c
lustre/utils/lsnapshot.c

index 3fbb09e..ec19dd1 100644 (file)
@@ -549,7 +549,6 @@ int Parser_list_commands(const command_t *cmdlist, char *buffer,
        int col = col_start;
        int char_max;
        int len;
-       char fmt[6];
        int count = 0;
        int rc;
 
@@ -572,9 +571,9 @@ int Parser_list_commands(const command_t *cmdlist, char *buffer,
 
                /* Add trailing spaces to pad the entry to the column size */
                if (len < char_max) {
-                       snprintf(fmt, 6, "%%-%2ds", char_max - len);
                        snprintf(&buffer[col * char_max] + len,
-                                char_max - len + 1, fmt, " ");
+                                char_max - len + 1, "%*s", char_max - len,
+                                " ");
                } else {
                        buffer[(col + 1) * char_max - 1] = ' ';
                }
index 064c73a..329e43f 100644 (file)
@@ -951,7 +951,7 @@ static struct ctl_table lnet_table[] = {
                .mode           = 0644,
                .proc_handler   = &proc_lnet_portal_rotor,
        },
-       { 0 }
+       { .procname = NULL }
 };
 
 void lnet_router_debugfs_init(void)
index 45380ee..c34a833 100644 (file)
@@ -120,8 +120,10 @@ struct lustre_sb_info {
        struct dt_device         *lsi_dt_dev;  /* dt device to access disk fs*/
        atomic_t                  lsi_mounts;  /* references to the srv_mnt */
        char                      lsi_svname[MTI_NAME_MAXLEN];
-       char                      lsi_osd_obdname[64];
-       char                      lsi_osd_uuid[64];
+       /* lsi_osd_obdname format = 'lsi->ls_svname'-osd */
+       char                      lsi_osd_obdname[MTI_NAME_MAXLEN + 4];
+       /* lsi_osd_uuid format = 'lsi->ls_osd_obdname'_UUID */
+       char                      lsi_osd_uuid[MTI_NAME_MAXLEN + 9];
        struct obd_export        *lsi_osd_exp;
        char                      lsi_osd_type[16];
        char                      lsi_fstype[16];
index 771f7bd..dba54a4 100644 (file)
@@ -1163,7 +1163,7 @@ static int ofd_ioc_get_obj_version(const struct lu_env *env,
                   data->ioc_inllen3 == sizeof(__u64) &&
                   data->ioc_inlbuf4 != NULL &&
                   data->ioc_inllen4 == sizeof(__u64)) {
-               struct ost_id ostid;
+               struct ost_id ostid = { };
 
                ostid_set_seq(&ostid, *(__u64 *)data->ioc_inlbuf4);
                rc = ostid_set_id(&ostid, *(__u64 *)data->ioc_inlbuf3);
index 54265df..5dceea7 100644 (file)
@@ -285,9 +285,9 @@ osd_oi_table_open(struct osd_thread_info *info, struct osd_device *osd,
                  struct osd_oi **oi_table, unsigned oi_count, bool create)
 {
        struct scrub_file *sf = &osd->od_scrub.os_scrub.os_file;
-       int                count = 0;
-       int                rc = 0;
-       int                i;
+       int count = 0;
+       int rc = 0;
+       int i;
        ENTRY;
 
        /* NB: oi_count != 0 means that we have already created/known all OIs
@@ -295,14 +295,14 @@ osd_oi_table_open(struct osd_thread_info *info, struct osd_device *osd,
        LASSERT(oi_count <= OSD_OI_FID_NR_MAX);
 
        for (i = 0; i < (oi_count != 0 ? oi_count : OSD_OI_FID_NR_MAX); i++) {
-               char name[12];
+               char name[sizeof(OSD_OI_NAME_BASE) + 3 * sizeof(i) + 1];
 
                if (oi_table[i] != NULL) {
                        count++;
                        continue;
                }
 
-               sprintf(name, "%s.%d", OSD_OI_NAME_BASE, i);
+               snprintf(name, sizeof(name), "%s.%d", OSD_OI_NAME_BASE, i);
                rc = osd_oi_open(info, osd, name, &oi_table[i], create);
                if (rc == 0) {
                        count++;
index 4920cf0..769d3ad 100644 (file)
@@ -6355,12 +6355,6 @@ static const char *const ladvise_names[] = LU_LADVISE_NAMES;
 
 static const char *const lock_mode_names[] = LOCK_MODE_NAMES;
 
-static const char *const lockahead_results[] = {
-       [LLA_RESULT_SENT] = "Lock request sent",
-       [LLA_RESULT_DIFFERENT] = "Different matching lock found",
-       [LLA_RESULT_SAME] = "Matching lock on identical extent found",
-};
-
 int lfs_get_mode(const char *string)
 {
        enum lock_mode_user mode;
index 3221f74..4b10836 100644 (file)
@@ -1325,8 +1325,7 @@ static int snapshot_create(struct snapshot_instance *si)
                return rc;
 
        srandom(tv.tv_usec);
-       snprintf(new_fsname, 8, "%08x", (__u32)random());
-       new_fsname[8] = '\0';
+       snprintf(new_fsname, sizeof(new_fsname), "%08x", (__u32)random());
 
        rc = snapshot_get_mgsnode(si, buf, sizeof(buf));
        if (rc)