Douglas Bagnall [Fri, 20 Jun 2014 02:33:53 +0000 (14:33 +1200)]
opt: always initialise values in set_llong_with_suffix()
The helper API functions based on set_llong_with_suffix() left the
value uninitialised in the case of an empty string argument. This is
quite unlikely to have caused problem in practice, as most values will
have already been set to a default and the non-NULL error message
should have triggered an early exit or some other emergency action.
Nevertheless, it caused a compiler warning on some minor version of
GCC 4.8 which I no longer seem to have, and the complaint seemed
reasonable at the time.
If an empty string (or any other non-numeric value) is passed to
strtoll(), the result is zero. As far as I know, the strtoll() call is
only short-circuited here to form a more specific error message, not
because there is a good reason for the empty string to be a special
non-initialising case. So let's set it to zero.
Signed-off-by: Douglas Bagnall <douglas@halo.gen.nz> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Cody P Schafer [Sat, 21 Jun 2014 00:46:01 +0000 (20:46 -0400)]
compiler: avoid barfing when config.h & the current -std= mode mismatch
Add a bunch of __ for all the attribute members.
Lets us keep working even if configurator is called with different
CFLAGS than the build of a file which includes compiler.h
Idealy, we (people using ccan) wouldn't let this happen, however I don't
see any reason /not/ to avoid build breakage in the above case.
Long term, it might make sense to plug some logic into configurator's
config.h (or a cc wrapper, so something else) to warn when the current
flags don't look the same as the ones used to generate config.h
CC: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Cody P Schafer <dev@codyps.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
David Gibson [Sun, 15 Jun 2014 14:09:09 +0000 (00:09 +1000)]
ccan: Correct some poor conventions in _info includes
There are a couple of small problems with the includes used in most of
ccan's _info files.
* _info routinely uses printf(), and so should include <stdio.h>, but
only some of them do. We get away with it, because they do include
<string.h>, which apparently includes <stdio.h> indirectly, but we should
be explicit about it.
* Most _info files were including config.h after the system headers.
That _seems_ sensible, but actually causes problems. Because config.h
defines _GNU_SOURCE it can change the behaviour of the system headers.
More specifically it can make them behave differently to how the individual
module headers (which have included config.h) expects them to behave.
This patch adjusts all the existing _info files and, more importantly,
the template constructed by ccanlint.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
David Gibson [Sat, 14 Jun 2014 16:11:25 +0000 (02:11 +1000)]
memmem: Trivial module to provide memmem() function
glibc includes a memmem() function which, by analogy with strstr()
searches for a byte sequence within a larger byte sequence. The function
isn't standard, however, so other C libraries may not include it.
This adds a trivial module providing the memmem() function, if the C
library doesn't already do so.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
David Gibson [Wed, 4 Jun 2014 14:41:51 +0000 (00:41 +1000)]
jacobson_karels: Add missing inline keyword
Forgot the 'inline' in 'static inline' in the functions defined in the
header, which means that lots of warnings will be generated, if you include
the header but don't use the functions.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
David Gibson [Mon, 2 Jun 2014 12:37:28 +0000 (22:37 +1000)]
minmax: New module, safe min and max macros
Add a 'minmax' module with typesafe macros to compute minimum, maximum and
clamping. Inspired by the versions used in the Linux kernel, but using
a different implementation based on __builtin_types_compatible_p() and the
build_assert module.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 27 May 2014 03:47:29 +0000 (13:17 +0930)]
net: don't return still-connecting fd.
If one connect failed, we'd return the other one without
waiting for the connect to complete. This resulted in
read() returning 0, which was really weird.
The downside: the poll doesn't seem to time out when the
connect times out (Linux 3.13 x86-64).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Emilio G. Cota [Mon, 10 Mar 2014 15:04:50 +0000 (11:04 -0400)]
bitmap: use unsigned int for iterating over bitmap words
Bitmap words (e.g. resulting from BITMAP_{N,HEAD}WORDS) are of
unsigned type.
Use "unsigned int" to iterate over bitmap words to avoid comparisons
between signed and unsigned expressions. GCC otherwise warns about
these when -Wsign-compare is enabled.
Rusty Russell [Sun, 2 Mar 2014 06:05:10 +0000 (16:35 +1030)]
io: call finish function after fd is actually closed.
This turns out to be the right sequence for pettycoin, which
wants to reap the child in the finish routine. From that sample
size of 1, this is clearly the Right Thing!
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Fri, 28 Feb 2014 01:42:11 +0000 (12:12 +1030)]
Enhance CCAN_LIST_DEBUG to report original caller
Simpler reimplementation of SS's patch; just plumb file and line through
inline functions in header. We add a new check, which actually tests
these, and fix _info which missed ccan/check_type as a dependency.
Based-on-the-true-story-by: Stewart Smith <stewart@linux.vnet.ibm.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Mon, 24 Feb 2014 02:55:19 +0000 (13:25 +1030)]
opt: relicense to GPLv2+ (from GPLv3+)
Acked by contributors:
Luke-Jr <luke@dashjr.org>:
I don't have any objections
Douglas Bagnall <douglas@halo.gen.nz>:
Fine by me.
Joel Stanley <joel@jms.id.au>:
Fine with me.
Brad Hards <bradh@frogmouth.net>:
Ack.
No response from Joey (trivial warning patch) or Andreas Schlick (one
trivial patch, but he also wrote opt_free() (which was a 2 line function).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Peter Hutterer [Thu, 21 Nov 2013 01:53:53 +0000 (11:53 +1000)]
argcheck: a module to check argument ranges
This code provides some macros to check arguments for valid value ranges.
Consider this a mild version of assert(3), because all it does is to log
a message and continue.
These macros don't replace error handling, but they are useful in
situations where an error is unexpected but not common, i.e.
this shouldn't happen but if it does let me know".
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Ahmed Samy [Mon, 11 Nov 2013 16:21:31 +0000 (18:21 +0200)]
cpuid: parse L1 cache information for AMD.
Also take out additional feature information from processor information
and feature bits since they can be tested using cpuid_test_feature() and
cpuid_has_feature()
Apparently init --user adopts orphans. To quote the author
Stewart Smith:
As much as one can be happy in Ubuntu breaking something that has been
true for what must be approaching 40 years, yep, I'm happy for you to
make the changes.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>