Staging: lustre: remove two build warnings
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 11 Dec 2018 12:50:37 +0000 (13:50 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Dec 2018 08:20:29 +0000 (09:20 +0100)
[for older kernels only, lustre has been removed from upstream]

When someone writes:
strncpy(dest, source, sizeof(source));
they really are just doing the same thing as:
strcpy(dest, source);
but somehow they feel better because they are now using the "safe"
version of the string functions.  Cargo-cult programming at its
finest...

gcc-8 rightfully warns you about doing foolish things like this.  Now
that the stable kernels are all starting to be built using gcc-8, let's
get rid of this warning so that we do not have to gaze at this horror.

To dropt the warning, just convert the code to using strcpy() so that if
someone really wants to audit this code and find all of the obvious
problems, it will be easier to do so.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lnet/lnet/config.c
drivers/staging/lustre/lustre/lmv/lmv_obd.c

index 9e2183ff847e66a405997e7fa8b7d1b69e7f672d..7a4d5a0137972488c8f52341be7e3dcbb77f06a0 100644 (file)
@@ -354,8 +354,7 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
                                CERROR("Can't allocate net interface name\n");
                                goto failed;
                        }
-                       strncpy(ni->ni_interfaces[niface], iface,
-                               strlen(iface));
+                       strcpy(ni->ni_interfaces[niface], iface);
                        niface++;
                        iface = comma;
                } while (iface);
index 9e63171c1ec394860823bc49ec3efa27d652db60..514f078749bb9f496890f41e5e3e971506d22858 100644 (file)
@@ -684,7 +684,7 @@ repeat_fid2path:
                memmove(ptr + strlen(gf->gf_path) + 1, ptr,
                        strlen(ori_gf->gf_path));
 
-               strncpy(ptr, gf->gf_path, strlen(gf->gf_path));
+               strcpy(ptr, gf->gf_path);
                ptr += strlen(gf->gf_path);
                *ptr = '/';
        }