diff options
author | Rob Landley <rob@landley.net> | 2007-10-09 02:25:18 -0400 |
---|---|---|
committer | Sam Ravnborg <sam@neptun.(none)> | 2007-10-18 07:42:53 -0400 |
commit | bb13be5145e18cfb3a2f9cc6091aa048d032a3cd (patch) | |
tree | 641277a42d90f1a99506a71b646371b1bc2935c4 /scripts | |
parent | 4b21960f90d4d011e49e386d0525b1e89f320658 (diff) |
kbuild: stop docproc segfaulting when SRCTREE isn't set.
Prevent docproc from segfaulting when SRCTREE isn't set.
Signed-off-by: Rob Landley <rob@landley.net>
Acked-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/basic/docproc.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/scripts/basic/docproc.c b/scripts/basic/docproc.c index e5c6ac7bde9b..0e4bd5459df4 100644 --- a/scripts/basic/docproc.c +++ b/scripts/basic/docproc.c | |||
@@ -66,12 +66,15 @@ FILELINE * entity_system; | |||
66 | #define FUNCTION "-function" | 66 | #define FUNCTION "-function" |
67 | #define NOFUNCTION "-nofunction" | 67 | #define NOFUNCTION "-nofunction" |
68 | 68 | ||
69 | char *srctree; | ||
70 | |||
69 | void usage (void) | 71 | void usage (void) |
70 | { | 72 | { |
71 | fprintf(stderr, "Usage: docproc {doc|depend} file\n"); | 73 | fprintf(stderr, "Usage: docproc {doc|depend} file\n"); |
72 | fprintf(stderr, "Input is read from file.tmpl. Output is sent to stdout\n"); | 74 | fprintf(stderr, "Input is read from file.tmpl. Output is sent to stdout\n"); |
73 | fprintf(stderr, "doc: frontend when generating kernel documentation\n"); | 75 | fprintf(stderr, "doc: frontend when generating kernel documentation\n"); |
74 | fprintf(stderr, "depend: generate list of files referenced within file\n"); | 76 | fprintf(stderr, "depend: generate list of files referenced within file\n"); |
77 | fprintf(stderr, "Environment variable SRCTREE: absolute path to kernel source tree.\n"); | ||
75 | } | 78 | } |
76 | 79 | ||
77 | /* | 80 | /* |
@@ -90,7 +93,7 @@ void exec_kernel_doc(char **svec) | |||
90 | exit(1); | 93 | exit(1); |
91 | case 0: | 94 | case 0: |
92 | memset(real_filename, 0, sizeof(real_filename)); | 95 | memset(real_filename, 0, sizeof(real_filename)); |
93 | strncat(real_filename, getenv("SRCTREE"), PATH_MAX); | 96 | strncat(real_filename, srctree, PATH_MAX); |
94 | strncat(real_filename, KERNELDOCPATH KERNELDOC, | 97 | strncat(real_filename, KERNELDOCPATH KERNELDOC, |
95 | PATH_MAX - strlen(real_filename)); | 98 | PATH_MAX - strlen(real_filename)); |
96 | execvp(real_filename, svec); | 99 | execvp(real_filename, svec); |
@@ -171,7 +174,7 @@ void find_export_symbols(char * filename) | |||
171 | if (filename_exist(filename) == NULL) { | 174 | if (filename_exist(filename) == NULL) { |
172 | char real_filename[PATH_MAX + 1]; | 175 | char real_filename[PATH_MAX + 1]; |
173 | memset(real_filename, 0, sizeof(real_filename)); | 176 | memset(real_filename, 0, sizeof(real_filename)); |
174 | strncat(real_filename, getenv("SRCTREE"), PATH_MAX); | 177 | strncat(real_filename, srctree, PATH_MAX); |
175 | strncat(real_filename, filename, | 178 | strncat(real_filename, filename, |
176 | PATH_MAX - strlen(real_filename)); | 179 | PATH_MAX - strlen(real_filename)); |
177 | sym = add_new_file(filename); | 180 | sym = add_new_file(filename); |
@@ -338,6 +341,10 @@ void parse_file(FILE *infile) | |||
338 | int main(int argc, char *argv[]) | 341 | int main(int argc, char *argv[]) |
339 | { | 342 | { |
340 | FILE * infile; | 343 | FILE * infile; |
344 | |||
345 | srctree = getenv("SRCTREE"); | ||
346 | if (!srctree) | ||
347 | srctree = getcwd(NULL, 0); | ||
341 | if (argc != 3) { | 348 | if (argc != 3) { |
342 | usage(); | 349 | usage(); |
343 | exit(1); | 350 | exit(1); |