aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/basic/fixdep.c
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2018-01-11 08:05:43 -0500
committerMasahiro Yamada <yamada.masahiro@socionext.com>2018-01-17 19:37:38 -0500
commitccfe78873c22561d3c514790094dc408e4876077 (patch)
treeeb3d49fb9fd8107c9e82d34a7c9f3e82a084b526 /scripts/basic/fixdep.c
parent4003fd80cba967e4044ebac96f13746153e87c4d (diff)
fixdep: remove unneeded memcpy() in parse_dep_file()
Each token in the depfile is copied to the temporary buffer 's' to terminate the token with zero. We do not need to do this any more because the parsed buffer is now writable. Insert '\0' directly in the buffer without calling memcpy(). <limits.h> is no longer necessary. (It was needed for PATH_MAX). Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Diffstat (limited to 'scripts/basic/fixdep.c')
-rw-r--r--scripts/basic/fixdep.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
index 9f9238eaec19..dfba77b5d0c3 100644
--- a/scripts/basic/fixdep.c
+++ b/scripts/basic/fixdep.c
@@ -109,7 +109,6 @@
109#include <string.h> 109#include <string.h>
110#include <stdlib.h> 110#include <stdlib.h>
111#include <stdio.h> 111#include <stdio.h>
112#include <limits.h>
113#include <ctype.h> 112#include <ctype.h>
114 113
115int insert_extra_deps; 114int insert_extra_deps;
@@ -304,7 +303,6 @@ static void *read_file(const char *filename)
304static void parse_dep_file(char *m) 303static void parse_dep_file(char *m)
305{ 304{
306 char *p; 305 char *p;
307 char s[PATH_MAX];
308 int is_last, is_target; 306 int is_last, is_target;
309 int saw_any_target = 0; 307 int saw_any_target = 0;
310 int is_first_dep = 0; 308 int is_first_dep = 0;
@@ -330,16 +328,14 @@ static void parse_dep_file(char *m)
330 /* The /next/ file is the first dependency */ 328 /* The /next/ file is the first dependency */
331 is_first_dep = 1; 329 is_first_dep = 1;
332 } else { 330 } else {
333 /* Save this token/filename */ 331 *p = '\0';
334 memcpy(s, m, p-m);
335 s[p - m] = 0;
336 332
337 /* Ignore certain dependencies */ 333 /* Ignore certain dependencies */
338 if (strrcmp(s, "include/generated/autoconf.h") && 334 if (strrcmp(m, "include/generated/autoconf.h") &&
339 strrcmp(s, "include/generated/autoksyms.h") && 335 strrcmp(m, "include/generated/autoksyms.h") &&
340 strrcmp(s, "arch/um/include/uml-config.h") && 336 strrcmp(m, "arch/um/include/uml-config.h") &&
341 strrcmp(s, "include/linux/kconfig.h") && 337 strrcmp(m, "include/linux/kconfig.h") &&
342 strrcmp(s, ".ver")) { 338 strrcmp(m, ".ver")) {
343 /* 339 /*
344 * Do not list the source file as dependency, 340 * Do not list the source file as dependency,
345 * so that kbuild is not confused if a .c file 341 * so that kbuild is not confused if a .c file
@@ -360,15 +356,15 @@ static void parse_dep_file(char *m)
360 if (!saw_any_target) { 356 if (!saw_any_target) {
361 saw_any_target = 1; 357 saw_any_target = 1;
362 printf("source_%s := %s\n\n", 358 printf("source_%s := %s\n\n",
363 target, s); 359 target, m);
364 printf("deps_%s := \\\n", 360 printf("deps_%s := \\\n",
365 target); 361 target);
366 } 362 }
367 is_first_dep = 0; 363 is_first_dep = 0;
368 } else 364 } else
369 printf(" %s \\\n", s); 365 printf(" %s \\\n", m);
370 366
371 buf = read_file(s); 367 buf = read_file(m);
372 parse_config_file(buf); 368 parse_config_file(buf);
373 free(buf); 369 free(buf);
374 } 370 }