X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=tools%2Fccanlint%2Ftests%2Freduce_features.c;h=183d798f7bd501b8b9eaed8e8ce9a58d52e43b69;hp=aaeba75170f78a7b33b60355f97292c7b7c61908;hb=758ab1f402b4af3cccac09548b709deca17ef930;hpb=6c1d3e2739e97674069862ec7369677d25e80312 diff --git a/tools/ccanlint/tests/reduce_features.c b/tools/ccanlint/tests/reduce_features.c index aaeba751..183d798f 100644 --- a/tools/ccanlint/tests/reduce_features.c +++ b/tools/ccanlint/tests/reduce_features.c @@ -40,7 +40,20 @@ static bool option_cmp(const char *name1, const char *name2) return streq(name1, name2); } -HTABLE_DEFINE_TYPE(char, option_name, option_hash, option_cmp, option); +HTABLE_DEFINE_TYPE(char, option_name, option_hash, option_cmp, htable_option); + +static struct htable_option *htable_option_new(void) +{ + struct htable_option *opts = malloc(sizeof(*opts)); + htable_option_init(opts); + return opts; +} + +static void htable_option_free(struct htable_option *opts) +{ + htable_option_clear(opts); + free(opts); +} static unsigned int add_options(struct htable_option *opts, struct pp_conditions *cond) @@ -160,11 +173,14 @@ static void do_reduce_features(struct manifest *m, hdr = talloc_asprintf_append (hdr, "#undef %s\n#define %s 0\n", sym, sym); } - fd = open("config.h", O_EXCL|O_CREAT|O_RDWR, 0600); + if (mkdir("reduced-features", 0700) != 0 && errno != EEXIST) + err(1, "Creating reduced-features directory"); + + fd = open("reduced-features/config.h", O_TRUNC|O_CREAT|O_RDWR, 0600); if (fd < 0) - err(1, "Creating config.h"); + err(1, "Creating reduced-features/config.h"); if (!write_all(fd, hdr, strlen(hdr))) - err(1, "Writing config.h"); + err(1, "Writing reduced-features/config.h"); close(fd); features_were_reduced = true; }