summaryrefslogtreecommitdiff
path: root/src/implicit.c
diff options
context:
space:
mode:
authorfergus.henderson <fergushenderson@users.noreply.github.com>2008-05-18 06:06:13 +0000
committerfergus.henderson <fergushenderson@users.noreply.github.com>2008-05-18 06:06:13 +0000
commit3a831a85a51a0ae7d03e310bd02882c02aeeaff5 (patch)
tree9b5650fae7bd78603535f9748d66415d684af263 /src/implicit.c
parenta212cf09a386a5327fbf497a136bca93370808c0 (diff)
downloaddistcc-git-3a831a85a51a0ae7d03e310bd02882c02aeeaff5.tar.gz
Fix bugs in my previous change to handle "-Wp," options: arguments
to str_startswith() were in the wrong order, and in one place I had wrongly passed 'argv' instead of 'new_argv'. Move the call to dcc_expand_preprocessor_options() from dcc_get_dotd_info() to gcc_build_somewhere(), so that it is pretty much the first thing done to argv. Not sure if this is really needed, but it seems like a good idea. Fix various memory management problems, including some introduced by moving the call to dcc_expand_preprocessor_options(). One problem was that dcc_find_compiler() was producing a result that was sometimes allocated with malloc() and sometimes not, so the caller couldn't safely deallocate it. I changed dcc_find_compiler to always return a dynamically allocated result. Fix some places where return values were being ignored. Also fix one place where distcc was inconsistenly calling exit() rather than returning a return code. Like my previous change, this one is necessary, but perhaps not sufficient, for building the Linux kernel with distcc-pump. Tested by "make valgrind-check", and by building and installing the debian package and the building Linux 2.6.25 in pump mode using the benchmark.py script. Reviewers
Diffstat (limited to 'src/implicit.c')
-rw-r--r--src/implicit.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/implicit.c b/src/implicit.c
index 8ed6f86..5e3785b 100644
--- a/src/implicit.c
+++ b/src/implicit.c
@@ -76,20 +76,29 @@
* We can tell there's no compiler name because argv[1] will be either
* a source filename or an object filename or an option. I don't
* think anything else is possible.
+ *
+ * Returns a dynamically allocated argv array in *out_argv.
+ * The caller is responsible for deallocating it.
**/
int dcc_find_compiler(char **argv, char ***out_argv)
{
+ int ret;
if (argv[1][0] == '-'
|| dcc_is_source(argv[1])
|| dcc_is_object(argv[1])) {
- dcc_copy_argv(argv, out_argv, 0);
+ if ((ret = dcc_copy_argv(argv, out_argv, 0)) != 0) {
+ return ret;
+ }
/* change "distcc -c foo.c" -> "cc -c foo.c" */
+ free((*out_argv)[0]);
(*out_argv)[0] = strdup("cc");
+ if ((*out_argv)[0] == NULL) {
+ return EXIT_OUT_OF_MEMORY;
+ }
return 0;
} else {
/* skip "distcc", point to "gcc -c foo.c" */
- *out_argv = argv+1;
- return 0;
+ return dcc_copy_argv(argv + 1, out_argv, 0);
}
}