From: Sam Ravnborg <sam@ravnborg.org>
To: Jan Beulich <jbeulich@novell.com>, Roman Zippel <zippel@linux-m68k.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] kconfig: factor out code in conf_spilt_config
Date: Sat, 31 Mar 2007 09:39:35 +0200 [thread overview]
Message-ID: <20070331073935.GA11383@uranus.ravnborg.org> (raw)
In-Reply-To: <20070331064228.GA11023@uranus.ravnborg.org>
>From e9fcc3bf8d1c71df1ae650d5291c5d4b15d71656 Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <sam@neptun.ravnborg.org>
Date: Sat, 31 Mar 2007 09:15:12 +0200
Subject: [PATCH] kconfig: factor out code in conf_spilt_config
This patch simply factor out code and
do not introduce any functional changes.
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
---
scripts/kconfig/confdata.c | 75 ++++++++++++++++++++++++--------------------
1 files changed, 41 insertions(+), 34 deletions(-)
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 664fe29..ff6b39b 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -533,13 +533,48 @@ int conf_write(const char *name)
return 0;
}
+/* Touch the file specified (adding .h to the name) */
+static int touch_file(const char *file)
+{
+ struct stat sb;
+ int fd;
+ char *d;
+ char name[128];
+
+ strcpy(name, file);
+ strcat(name, ".h");
+
+ /* Open existing file */
+ fd = open(name, O_WRONLY | O_CREAT | O_TRUNC, 0644);
+ if (fd == -1) {
+ if (errno != ENOENT)
+ return 1;
+ /*
+ * Create directory components,
+ * unless they exist already.
+ */
+ d = name;
+ while ((d = strchr(d, '/'))) {
+ *d = 0;
+ if (stat(name, &sb) && mkdir(name, 0755))
+ return 1;
+ *d++ = '/';
+ }
+ /* Directories created, now create file. */
+ fd = open(name, O_WRONLY | O_CREAT | O_TRUNC, 0644);
+ if (fd == -1)
+ return 1;
+ }
+ close(fd);
+ return 0;
+}
+
int conf_split_config(void)
{
char *name, path[128];
char *s, *d, c;
struct symbol *sym;
- struct stat sb;
- int res, i, fd;
+ int res, i;
name = getenv("KCONFIG_AUTOCONFIG");
if (!name)
@@ -601,45 +636,17 @@ int conf_split_config(void)
* different from 'no').
*/
- /* Replace all '_' and append ".h" */
+ /* Replace all '_' with '/' */
s = sym->name;
d = path;
while ((c = *s++)) {
c = tolower(c);
*d++ = (c == '_') ? '/' : c;
}
- strcpy(d, ".h");
-
- /* Assume directory path already exists. */
- fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
- if (fd == -1) {
- if (errno != ENOENT) {
- res = 1;
- break;
- }
- /*
- * Create directory components,
- * unless they exist already.
- */
- d = path;
- while ((d = strchr(d, '/'))) {
- *d = 0;
- if (stat(path, &sb) && mkdir(path, 0755)) {
- res = 1;
- goto out;
- }
- *d++ = '/';
- }
- /* Try it again. */
- fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
- if (fd == -1) {
- res = 1;
- break;
- }
- }
- close(fd);
+ *d = '\0';
+ if (touch_file(path))
+ return 1;
}
-out:
if (chdir("../.."))
return 1;
--
1.5.1.rc3.gaa453
next prev parent reply other threads:[~2007-03-31 7:38 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-29 9:27 [PATCH] fix dependency generation Jan Beulich
2007-03-29 15:39 ` Randy Dunlap
2007-03-29 16:06 ` Jan Beulich
2007-03-29 16:38 ` Randy Dunlap
2007-03-30 9:14 ` Jan Beulich
2007-03-30 15:17 ` Randy Dunlap
2007-03-30 15:08 ` Sam Ravnborg
2007-03-30 15:43 ` Jan Beulich
2007-03-30 17:14 ` Jeff Dike
2007-03-31 6:42 ` Sam Ravnborg
2007-03-31 7:39 ` Sam Ravnborg [this message]
2007-03-31 7:40 ` [PATCH 2/2] kconfig/kbuild: fix dependency problem Sam Ravnborg
2007-03-31 16:11 ` [PATCH] fix dependency generation Roman Zippel
2007-04-01 18:45 ` Sam Ravnborg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070331073935.GA11383@uranus.ravnborg.org \
--to=sam@ravnborg.org \
--cc=jbeulich@novell.com \
--cc=linux-kernel@vger.kernel.org \
--cc=zippel@linux-m68k.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.