History

kbuild: stop docproc segfaulting when SRCTREE isn't set.

Prevent docproc from segfaulting when SRCTREE isn't set.

Rob Landley committed 19 years ago

Commit bb13be51 parent 4b219601 file · +9 −2Browse files

Showing the changes to scripts/basic (1 of 1 file). Show all

Unified · Split

scripts/basic/docproc.c+9−2
@@ -66,12 +66,15 @@ FILELINE * entity_system; · 65 unmodified lines
6666 #define FUNCTION "-function"
6767 #define NOFUNCTION "-nofunction"
6868
69+char *srctree;
70+
6971 void usage (void)
7072 {
7173 fprintf(stderr, "Usage: docproc {doc|depend} file\n");
7274 fprintf(stderr, "Input is read from file.tmpl. Output is sent to stdout\n");
7375 fprintf(stderr, "doc: frontend when generating kernel documentation\n");
7476 fprintf(stderr, "depend: generate list of files referenced within file\n");
77+ fprintf(stderr, "Environment variable SRCTREE: absolute path to kernel source tree.\n");
7578 }
7679
7780 /*
@@ -90,7 +93,7 @@ void exec_kernel_doc(char **svec) · 12 unmodified lines
9093 exit(1);
9194 case 0:
9295 memset(real_filename, 0, sizeof(real_filename));
93− strncat(real_filename, getenv("SRCTREE"), PATH_MAX);
96+ strncat(real_filename, srctree, PATH_MAX);
9497 strncat(real_filename, KERNELDOCPATH KERNELDOC,
9598 PATH_MAX - strlen(real_filename));
9699 execvp(real_filename, svec);
@@ -171,7 +174,7 @@ void find_export_symbols(char * filename) · 74 unmodified lines
171174 if (filename_exist(filename) == NULL) {
172175 char real_filename[PATH_MAX + 1];
173176 memset(real_filename, 0, sizeof(real_filename));
174− strncat(real_filename, getenv("SRCTREE"), PATH_MAX);
177+ strncat(real_filename, srctree, PATH_MAX);
175178 strncat(real_filename, filename,
176179 PATH_MAX - strlen(real_filename));
177180 sym = add_new_file(filename);
@@ -338,6 +341,10 @@ void parse_file(FILE *infile) · 160 unmodified lines
338341 int main(int argc, char *argv[])
339342 {
340343 FILE * infile;
344+
345+ srctree = getenv("SRCTREE");
346+ if (!srctree)
347+ srctree = getcwd(NULL, 0);
341348 if (argc != 3) {
342349 usage();
343350 exit(1);