From: Rusty Russell Date: Thu, 13 Nov 2008 11:54:08 +0000 (+1030) Subject: Fix examples (they all compile now), and init parent list in list X-Git-Url: https://git.ozlabs.org/?p=ccan;a=commitdiff_plain;h=49b125f3c4cab0240523c976e1d48493ae8644e6 Fix examples (they all compile now), and init parent list in list example. --- diff --git a/ccan/alignof/_info.c b/ccan/alignof/_info.c index 3b73f655..e647afbf 100644 --- a/ccan/alignof/_info.c +++ b/ccan/alignof/_info.c @@ -16,7 +16,8 @@ * * Example: * #include - * #include "alignof/alignof.h" + * #include + * #include * * int main(int argc, char *argv[]) * { diff --git a/ccan/alloc/_info.c b/ccan/alloc/_info.c index 61c00464..9b00284f 100644 --- a/ccan/alloc/_info.c +++ b/ccan/alloc/_info.c @@ -20,14 +20,17 @@ * #include * #include * #include - * #include "alloc/alloc.h" + * #include + * #include + * #include + * #include * * static void usage(const char *name) * { * errx(1, "Usage: %s --create \n" * " %s --check \n" * " %s --alloc \n" - * " %s --free= \n", name, name, name); + * " %s --free= \n", name, name, name, name); * } * * // Create a memory mapped file, and allocate from within it diff --git a/ccan/build_assert/_info.c b/ccan/build_assert/_info.c index b61aeee0..d2fe3d9c 100644 --- a/ccan/build_assert/_info.c +++ b/ccan/build_assert/_info.c @@ -18,6 +18,14 @@ * you would catch such changes in your code like so: * * Example: + * #include + * #include + * + * struct foo { + * char string[5]; + * int x; + * }; + * * char *foo_string(struct foo *foo) * { * // This trick requires that the string be first in the structure diff --git a/ccan/container_of/_info.c b/ccan/container_of/_info.c index 194fcaba..4c25c296 100644 --- a/ccan/container_of/_info.c +++ b/ccan/container_of/_info.c @@ -14,8 +14,14 @@ * callback. * * Example: - * struct info - * { + * #include + * #include + * + * struct timer { + * void *members; + * }; + * + * struct info { * int my_stuff; * struct timer timer; * }; @@ -31,7 +37,9 @@ * struct info info = { .my_stuff = 1 }; * * register_timer(&info.timer); - * ... + * // ... + * return 0; + * } * * Licence: LGPL (2 or any later version) */ diff --git a/ccan/grab_file/_info.c b/ccan/grab_file/_info.c index 4aac31ae..9a0249f1 100644 --- a/ccan/grab_file/_info.c +++ b/ccan/grab_file/_info.c @@ -8,10 +8,11 @@ * This contains simple functions for getting the contents of a file. * * Example: - * #include "grab_file/grab_file.h" * #include * #include * #include + * #include + * #include // For talloc_free() * * int main(int argc, char *argv[]) * { diff --git a/ccan/list/_info.c b/ccan/list/_info.c index 7061762f..003887c9 100644 --- a/ccan/list/_info.c +++ b/ccan/list/_info.c @@ -12,7 +12,9 @@ * * Example: * #include - * #include "list/list.h" + * #include + * #include + * #include * * struct parent { * const char *name; @@ -35,7 +37,8 @@ * errx(1, "Usage: %s parent children...", argv[0]); * * p.name = argv[1]; - * for (i = 2; i < argc, i++) { + * list_head_init(&p.children); + * for (i = 2; i < argc; i++) { * c = malloc(sizeof(*c)); * c->name = argv[i]; * list_add(&p.children, &c->list); diff --git a/ccan/noerr/_info.c b/ccan/noerr/_info.c index 32ced7d8..fee413d3 100644 --- a/ccan/noerr/_info.c +++ b/ccan/noerr/_info.c @@ -14,6 +14,10 @@ * #include * #include * #include + * #include + * #include + * #include + * #include * * bool write_string_to_file(const char *file, const char *string) * { diff --git a/ccan/str/_info.c b/ccan/str/_info.c index 4baea773..081e862d 100644 --- a/ccan/str/_info.c +++ b/ccan/str/_info.c @@ -9,7 +9,8 @@ * the standard string.h. * * Example: - * #include "str/str.h" + * #include + * #include * * int main(int argc, char *argv[]) * { diff --git a/ccan/str_talloc/_info.c b/ccan/str_talloc/_info.c index 3186b2ba..aaf9d996 100644 --- a/ccan/str_talloc/_info.c +++ b/ccan/str_talloc/_info.c @@ -10,9 +10,9 @@ * string utilities in "str.h". * * Example: - * #include "str_talloc/str_talloc.h" - * #include "talloc/talloc.h" - * #include "grab_file/grab_file.h" + * #include + * #include + * #include * #include * * // Dumb demo program to double-linespace a file. diff --git a/ccan/talloc/_info.c b/ccan/talloc/_info.c index 2a978801..95c91536 100644 --- a/ccan/talloc/_info.c +++ b/ccan/talloc/_info.c @@ -31,9 +31,9 @@ * #include * #include * #include - * #include "talloc/talloc.h" + * #include * - * // A structure containing a popened comman. + * // A structure containing a popened command. * struct command * { * FILE *f; @@ -79,7 +79,7 @@ * struct command *cmd; * * if (argc != 2) - * errx(1, "Usage: %s \n"); + * errx(1, "Usage: %s \n", argv[0]); * * cmd = open_output_cmd(NULL, "%s hello", argv[1]); * if (!cmd) diff --git a/ccan/tap/_info.c b/ccan/tap/_info.c index 2e628914..010f9896 100644 --- a/ccan/tap/_info.c +++ b/ccan/tap/_info.c @@ -20,7 +20,7 @@ * * Example: * #include - * #include "tap/tap.h" + * #include * * // Run some simple (but overly chatty) tests on strcmp(). * int main(int argc, char *argv[])