LKML Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] Stop docproc segfaulting when SRCTREE isn't set.
@ 2007-10-09  6:25 Rob Landley
  2007-10-09 13:03 ` Ahmed S. Darwish
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Rob Landley @ 2007-10-09  6:25 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, rdunlap

From: Rob Landley <rob@landley.net>

Prevent docproc from segfaulting when SRCTREE isn't set.

Signed-off-by: Rob Landley <rob@landley.net>
---

 scripts/basic/docproc.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff -r a26a53ed1101 scripts/basic/docproc.c
--- a/scripts/basic/docproc.c	Sun Oct 07 16:42:22 2007 -0700
+++ b/scripts/basic/docproc.c	Tue Oct 09 01:08:54 2007 -0500
@@ -64,12 +64,15 @@ FILELINE * entity_system;
 #define FUNCTION      "-function"
 #define NOFUNCTION    "-nofunction"
 
+char *srctree;
+
 void usage (void)
 {
 	fprintf(stderr, "Usage: docproc {doc|depend} file\n");
 	fprintf(stderr, "Input is read from file.tmpl. Output is sent to stdout\n");
 	fprintf(stderr, "doc: frontend when generating kernel documentation\n");
 	fprintf(stderr, "depend: generate list of files referenced within file\n");
+	fprintf(stderr, "Environment variable SRCTREE: absolute path to kernel source tree.\n");
 }
 
 /*
@@ -88,7 +91,7 @@ void exec_kernel_doc(char **svec)
 			exit(1);
 		case  0:
 			memset(real_filename, 0, sizeof(real_filename));
-			strncat(real_filename, getenv("SRCTREE"), PATH_MAX);
+			strncat(real_filename, srctree, PATH_MAX);
 			strncat(real_filename, KERNELDOCPATH KERNELDOC,
 					PATH_MAX - strlen(real_filename));
 			execvp(real_filename, svec);
@@ -168,7 +171,7 @@ void find_export_symbols(char * filename
 	if (filename_exist(filename) == NULL) {
 		char real_filename[PATH_MAX + 1];
 		memset(real_filename, 0, sizeof(real_filename));
-		strncat(real_filename, getenv("SRCTREE"), PATH_MAX);
+		strncat(real_filename, srctree, PATH_MAX);
 		strncat(real_filename, filename,
 				PATH_MAX - strlen(real_filename));
 		sym = add_new_file(filename);
@@ -335,6 +338,9 @@ int main(int argc, char *argv[])
 int main(int argc, char *argv[])
 {
 	FILE * infile;
+
+	srctree = getenv("SRCTREE");
+	if (!srctree) srctree = getcwd(NULL,0);
 	if (argc != 3) {
 		usage();
 		exit(1);

-- 
"One of my most productive days was throwing away 1000 lines of code."
  - Ken Thompson.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, back to index

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-09  6:25 [PATCH] Stop docproc segfaulting when SRCTREE isn't set Rob Landley
2007-10-09 13:03 ` Ahmed S. Darwish
2007-10-09 15:55   ` Randy Dunlap
2007-10-09 17:19     ` Ahmed S. Darwish
2007-10-09 17:24       ` Randy Dunlap
2007-10-09 17:51         ` Ahmed S. Darwish
2007-10-09 22:19   ` Rob Landley
2007-10-09 15:56 ` Randy Dunlap
2007-10-18 11:53 ` Sam Ravnborg

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lkml.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lkml.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lkml.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lkml.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lkml.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lkml.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lkml.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lkml.kernel.org/lkml/7 lkml/git/7.git
	git clone --mirror https://lkml.kernel.org/lkml/8 lkml/git/8.git
	git clone --mirror https://lkml.kernel.org/lkml/9 lkml/git/9.git
	git clone --mirror https://lkml.kernel.org/lkml/10 lkml/git/10.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lkml.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git