History

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 0e0345b77ac4 ("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.

Masahiro Yamada committed 5 years ago

Commit fee762d1 parent 00d674c1 file · +4 −18Browse files

Unified · Split

scripts/kconfig/confdata.c+4−18
@@ -130,31 +130,17 @@ static size_t depfile_prefix_len; · 129 unmodified lines
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;