From: Rusty Russell Date: Tue, 30 Aug 2016 00:32:06 +0000 (+0930) Subject: Merge remote-tracking branch 'origin/pr/48' X-Git-Url: http://git.ozlabs.org/?p=ccan;a=commitdiff_plain;h=3750ffaa89f0d771990152e6c0894681dffc4850;hp=61aead95bb68f33d7f38998f0e8ff7c81141f99f Merge remote-tracking branch 'origin/pr/48' --- diff --git a/.travis.yml b/.travis.yml index 37bbd460..cbb0aebb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,5 +11,6 @@ addons: - libjudy-dev libvorbis-dev libportaudio-dev libtalloc-dev script: + - make config.h - make -j2 - make -j2 -k check diff --git a/ccan/base64/base64.c b/ccan/base64/base64.c index 5e75dd71..af078bc7 100644 --- a/ccan/base64/base64.c +++ b/ccan/base64/base64.c @@ -14,7 +14,6 @@ */ static char sixbit_to_b64(const base64_maps_t *maps, const uint8_t sixbit) { - assert(sixbit >= 0); assert(sixbit <= 63); return maps->encode_map[(unsigned char)sixbit]; diff --git a/ccan/ciniparser/ciniparser.c b/ccan/ciniparser/ciniparser.c index 2b60e409..527f8377 100644 --- a/ccan/ciniparser/ciniparser.c +++ b/ccan/ciniparser/ciniparser.c @@ -316,7 +316,7 @@ int ciniparser_getint(dictionary *d, const char *key, int notfound) return (int) strtol(str, NULL, 10); } -double ciniparser_getdouble(dictionary *d, char *key, double notfound) +double ciniparser_getdouble(dictionary *d, const char *key, double notfound) { char *str; diff --git a/ccan/ciniparser/ciniparser.h b/ccan/ciniparser/ciniparser.h index f61b3576..b61c1d6e 100644 --- a/ccan/ciniparser/ciniparser.h +++ b/ccan/ciniparser/ciniparser.h @@ -151,7 +151,7 @@ int ciniparser_getint(dictionary *d, const char *key, int notfound); * ini file is given as "section:key". If the key cannot be found, * the notfound value is returned. */ -double ciniparser_getdouble(dictionary *d, char *key, double notfound); +double ciniparser_getdouble(dictionary *d, const char *key, double notfound); /** * @brief Get the string associated to a key, convert to a boolean diff --git a/ccan/ciniparser/dictionary.c b/ccan/ciniparser/dictionary.c index 4b24fb04..19dd6411 100644 --- a/ccan/ciniparser/dictionary.c +++ b/ccan/ciniparser/dictionary.c @@ -72,7 +72,7 @@ static void *mem_double(void *ptr, int size) /* The remaining exposed functions are documented in dictionary.h */ -unsigned dictionary_hash(char *key) +unsigned dictionary_hash(const char *key) { int len; unsigned hash; @@ -126,7 +126,7 @@ void dictionary_del(dictionary *d) return; } -char *dictionary_get(dictionary *d, char *key, char *def) +char *dictionary_get(dictionary *d, const char *key, char *def) { unsigned hash; int i; @@ -146,7 +146,7 @@ char *dictionary_get(dictionary *d, char *key, char *def) return def; } -int dictionary_set(dictionary *d, char *key, char *val) +int dictionary_set(dictionary *d, const char *key, char *val) { int i; unsigned hash; @@ -206,7 +206,7 @@ int dictionary_set(dictionary *d, char *key, char *val) return 0; } -void dictionary_unset(dictionary *d, char *key) +void dictionary_unset(dictionary *d, const char *key) { unsigned hash; int i; diff --git a/ccan/ciniparser/dictionary.h b/ccan/ciniparser/dictionary.h index f831e39d..a94ea1a1 100644 --- a/ccan/ciniparser/dictionary.h +++ b/ccan/ciniparser/dictionary.h @@ -76,7 +76,7 @@ typedef struct _dictionary_ { * The key is stored anyway in the struct so that collision can be avoided * by comparing the key itself in last resort. */ -unsigned dictionary_hash(char *key); +unsigned dictionary_hash(const char *key); /** * @brief Create a new dictionary object. @@ -110,7 +110,7 @@ void dictionary_del(dictionary *vd); * dictionary. The returned character pointer points to data internal to the * dictionary object, you should not try to free it or modify it. */ -char *dictionary_get(dictionary *d, char *key, char *def); +char *dictionary_get(dictionary *d, const char *key, char *def); /** * @brief Set a value in a dictionary. @@ -136,7 +136,7 @@ char *dictionary_get(dictionary *d, char *key, char *def); * * This function returns non-zero in case of failure. */ -int dictionary_set(dictionary *vd, char *key, char *val); +int dictionary_set(dictionary *vd, const char *key, char *val); /** * @brief Delete a key in a dictionary @@ -147,7 +147,7 @@ int dictionary_set(dictionary *vd, char *key, char *val); * This function deletes a key in a dictionary. Nothing is done if the * key cannot be found. */ -void dictionary_unset(dictionary *d, char *key); +void dictionary_unset(dictionary *d, const char *key); /** * @brief Dump a dictionary to an opened file pointer. diff --git a/ccan/crypto/shachain/shachain.c b/ccan/crypto/shachain/shachain.c index 6cfb7244..c6bd37e8 100644 --- a/ccan/crypto/shachain/shachain.c +++ b/ccan/crypto/shachain/shachain.c @@ -12,12 +12,12 @@ static void change_bit(unsigned char *arr, size_t index) arr[index / CHAR_BIT] ^= (1 << (index % CHAR_BIT)); } -static int count_trailing_zeroes(shachain_index_t index) +static unsigned int count_trailing_zeroes(shachain_index_t index) { #if HAVE_BUILTIN_CTZLL - return index ? __builtin_ctzll(index) : INDEX_BITS; + return index ? (unsigned int)__builtin_ctzll(index) : INDEX_BITS; #else - int i; + unsigned int i; for (i = 0; i < INDEX_BITS; i++) { if (index & (1ULL << i)) @@ -77,7 +77,7 @@ void shachain_init(struct shachain *chain) bool shachain_add_hash(struct shachain *chain, shachain_index_t index, const struct sha256 *hash) { - int i, pos; + unsigned int i, pos; /* You have to insert them in order! */ assert(index == chain->min_index - 1 || @@ -107,7 +107,7 @@ bool shachain_add_hash(struct shachain *chain, bool shachain_get_hash(const struct shachain *chain, shachain_index_t index, struct sha256 *hash) { - int i; + unsigned int i; for (i = 0; i < chain->num_valid; i++) { /* If we can get from key to index only by resetting bits, diff --git a/ccan/generator/test/compile_fail-4.c b/ccan/generator/test/compile_fail-4.c index f7297cff..71218026 100644 --- a/ccan/generator/test/compile_fail-4.c +++ b/ccan/generator/test/compile_fail-4.c @@ -16,8 +16,8 @@ int main(int argc, char *argv[]) int val; #endif - generator_next_val(val, g); - printf("%d", val); + if (generator_next_val(val, g)) + printf("%d", val); exit(0); } diff --git a/ccan/pr_log/_info b/ccan/pr_log/_info index 7f4feb64..22ccdfc4 100644 --- a/ccan/pr_log/_info +++ b/ccan/pr_log/_info @@ -1,4 +1,5 @@ #include +#include #include "config.h" /** diff --git a/ccan/strmap/LICENSE b/ccan/strmap/LICENSE new file mode 120000 index 00000000..b7951dab --- /dev/null +++ b/ccan/strmap/LICENSE @@ -0,0 +1 @@ +../../licenses/CC0 \ No newline at end of file diff --git a/ccan/tal/tal.h b/ccan/tal/tal.h index 0cfea984..f360a961 100644 --- a/ccan/tal/tal.h +++ b/ccan/tal/tal.h @@ -256,7 +256,7 @@ const char *tal_name(const tal_t *ptr); * tal_count - get the count of objects in a tal_arr. * @ptr: The tal allocated object array. * - * Returns 0 if @ptr has no length property, but we aware that that is + * Returns 0 if @ptr has no length property, but be aware that that is * also a valid size! */ size_t tal_count(const tal_t *ptr); diff --git a/ccan/tlist/_info b/ccan/tlist/_info index e6b16ef0..4c3394c9 100644 --- a/ccan/tlist/_info +++ b/ccan/tlist/_info @@ -22,8 +22,8 @@ * }; * struct parent { * const char *name; - * struct tlist_children children; * unsigned int num_children; + * struct tlist_children children; * }; * * struct child { diff --git a/ccan/tlist/test/run.c b/ccan/tlist/test/run.c index 06732cc3..d36cd8bc 100644 --- a/ccan/tlist/test/run.c +++ b/ccan/tlist/test/run.c @@ -6,8 +6,8 @@ TLIST_TYPE(children, struct child); struct parent { const char *name; - struct tlist_children children; unsigned int num_children; + struct tlist_children children; }; struct child { diff --git a/ccan/tlist/tlist.h b/ccan/tlist/tlist.h index 28978514..a99191a2 100644 --- a/ccan/tlist/tlist.h +++ b/ccan/tlist/tlist.h @@ -11,15 +11,16 @@ * * This declares a structure "struct tlist_@suffix" to use for * lists containing this type. The actual list can be accessed using - * ".raw" or tlist_raw(). + * ".raw" or tlist_raw(). For maximum portability, place tlists + * embedded in structures as the last member. * * Example: * // Defines struct tlist_children * TLIST_TYPE(children, struct child); * struct parent { * const char *name; - * struct tlist_children children; * unsigned int num_children; + * struct tlist_children children; * }; * * struct child { diff --git a/tools/ccan_depends.c b/tools/ccan_depends.c index a487e09b..f81a42b8 100644 --- a/tools/ccan_depends.c +++ b/tools/ccan_depends.c @@ -46,8 +46,9 @@ int main(int argc, char *argv[]) else deps = get_safe_ccan_deps(NULL, argv[1], style, recurse); - for (i = 0; deps[i]; i++) - if (strstarts(deps[i], "ccan/") == ccan) - printf("%s\n", deps[i]); + if (deps) + for (i = 0; deps[i]; i++) + if (strstarts(deps[i], "ccan/") == ccan) + printf("%s\n", deps[i]); return 0; } diff --git a/tools/configurator/configurator.c b/tools/configurator/configurator.c index 5d959cf3..67dadc61 100644 --- a/tools/configurator/configurator.c +++ b/tools/configurator/configurator.c @@ -330,7 +330,7 @@ static struct test tests[] = { " setcontext(&b);\n" " x |= 4;\n" "}\n" - "int main(int argc, char *argv[]) {\n" + "int main(void) {\n" " x |= 1;\n" " getcontext(&a);\n" " a.uc_stack.ss_sp = stack;\n" @@ -354,7 +354,7 @@ static struct test tests[] = { " worked = 1;\n" " setcontext(&b);\n" "}\n" - "int main(int argc, char *argv[]) {\n" + "int main(void) {\n" " void *ap = &worked;\n" " void *aq = (void *)(~((ptrdiff_t)ap));\n" " getcontext(&a);\n" diff --git a/tools/manifest.c b/tools/manifest.c index d3245ca5..3494937a 100644 --- a/tools/manifest.c +++ b/tools/manifest.c @@ -167,7 +167,7 @@ static void add_files(struct manifest *m, const char *base, const char *subdir) if (!m->info_file && list_empty(&m->c_files) && list_empty(&m->h_files)) - errx(1, "No _info, C or H files found here!"); + errx(1, "No _info, C or H files found in %s", thisdir); /* Don't enter subdirs with _info: they're separate modules. */ for (i = 0; i < tal_count(subs); i++) {