Skip to content

Commit ccfe788

Browse files
committed
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 <[email protected]>
1 parent 4003fd8 commit ccfe788

1 file changed

Lines changed: 9 additions & 13 deletions

File tree

scripts/basic/fixdep.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@
109109
#include <string.h>
110110
#include <stdlib.h>
111111
#include <stdio.h>
112-
#include <limits.h>
113112
#include <ctype.h>
114113

115114
int insert_extra_deps;
@@ -304,7 +303,6 @@ static void *read_file(const char *filename)
304303
static void parse_dep_file(char *m)
305304
{
306305
char *p;
307-
char s[PATH_MAX];
308306
int is_last, is_target;
309307
int saw_any_target = 0;
310308
int is_first_dep = 0;
@@ -330,16 +328,14 @@ static void parse_dep_file(char *m)
330328
/* The /next/ file is the first dependency */
331329
is_first_dep = 1;
332330
} else {
333-
/* Save this token/filename */
334-
memcpy(s, m, p-m);
335-
s[p - m] = 0;
331+
*p = '\0';
336332

337333
/* Ignore certain dependencies */
338-
if (strrcmp(s, "include/generated/autoconf.h") &&
339-
strrcmp(s, "include/generated/autoksyms.h") &&
340-
strrcmp(s, "arch/um/include/uml-config.h") &&
341-
strrcmp(s, "include/linux/kconfig.h") &&
342-
strrcmp(s, ".ver")) {
334+
if (strrcmp(m, "include/generated/autoconf.h") &&
335+
strrcmp(m, "include/generated/autoksyms.h") &&
336+
strrcmp(m, "arch/um/include/uml-config.h") &&
337+
strrcmp(m, "include/linux/kconfig.h") &&
338+
strrcmp(m, ".ver")) {
343339
/*
344340
* Do not list the source file as dependency,
345341
* so that kbuild is not confused if a .c file
@@ -360,15 +356,15 @@ static void parse_dep_file(char *m)
360356
if (!saw_any_target) {
361357
saw_any_target = 1;
362358
printf("source_%s := %s\n\n",
363-
target, s);
359+
target, m);
364360
printf("deps_%s := \\\n",
365361
target);
366362
}
367363
is_first_dep = 0;
368364
} else
369-
printf(" %s \\\n", s);
365+
printf(" %s \\\n", m);
370366

371-
buf = read_file(s);
367+
buf = read_file(m);
372368
parse_config_file(buf);
373369
free(buf);
374370
}

0 commit comments

Comments
 (0)