Skip to content

Commit fee762d

Browse files
committed
kconfig: refactor conf_touch_dep()
If this function fails to touch a dummy header due to missing parent directory, then it creates it and touches the file again. This was needed because CONFIG_FOO_BAR was previously tracked by include/config/foo/bar.h. (include/config/foo/ may not exist here) This is no longer the case since commit 0e0345b ("kbuild: redo fake deps at include/config/*.h"); now all the fake headers are placed right under include/config/, like include/config/FOO_BAR. Do not try to create parent directory, include/config/, which already exists. Signed-off-by: Masahiro Yamada <[email protected]>
1 parent 00d674c commit fee762d

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

scripts/kconfig/confdata.c

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -130,31 +130,17 @@ static size_t depfile_prefix_len;
130130
/* touch depfile for symbol 'name' */
131131
static int conf_touch_dep(const char *name)
132132
{
133-
int fd, ret;
134-
char *d;
133+
int fd;
135134

136135
/* check overflow: prefix + name + '\0' must fit in buffer. */
137136
if (depfile_prefix_len + strlen(name) + 1 > sizeof(depfile_path))
138137
return -1;
139138

140-
d = depfile_path + depfile_prefix_len;
141-
strcpy(d, name);
139+
strcpy(depfile_path + depfile_prefix_len, name);
142140

143-
/* Assume directory path already exists. */
144141
fd = open(depfile_path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
145-
if (fd == -1) {
146-
if (errno != ENOENT)
147-
return -1;
148-
149-
ret = make_parent_dir(depfile_path);
150-
if (ret)
151-
return ret;
152-
153-
/* Try it again. */
154-
fd = open(depfile_path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
155-
if (fd == -1)
156-
return -1;
157-
}
142+
if (fd == -1)
143+
return -1;
158144
close(fd);
159145

160146
return 0;

0 commit comments

Comments
 (0)