[PATCH] scripts: docproc.c: Changed from using strncat to strlcat

From: Rickard Strandqvist
Date: Sun Oct 12 2014 - 16:29:51 EST


Changed from using strncat to strlcat to simplify the code

Signed-off-by: Rickard Strandqvist <rickard_strandqvist@xxxxxxxxxxxxxxxxxx>
---
scripts/docproc.c | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/scripts/docproc.c b/scripts/docproc.c
index e267e621..dd1d10a 100644
--- a/scripts/docproc.c
+++ b/scripts/docproc.c
@@ -118,10 +118,10 @@ static void exec_kernel_doc(char **svec)
perror("fork");
exit(1);
case 0:
- memset(real_filename, 0, sizeof(real_filename));
- strncat(real_filename, kernsrctree, PATH_MAX);
- strncat(real_filename, "/" KERNELDOCPATH KERNELDOC,
- PATH_MAX - strlen(real_filename));
+ strlcpy(real_filename, kernsrctree,
+ sizeof(real_filename));
+ strlcat(real_filename, "/" KERNELDOCPATH KERNELDOC,
+ sizeof(real_filename));
execvp(real_filename, svec);
fprintf(stderr, "exec ");
perror(real_filename);
@@ -199,11 +199,9 @@ static void find_export_symbols(char * filename)
char line[MAXLINESZ];
if (filename_exist(filename) == NULL) {
char real_filename[PATH_MAX + 1];
- memset(real_filename, 0, sizeof(real_filename));
- strncat(real_filename, srctree, PATH_MAX);
- strncat(real_filename, "/", PATH_MAX - strlen(real_filename));
- strncat(real_filename, filename,
- PATH_MAX - strlen(real_filename));
+ strlcpy(real_filename, srctree, sizeof(real_filename));
+ strlcat(real_filename, "/", sizeof(real_filename));
+ strlcat(real_filename, filename, sizeof(real_filename));
sym = add_new_file(filename);
fp = fopen(real_filename, "r");
if (fp == NULL) {
@@ -379,10 +377,10 @@ static void find_all_symbols(char *filename)
case 0:
close(pipefd[0]);
dup2(pipefd[1], 1);
- memset(real_filename, 0, sizeof(real_filename));
- strncat(real_filename, kernsrctree, PATH_MAX);
- strncat(real_filename, "/" KERNELDOCPATH KERNELDOC,
- PATH_MAX - strlen(real_filename));
+ strlcpy(real_filename, kernsrctree,
+ sizeof(real_filename));
+ strlcat(real_filename, "/" KERNELDOCPATH KERNELDOC,
+ sizeof(real_filename));
execvp(real_filename, vec);
fprintf(stderr, "exec ");
perror(real_filename);
--
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/