ccan
9 years agoopt: correct description, and neaten main header order.
Rusty Russell [Tue, 18 Jan 2011 07:21:51 +0000 (17:51 +1030)]
opt: correct description, and neaten main header order.

Reordering header makes it more readable, and we don't rely on
getopt_long any more.

9 years agoccanlint: fix _info option handling
Rusty Russell [Tue, 18 Jan 2011 01:47:17 +0000 (12:17 +1030)]
ccanlint: fix _info option handling

Two places were using a bogus ccanlint struct: the side-effect was
that valgrind options didn't work, nor did license fixups.

Make REGISTER_TEST do the extern declaration, and remove the bogus
ones.

9 years agostrsplit: remove nump argument
Rusty Russell [Tue, 18 Jan 2011 00:44:46 +0000 (11:14 +1030)]
strsplit: remove nump argument

You can use talloc_array_length() to get the length of a tallocated array.

9 years agotalloc: talloc_array_length()
Rusty Russell [Tue, 18 Jan 2011 00:36:23 +0000 (11:06 +1030)]
talloc: talloc_array_length()

I originally called this talloc_length(), but SAMBA upstream uses
talloc_array_length.

9 years agoccanlint: -k all
Rusty Russell [Sun, 9 Jan 2011 02:50:14 +0000 (13:20 +1030)]
ccanlint: -k all

Use this to preserve the entire working directory.

9 years agoccanlint: -k should not pollute module directory.
Rusty Russell [Sun, 9 Jan 2011 02:49:15 +0000 (13:19 +1030)]
ccanlint: -k should not pollute module directory.

It leads to numerous problems, such as the next ccanlint getting confused
trying to compile examples, and "-k examples_compile -k examples_exist"
giving bogus errors.

So instead we leave the temporary dir lying around and delete
individual files which aren't marked "keep".

9 years agofailtest: free up everything on exit.
Rusty Russell [Tue, 18 Jan 2011 00:35:37 +0000 (11:05 +1030)]
failtest: free up everything on exit.

Otherwise valgrind will report that tests leak memory.

9 years agofailtest: failtest_restore.h as an antidote to function overload.
Rusty Russell [Tue, 18 Jan 2011 00:38:34 +0000 (11:08 +1030)]
failtest: failtest_restore.h as an antidote to function overload.

This makes some cases simpler, where you no longer want malloc etc.
to fail.

9 years agowwviaudio: spelling fix
Brad Hards [Sun, 16 Jan 2011 06:50:51 +0000 (17:50 +1100)]
wwviaudio: spelling fix

9 years agotdb2: spelling fix
Brad Hards [Sun, 16 Jan 2011 06:50:24 +0000 (17:50 +1100)]
tdb2: spelling fix

9 years agotdb: spelling fixes
Brad Hards [Sun, 16 Jan 2011 06:50:03 +0000 (17:50 +1100)]
tdb: spelling fixes

9 years agotap: spelling fix
Brad Hards [Sun, 16 Jan 2011 06:49:20 +0000 (17:49 +1100)]
tap: spelling fix

9 years agotalloc: spelling fix.
Brad Hards [Sun, 16 Jan 2011 06:48:53 +0000 (17:48 +1100)]
talloc: spelling fix.

9 years agorbtree: spelling fixes
Brad Hards [Sun, 16 Jan 2011 06:48:20 +0000 (17:48 +1100)]
rbtree: spelling fixes

9 years agoopt: spelling fixes.
Brad Hards [Sun, 16 Jan 2011 06:22:39 +0000 (17:22 +1100)]
opt: spelling fixes.

9 years agonfs: spelling fixes.
Brad Hards [Sun, 16 Jan 2011 06:22:14 +0000 (17:22 +1100)]
nfs: spelling fixes.

9 years agolist: spelling fixes
Brad Hards [Sun, 16 Jan 2011 06:21:39 +0000 (17:21 +1100)]
list: spelling fixes

9 years agoiscsi: spelling fixes.
Brad Hards [Sun, 16 Jan 2011 06:21:12 +0000 (17:21 +1100)]
iscsi: spelling fixes.

9 years agohash: spelling fix
Brad Hards [Sun, 16 Jan 2011 06:19:51 +0000 (17:19 +1100)]
hash: spelling fix

9 years agobtree: spelling fix
Brad Hards [Sun, 16 Jan 2011 06:19:12 +0000 (17:19 +1100)]
btree: spelling fix

9 years agociniparser: spelling fixes
Brad Hards [Sun, 16 Jan 2011 06:17:36 +0000 (17:17 +1100)]
ciniparser: spelling fixes

9 years agojunkcode: spelling fixes.
Brad Hards [Sun, 16 Jan 2011 06:16:46 +0000 (17:16 +1100)]
junkcode: spelling fixes.

9 years agoarray: spelling fixes.
Brad Hards [Sun, 16 Jan 2011 06:15:32 +0000 (17:15 +1100)]
array: spelling fixes.

9 years agostr: change example to match function being explained.
Brad Hards [Sun, 16 Jan 2011 05:22:46 +0000 (16:22 +1100)]
str: change example to match function being explained.

Looks like the example was copy-n-pasted from the previous entry.

9 years agoccanlint: check examples actually mention thing they are demonstrating.
Rusty Russell [Mon, 17 Jan 2011 05:50:15 +0000 (16:20 +1030)]
ccanlint: check examples actually mention thing they are demonstrating.

Brad suggested this after finding one such cut & paste in str:

rusty@vivaldi:~/devel/cvs/ccan/ccan/str$ ../../tools/ccanlint/ccanlint
Example: sections demonstrate appropriate function (examples_relevant): FAIL
/home/rusty/devel/cvs/ccan/ccan/str/str.h:64:Example for strcount doesn't mention it
Total score: 37/38

9 years agoccanlint: fix trailing / in -d.
Rusty Russell [Mon, 17 Jan 2011 05:49:13 +0000 (16:19 +1030)]
ccanlint: fix trailing / in -d.

Before:
$ tools/ccanlint/ccanlint -d ccan/talloc/
Module's source code has no trailing whitespace (no_trailing_whitespace): FAIL
: Total score: 0/1

After:
$ tools/ccanlint/ccanlint -d ccan/talloc/
Module's source code has no trailing whitespace (no_trailing_whitespace): FAIL
talloc: Total score: 0/1

9 years agoccanlint: score_file_error() takes printf-format
Rusty Russell [Mon, 17 Jan 2011 05:47:49 +0000 (16:17 +1030)]
ccanlint: score_file_error() takes printf-format

We simply build up the error string in score_file_error; a bit different
but simpler than current behaviour.  We keep around struct file_error
because some tests need it.

9 years agoccanlint: fix score for info_summary_single_line
Rusty Russell [Mon, 17 Jan 2011 05:34:42 +0000 (16:04 +1030)]
ccanlint: fix score for info_summary_single_line

My refactoring introduced a bug: we need to set score=1 for the success case.

9 years agociniparser: Separate summary line and description text for metadata
Brad Hards [Mon, 17 Jan 2011 03:02:36 +0000 (13:32 +1030)]
ciniparser: Separate summary line and description text for metadata

9 years agoblock_pool: Change metadata layout so initial description is all on one line.
Brad Hards [Mon, 17 Jan 2011 03:02:36 +0000 (13:32 +1030)]
block_pool: Change metadata layout so initial description is all on one line.

With the original layout, we got:
Summary:
An efficient allocator for blocks that don't need to be
....
Description:
resized or freed.

9 years agoccanlint: neaten info_summary_single_line with new doc_section info.
Rusty Russell [Mon, 17 Jan 2011 03:52:29 +0000 (14:22 +1030)]
ccanlint: neaten info_summary_single_line with new doc_section info.

9 years agoccanlint: keep mapping back to original source line for doc_extract
Rusty Russell [Mon, 17 Jan 2011 03:44:43 +0000 (14:14 +1030)]
ccanlint: keep mapping back to original source line for doc_extract

Makes reporting of documentation easier.

9 years agoccanlint: add test case for metadata summary line on a single separate line.
Brad Hards [Mon, 17 Jan 2011 03:02:36 +0000 (13:32 +1030)]
ccanlint: add test case for metadata summary line on a single separate line.

9 years agohtable: fix type of cmpfn in htable_type
Rusty Russell [Thu, 13 Jan 2011 08:55:01 +0000 (19:25 +1030)]
htable: fix type of cmpfn in htable_type

It in fact takes an object and a key to compare, not two keys.

The test case had the key as first element of the object, so it worked,
but ccanlint lost track of module dependencies due to this bug, and thus
would build submodules multiple times.

9 years agorbtree: fix allocation failre paths.
Rusty Russell [Mon, 10 Jan 2011 05:55:22 +0000 (16:25 +1030)]
rbtree: fix allocation failre paths.

9 years agorbtree: don't use temporary context to destroy rbtree
Rusty Russell [Mon, 10 Jan 2011 05:17:24 +0000 (15:47 +1030)]
rbtree: don't use temporary context to destroy rbtree

It leads to a memory leak if the allocation fails (as we reparent onto NULL).
Also, the extra allocation in the failure path increases test time for
failtest (under valgrind) by a factor of 2.

9 years agorbtree: use failtest to check handling of allocation failures.
Rusty Russell [Mon, 10 Jan 2011 05:53:46 +0000 (16:23 +1030)]
rbtree: use failtest to check handling of allocation failures.

Unfortunately this means we have to reduce run-many from 1000 nodes to 100
(as forking under valgrind is really slow: test takes about 2 minutes with
100 nodes).

9 years agorbtree: fix memory leak in tests
Rusty Russell [Mon, 10 Jan 2011 05:51:24 +0000 (16:21 +1030)]
rbtree: fix memory leak in tests

The data is not made a child of the tree: the nodes are made children of the
data.  So we must explicitly free the data objects.

9 years agorbtree: vary insert and delete orders in test
Rusty Russell [Mon, 10 Jan 2011 05:55:48 +0000 (16:25 +1030)]
rbtree: vary insert and delete orders in test

This covers more code than simply doing an ordered delete/insert.

9 years agotalloc: allow replacement allocator
Rusty Russell [Mon, 10 Jan 2011 03:36:40 +0000 (14:06 +1030)]
talloc: allow replacement allocator

This allows us to both allocators which handle failure themselves, and
allocators which insert failures.

9 years agotalloc: fixed a use after free error
Rusty Russell [Mon, 10 Jan 2011 05:32:03 +0000 (16:02 +1030)]
talloc: fixed a use after free error

(Import from SAMBA commit 6f51a1f45bf4de062cce7a562477e8140630a53d):

this is the minimal fix for the problem Rusty found. I previously
thought that the best fix would be to change tc->parent to be valid
for all pointers, but that is expensive for realloc with large numbers
of child pointers, which is much more commmon than I expected it to
be.

9 years agotalloc: use failtest to test failure paths.
Rusty Russell [Mon, 10 Jan 2011 03:31:47 +0000 (14:01 +1030)]
talloc: use failtest to test failure paths.

9 years agofailtest: new module.
Rusty Russell [Mon, 10 Jan 2011 04:12:38 +0000 (14:42 +1030)]
failtest: new module.

A module designed to help test "never fails" functions like malloc.

9 years agotap: add fail callback
Rusty Russell [Mon, 10 Jan 2011 05:30:48 +0000 (16:00 +1030)]
tap: add fail callback

This is useful for failtest, so we can abort on first failure.

9 years agoccanlint: fix and simplify depends-accurate (with strreg)
Rusty Russell [Sun, 9 Jan 2011 01:26:41 +0000 (11:56 +1030)]
ccanlint: fix and simplify depends-accurate (with strreg)

9 years agoccanlint: fix total score for running examples
Rusty Russell [Sat, 8 Jan 2011 09:39:25 +0000 (20:09 +1030)]
ccanlint: fix total score for running examples

Don't count examples which didn't compile (expected, as we mangle them in
various different ways).

9 years agoccanlint: fix uninitialized variable
Rusty Russell [Sat, 8 Jan 2011 10:13:59 +0000 (20:43 +1030)]
ccanlint: fix uninitialized variable

9 years agoccanlint: use strreg for section extraction.
Rusty Russell [Sat, 8 Jan 2011 08:07:19 +0000 (18:37 +1030)]
ccanlint: use strreg for section extraction.

Makes it simpler and clearer.

9 years agoMakefile: append git revision to "make scores"
Rusty Russell [Sat, 8 Jan 2011 08:06:56 +0000 (18:36 +1030)]
Makefile: append git revision to "make scores"

Good for testing ccanlint changes.

9 years agostr_talloc: strreg
Rusty Russell [Sat, 8 Jan 2011 02:45:35 +0000 (13:15 +1030)]
str_talloc: strreg

Useful wrapper for extended POSIX regular expressions.

9 years agostr: strcount
Rusty Russell [Fri, 7 Jan 2011 23:47:37 +0000 (10:17 +1030)]
str: strcount

Useful routine to count number of matches in a string.

9 years agostr: clean up tests so ccanlint doesn't complain about memory leaking.
Rusty Russell [Thu, 6 Jan 2011 03:50:26 +0000 (14:20 +1030)]
str: clean up tests so ccanlint doesn't complain about memory leaking.

9 years agoccanlint: use positive description for test_pass_valgrind_noleaks
Rusty Russell [Fri, 7 Jan 2011 11:51:29 +0000 (22:21 +1030)]
ccanlint: use positive description for test_pass_valgrind_noleaks

A bit more awkward, but more consistent with everything else.

9 years agoccanlint: print keys in output
Rusty Russell [Fri, 7 Jan 2011 11:50:44 +0000 (22:20 +1030)]
ccanlint: print keys in output

Since test keys are used for --target=, this is useful.

9 years agoccanlint: rename files to match keys
Rusty Russell [Fri, 7 Jan 2011 11:50:13 +0000 (22:20 +1030)]
ccanlint: rename files to match keys

9 years agoccanlint: rename structures to match keys
Rusty Russell [Fri, 7 Jan 2011 11:50:04 +0000 (22:20 +1030)]
ccanlint: rename structures to match keys

9 years agoccanlint: list dependencies by key
Rusty Russell [Fri, 7 Jan 2011 11:49:49 +0000 (22:19 +1030)]
ccanlint: list dependencies by key

Joey Adams also pointed out that we should use strings for the dependency
lists.  Moving them into the structure also somewhat simplifies it.

9 years agoccanlint: rename test keys
Rusty Russell [Fri, 7 Jan 2011 11:48:41 +0000 (22:18 +1030)]
ccanlint: rename test keys

Joey Adams rightly points out that the current keys are a mess: ideally the
filenames, test keys and structure names in ccanlint should be the same.

First step is to make the test names all regular, of basic form <noun>_<verb>
(eg "tests_exist" rather than "has-tests").

9 years agoAdd scores/ directory to .gitignore.
Rusty Russell [Fri, 7 Jan 2011 02:52:43 +0000 (13:22 +1030)]
Add scores/ directory to .gitignore.

9 years agoccanlint: added --test-dep-graph option
Joey Adams [Thu, 6 Jan 2011 20:35:51 +0000 (15:35 -0500)]
ccanlint: added --test-dep-graph option

This option prints the dependency graph of ccanlint's tests
in Graphviz .dot format.

Sample usage:

ccanlint --test-dep-graph | dot -Tpng > out.png && eog out.png

9 years agoccanlint: fix segfault caused by tests not depending on the "info" test.
Joey Adams [Thu, 6 Jan 2011 20:12:18 +0000 (15:12 -0500)]
ccanlint: fix segfault caused by tests not depending on the "info" test.

These tests:

"depends-exist"      (compulsory_tests/check_depends_exist.c)
"info-documentation" (tests/has_info_documentation.c)

used m->info_file without checking if it was NULL,
leading to a segfault when no _info file was present.

Some other tests also used m->info_file without depending on "info",
but are taken care of indirectly by this patch.

9 years agoopt: Fix warnings with gcc-4.5 (same approach as commit 6535bde)
Joey Adams [Thu, 6 Jan 2011 15:50:04 +0000 (10:50 -0500)]
opt: Fix warnings with gcc-4.5 (same approach as commit 6535bde)

&*ptr is used in some other macros, but at a glance, they look like
cases where the pointer shouldn't be NULL .  Didn't change those,
and if we get more warnings, we'll cross that bridge when we get to it.
For now, I suppose they are just free NULL checks.

9 years agodaemonize: set stderr to /dev/null.
Rusty Russell [Thu, 6 Jan 2011 01:54:05 +0000 (12:24 +1030)]
daemonize: set stderr to /dev/null.

9 years agodaemonize: make valgrind happy.
Rusty Russell [Thu, 6 Jan 2011 01:45:03 +0000 (12:15 +1030)]
daemonize: make valgrind happy.

9 years agodaemonize: use BSD-MIT as License: string in _info
Rusty Russell [Thu, 6 Jan 2011 01:37:37 +0000 (12:07 +1030)]
daemonize: use BSD-MIT as License: string in _info

The parenthesized thing is confusing and ccanlint dislikes it.

9 years agoccanlint: allow BSD-MIT for MIT license.
Rusty Russell [Thu, 6 Jan 2011 01:37:05 +0000 (12:07 +1030)]
ccanlint: allow BSD-MIT for MIT license.

There are a large number of BSD variants out there, be explicit.

9 years agoccanlint: fix parsing bug which believes lines starting with - are a section header.
Rusty Russell [Thu, 6 Jan 2011 00:56:47 +0000 (11:26 +1030)]
ccanlint: fix parsing bug which believes lines starting with - are a section header.

9 years agoccanlint: have valgrind fail with an error, always
Rusty Russell [Tue, 4 Jan 2011 10:41:47 +0000 (21:11 +1030)]
ccanlint: have valgrind fail with an error, always

The upcoming failtest module can only tell that a child failed when it
exits with a non-zero error.  So we need this, although it means for ccanlint
it still needs to look at output to distinguish a memory leak from a real
error.

9 years agoccanlint: compile modules required by examples.
Rusty Russell [Tue, 4 Jan 2011 10:41:47 +0000 (21:11 +1030)]
ccanlint: compile modules required by examples.

If an example #includes <ccan/foo/...> we assume it needs module foo,
but we would fail instead of building it if it isn't built.

9 years agoccanlint: make get_manifest cache manifests
Rusty Russell [Tue, 4 Jan 2011 10:41:47 +0000 (21:11 +1030)]
ccanlint: make get_manifest cache manifests

As we start doing more building of dependencies, this saves us effort.

9 years agocompiler: NORETURN
Rusty Russell [Tue, 4 Jan 2011 10:42:41 +0000 (21:12 +1030)]
compiler: NORETURN

9 years agotlist: typesafe variant of list module.
Rusty Russell [Sat, 1 Jan 2011 06:44:05 +0000 (17:14 +1030)]
tlist: typesafe variant of list module.

I chose not to do the "macro creates set of routines" approach, as
we can be almost as safe with a struct containing a pointer to the member
type.

9 years agolist: LIST_HEAD_INIT
Rusty Russell [Sat, 1 Jan 2011 06:43:04 +0000 (17:13 +1030)]
list: LIST_HEAD_INIT

I find hiding the declaration in LIST_HEAD() a bit weird.

9 years agolist: improve test coverage to 100%
Rusty Russell [Sat, 1 Jan 2011 06:42:40 +0000 (17:12 +1030)]
list: improve test coverage to 100%

In particular, we test the corruption cases.

9 years agolist: list_del_from()
Rusty Russell [Sat, 1 Jan 2011 06:41:15 +0000 (17:11 +1030)]
list: list_del_from()

Deletion from a specific list.

9 years agolist: test CCAN_LIST_DEBUG=1 case
Rusty Russell [Sat, 1 Jan 2011 06:45:10 +0000 (17:15 +1030)]
list: test CCAN_LIST_DEBUG=1 case

9 years agolist: rename debug_list to list_debug, use list_check_node in list_del
Rusty Russell [Sat, 1 Jan 2011 06:40:54 +0000 (17:10 +1030)]
list: rename debug_list to list_debug, use list_check_node in list_del

When CCAN_LIST_DEBUG was defined, we were previously calling
list_check() in list_del instead of list_check_node(), which caused a
warning.

We also should stick within the "list_" prefix namespace, so rename
"debug_list" to "list_debug".

9 years agolist: implement list_check_node to check list from node rather than head
Rusty Russell [Sat, 1 Jan 2011 06:38:58 +0000 (17:08 +1030)]
list: implement list_check_node to check list from node rather than head

9 years agoconfig.h: HAVE_FLEXIBLE_ARRAY_MEMBER
Rusty Russell [Sat, 1 Jan 2011 06:45:41 +0000 (17:15 +1030)]
config.h: HAVE_FLEXIBLE_ARRAY_MEMBER

9 years agoccanlint: give a bonus for 100% code coverage
Rusty Russell [Sat, 1 Jan 2011 06:42:00 +0000 (17:12 +1030)]
ccanlint: give a bonus for 100% code coverage

9 years agotdb: add test for tdb_summary
Rusty Russell [Thu, 23 Dec 2010 02:35:55 +0000 (13:05 +1030)]
tdb: add test for tdb_summary

9 years agotdb: remove tally dependency
Rusty Russell [Thu, 23 Dec 2010 02:14:48 +0000 (12:44 +1030)]
tdb: remove tally dependency

We lose the histograms, but this prepares it for upstream merge.

9 years agotdb: fix uncoalesced record count in tdb_summary.
Rusty Russell [Thu, 23 Dec 2010 02:14:25 +0000 (12:44 +1030)]
tdb: fix uncoalesced record count in tdb_summary.

One free record is not "uncoalesced".

9 years agotdb: combine dead_space helper from summary.c and check.c
Rusty Russell [Thu, 23 Dec 2010 02:13:54 +0000 (12:43 +1030)]
tdb: combine dead_space helper from summary.c and check.c

Remove code duplication, and allow unit tests (which #include both).

9 years agotypesafe_cb: Fix warnings with gcc-4.5:
Rusty Russell [Thu, 16 Dec 2010 05:33:41 +0000 (16:03 +1030)]
typesafe_cb: Fix warnings with gcc-4.5:

Test compiled with warnings:
/home/rusty/devel/cvs/ccan/ccan/typesafe_cb/test/compile_ok-typesafe_cb-NULL.c:/home/rusty/devel/cvs/ccan/ccan/typesafe_cb/test/compile_ok-typesafe_cb-NULL.c: In function ‘main’:
/home/rusty/devel/cvs/ccan/ccan/typesafe_cb/test/compile_ok-typesafe_cb-NULL.c:18:2: warning: taking address of expression of type ‘void’
/home/rusty/devel/cvs/ccan/ccan/typesafe_cb/test/compile_ok-typesafe_cb-NULL.c:18:2: warning: taking address of expression of type ‘void’
/home/rusty/devel/cvs/ccan/ccan/typesafe_cb/test/compile_ok-typesafe_cb-NULL.c:18:2: warning: taking address of expression of type ‘void’
/home/rusty/devel/cvs/ccan/ccan/typesafe_cb/test/compile_ok-typesafe_cb-NULL.c:18:2: warning: taking address of expression of type ‘void’
/home/rusty/devel/cvs/ccan/ccan/typesafe_cb/test/compile_ok-typesafe_cb-NULL.c:18:2: warning: taking address of expression of type ‘void’
/home/rusty/devel/cvs/ccan/ccan/typesafe_cb/test/compile_ok-typesafe_cb-NULL.c:18:2: warning: taking address of expression of type ‘void’
/home/rusty/devel/cvs/ccan/ccan/typesafe_cb/test/compile_ok-typesafe_cb-NULL.c:18:2: warning: taking address of expression of type ‘void’
/home/rusty/devel/cvs/ccan/ccan/typesafe_cb/test/compile_ok-typesafe_cb-NULL.c:19:2: warning: taking address of expression of type ‘void’

9 years agoccanlint: use valgrind options when debugging too
Rusty Russell [Mon, 13 Dec 2010 08:15:24 +0000 (18:45 +1030)]
ccanlint: use valgrind options when debugging too

If they specify valgrind options in their _info, we should use them when
running with --db-attach=yes, too.

9 years agoccanlint: report valgrind "definite" leaks.
Rusty Russell [Mon, 13 Dec 2010 08:15:25 +0000 (18:45 +1030)]
ccanlint: report valgrind "definite" leaks.

This is complicated by valgrind's limited options, and our desire not to run
valgrind twice (it's already the slowest part of the tests).

Ideally I'd like a different error code for each kind of error.  I
could parse and pretty-print the XML output, but instead I just parse
the human-readable (which is fragile).

9 years agoccanlint: fix bogus strerror printing when unknown test handed to --target
Rusty Russell [Mon, 13 Dec 2010 08:15:25 +0000 (18:45 +1030)]
ccanlint: fix bogus strerror printing when unknown test handed to --target

9 years agoccanlint: fix error with --target=build
Rusty Russell [Mon, 13 Dec 2010 08:23:14 +0000 (18:53 +1030)]
ccanlint: fix error with --target=build

It requires that we build the objects first.

9 years agorbtree: remove unused variable in tests.
Rusty Russell [Wed, 8 Dec 2010 02:05:46 +0000 (12:35 +1030)]
rbtree: remove unused variable in tests.

9 years agorb_tree: fix trbt_delete
Ronnie Sahlberg [Wed, 8 Dec 2010 01:00:35 +0000 (12:00 +1100)]
rb_tree: fix trbt_delete

trbt_delete32() was broken and caused SEGV as soon as you tried to
delete an object from a tree.

Rework trbt_delete32() to instead just call talloc_free() instread of trying
to call delete_node() directly.
This makes the "from_destructor" argument to delete_node() redundant
so that parameter is removed too.

Signed-off-by: Ronnie Sahlberg <sahlberg@lenovo-laptop.(none)>
9 years agoconfigurator: warnings count as failures too.
Rusty Russell [Wed, 8 Dec 2010 00:44:21 +0000 (11:14 +1030)]
configurator: warnings count as failures too.

Unfortunately, gcc only warns if it sees an unknown attribute (in this case, gcc 4.1 vs "cold").

9 years agoccanlint: fix compile on x86-64
Rusty Russell [Wed, 8 Dec 2010 00:34:03 +0000 (11:04 +1030)]
ccanlint: fix compile on x86-64

cc -g -Wall -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -I. -MD -Werror   -c -o tools/ccanlint/tests/examples_run.o tools/ccanlint/tests/examples_run.c
cc1: warnings being treated as errors
tools/ccanlint/tests/examples_run.c: In function ‘scan_forv’:
tools/ccanlint/tests/examples_run.c:37: warning: passing argument 2 of ‘__builtin_va_copy’ discards qualifiers from pointer target type
tools/ccanlint/tests/examples_run.c:43: warning: passing argument 4 of ‘scan_forv’ from incompatible pointer type
tools/ccanlint/tests/examples_run.c:52: warning: passing argument 4 of ‘scan_forv’ from incompatible pointer type
tools/ccanlint/tests/examples_run.c:60: warning: passing argument 4 of ‘scan_forv’ from incompatible pointer type
tools/ccanlint/tests/examples_run.c: In function ‘scan_for’:
tools/ccanlint/tests/examples_run.c:78: warning: passing argument 4 of ‘scan_forv’ from incompatible pointer type
make: *** [tools/ccanlint/tests/examples_run.o] Error 1

It really doesn't like constifying a va_arg, so remove the const declaration.

9 years agorbtree: add tests (which currently fail)
Rusty Russell [Tue, 7 Dec 2010 05:19:08 +0000 (15:49 +1030)]
rbtree: add tests (which currently fail)

9 years agoidtree: fix overflow for v. large ids on allocation and removal
Rusty Russell [Mon, 6 Dec 2010 03:12:13 +0000 (13:42 +1030)]
idtree: fix overflow for v. large ids on allocation and removal

Chris Cowan tracked down a SEGV in sub_alloc: idp->level can actually
be equal to 7 (MAX_LEVEL) there, as it can be in sub_remove.

9 years agoidtree: fix right shift of signed ints
Rusty Russell [Mon, 6 Dec 2010 03:12:00 +0000 (13:42 +1030)]
idtree: fix right shift of signed ints

(Imported from SAMBA commit 2db1987f5a3a)

Right-shifting signed integers in undefined; indeed it seems that on
AIX with their compiler, doing a 30-bit shift on (INT_MAX-200) gives
0, not 1 as we might expect (THIS WAS WRONG, REAL FIX LATER).

The obvious fix is to make id and oid unsigned: l (level count) is also
logically unsigned.

(Note: Samba doesn't generally get to ids > 1 billion, but ctdb does)

Reported-by: Chris Cowan <cc@us.ibm.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years agoidtree: import fix from SAMBA source
Rusty Russell [Mon, 6 Dec 2010 03:00:59 +0000 (13:30 +1030)]
idtree: import fix from SAMBA source

(Imported from b53f8c187de8)

Author: Rusty Russell <rusty@rustorp.com.au>
Date:   Thu Jun 10 13:27:51 2010 -0700

Since idtree assigns sequentially, it rarely reaches high numbers.
But such numbers can be forced with idr_get_new_above(), and that
reveals two bugs:

1) Crash in sub_remove() caused by pa array being too short.
2) Shift by more than 32 in _idr_find(), which is undefined, causing
   the "outside the current tree" optimization to misfire and return NULL.

9 years agoidtree: add unit test for ids around INT_MAX
Rusty Russell [Mon, 6 Dec 2010 02:22:19 +0000 (12:52 +1030)]
idtree: add unit test for ids around INT_MAX

This causes a SEGV on my laptop.

9 years agoccanlint: ignore comments when parsing examples.
Rusty Russell [Mon, 6 Dec 2010 02:21:40 +0000 (12:51 +1030)]
ccanlint: ignore comments when parsing examples.

We insert comments when we massage or combine examples; don't let these
throw off our analysis (as happened for idtree.h).

9 years agoccanlint: show example we actually compiled when we report warnings.
Rusty Russell [Mon, 6 Dec 2010 02:20:45 +0000 (12:50 +1030)]
ccanlint: show example we actually compiled when we report warnings.