Commit Graph

39 Commits

Author SHA1 Message Date
Andrew Bettison
71e654a615 Fix compile error in strbuf_local_buf() with CFLAGS=-g
The strbuf_local_buf() function attempted to detect if its argument was
not an array but a pointer, and fail at compile time.  This worked fine
when compiling with standard optimisation (-O2).

However, specifying the gcc -g option disables compiler optimisation, so
the compiler does not optimise away the call to the function with
__attribute__(error("...")), and so the compile fails.

The solution is to perform the check at run time using assert(), like
strbuf_local() already does.
2018-03-06 15:16:55 +10:30
Jeremy Lakeman
a8c29bbb15 Add MeshMB cli commands to follow and ignore feeds 2017-04-19 14:46:36 +09:30
Jeremy Lakeman
1e70bcaac6 Clean up some more warnings 2016-11-21 10:34:12 +10:30
Andrew Bettison
1efe6686fc Use config.h instead of -DHAVE_FOO=1
swiftc(1) requires every -D option to be prefixed with -Xcc, which
is not easy to achieve using autoconf.

Now instead of setting configuration macros like HAVE_LSEEK64 on the
command line using -D, they are defined in config.h, which is generated
by ./configure, ignored by Git, and included by all headers and source
files that use any configuration macro.

The dependency on Makefile has been replaced with a dependency on
Makefile.in and config.h, which helps avoid some redundant full
recompiles after running ./configure, because the configure script
does not overwrit config.h if its content does not change.
2016-10-19 16:27:20 +10:30
Andrew Bettison
6dd823a9e8 Rename "features.h" to "lang.h"
In preparation for introducing "feature.h" for feature-driven linking.
2016-10-19 09:30:18 +10:30
Jeremy Lakeman
ef208c9932 Workaround stack alignment bugs when compiling with clang 2016-01-27 16:27:47 +10:30
Andrew Bettison
e8e87b8a34 Fix broken clang and Android builds
Recent addition of the GCC __attribute__(alloc_size) to some functions
in mem.h broke the build when using Clang 3.5.  This commit introduces
configure-time checks for all GCC attributes used in the Serval source
code, and adapts accordingly.
2015-11-23 15:00:25 +10:30
Andrew Bettison
23cd578595 Cosmetic improvements to strbuf.h 2015-11-17 00:42:06 +10:30
Andrew Bettison
8310d3cf19 Add strbuf_malloc() macro 2015-11-17 00:42:06 +10:30
Andrew Bettison
45b7d4f4c5 Under GCC, check strbuf_local() buffer limit
If strbuf_local(buf, len) is called with a buffer whose size can be
deduced at compile time, then this change will check that 'len' does not
exceed that size, causing an assertion failure at run time if it does.

The safety check makes use of the GCC extensions: __builtin_object_size()
and __attribute__((alloc_size(n)).  Under non-GCC compilers, the safety
check will not be performed.
2015-11-17 00:42:06 +10:30
Andrew Bettison
fdc6156ec7 Under GCC, enforce proper strbuf_local_buf() arg
Internally the strbuf_local_buf(x) macro uses sizeof(x) to determine
the size of the buffer, but this will give the wrong behaviour if x
is a pointer (char *x), not an array (char x[]).  With this change,
invoking it with a pointer will cause a compile error.

The safety check makes use of the GCC extensions: __builtin_object_size()
and __attribute__((alloc_size(n)).  Under non-GCC compilers, the safety
check will not be performed.
2015-11-17 00:42:06 +10:30
Andrew Bettison
a060642fdb Add strbuf_local_buf() macro 2015-11-02 10:11:41 +10:30
Andrew Bettison
cf0e1aa8d6 Add log_context 2015-06-29 15:39:19 +09:30
Andrew Bettison
00037cf803 Change return type of strbuf_sprintf() 2015-03-16 22:33:11 +10:30
Andrew Bettison
a3010d3632 STRBUF_ALLOCA_FIT() macro 2014-01-20 15:37:14 +10:30
Andrew Bettison
81f641b1fe Include <limits.h> for SIZE_MAX on Android 2013-12-11 14:34:34 +10:30
Andrew Bettison
27b37c143f Fix -Wsign-compare warnings in strbuf 2013-12-09 16:29:06 +10:30
Andrew Bettison
a95ef79139 Use sid_t everywhere
Remove stowSid() at last

Change API of tohex() and strbuf_tohex(), to pass string length instead of
binary byte count.  This allows odd numbers of hex digits to be produced.

Remove alloca_tohex_sid(); replace with alloca_tohex_sid_t()

New alloca_tohex_sid_t_trunc() macro
2013-10-09 18:54:21 +10:30
Jeremy Lakeman
08b44e96ed Improve html debug statistics
- shift radio rssi onto interace structure
- track packets sent received
- create html output for interface stats
- create html output for link state routing stats
2013-09-23 11:31:38 +09:30
Andrew Bettison
a4704dfd3c Add strbuf_va_vprintf() convenience macro 2013-09-19 16:34:02 +09:30
Jeremy Lakeman
0b40ef655c Log format warnings for strbuf_sprintf 2013-08-15 16:31:26 +09:30
Andrew Bettison
10e89c7438 Add strbuf_remaining()
Improve some comments in strbuf.h
2013-04-04 17:41:18 +10:30
Andrew Bettison
a50594971c Fix comment in strbuf.h 2013-03-26 18:24:13 +10:30
Andrew Bettison
27a0a6eeb5 Introduce struct __sourceloc
Replaces (const char *file, unsigned int line, const char *function) arguments
to all logging functions, simplifies malloc/free tracking code in
overlay_buffer.c and Rhizome manifest alloc/free tracking in rhizome_bundle.c.

Use __HERE__ macro instead of (__FILE__, __LINE__, __FUNCTION__) everywhere.

Special __NOWHERE__ macro is equivalent to (NULL, 0, NULL).

Declare net.c functions in new "net.h" header, so log.c doesn't have to pull
in the entire "serval.h" just to use write_str().

Facilitates progress on issue #2.
2012-08-23 12:31:07 +09:30
Andrew Bettison
65d6bf191a Fix strbuf API comment 2012-08-22 19:03:00 +09:30
Andrew Bettison
fa03b7e667 Fix bug in alloca_toprint() that caused SEGV 2012-08-06 15:39:08 +09:30
Andrew Bettison
07349c3aea Improve copyright attributions and comments 2012-07-30 16:15:42 +09:30
gardners
93449d380e various fixes for libmonitorclient and commits made by others
inbetween. Hopefully I have captured all the changes.
2012-07-29 12:35:53 +09:30
Andrew Bettison
ed2410c152 Add strbuf_end() function 2012-07-26 16:47:17 +09:30
Andrew Bettison
04b95d2590 Merge branch 'andrew' into 'master' 2012-07-25 18:04:16 +09:30
Andrew Bettison
6bb0d93d85 Add strbuf_tohex() primitive 2012-07-20 18:17:04 +09:30
Jeremy Lakeman
7fb1fd7938 Fix building and testing on OSX 2012-07-13 12:30:59 +09:30
Andrew Bettison
63d1792863 Fix bugs in strbuf_ncat(), strbuf_puts() and strbuf_putc()
Were not advancing the 'current' pointer the entire length of the appended text
2012-07-11 11:41:15 +09:30
Andrew Bettison
2c1c44c4fe Add strbuf_trunc() primitive, fix bug in strbuf_substr() 2012-07-10 19:36:25 +09:30
Andrew Bettison
bbdfda2ce4 Improve strbuf API
Add STRUCT_STRBUF_EMPTY initialisation constant
Add strbuf_is_empty() primitive
Fix documentation comments in strbuf.h
2012-07-05 14:58:28 +09:30
Andrew Bettison
5cff81e0c0 Add strbuf_reset() 2012-06-25 16:32:52 +09:30
Andrew Bettison
56cb12f507 Refactor rhizome db creation and execution functions 2012-06-12 18:12:36 +09:30
Andrew Bettison
345b2c1c4c Fix SEGV bug using new strbuf operations 2012-05-20 13:02:41 +09:30
Andrew Bettison
2f4d1eb720 "strbuf.h" API for assembling fixed-sized string buffers 2012-05-19 14:02:03 +09:30