Commit Graph

4501 Commits

Author SHA1 Message Date
iphydf
767ccbb387
Avoid forward declaration of rtp structs.
Forward declarations are problematic, as they easily allow introducing
cyclic dependencies.
2018-08-12 19:54:27 +00:00
iphydf
b2590e2f44
Fix style in bwcontroller module.
* Comments in macros must be `//` style.
* No inner structs.
* Named callback types.
* `++i` instead of `i++`.
* No assignments as expressions.
2018-08-12 18:26:31 +00:00
iphydf
b3036c55a6
Stop running tests in the bazel build.
These always fail at present. We'll need to look into making them not
always fail so we can enable them and get some useful signal from them.
2018-08-12 17:04:07 +00:00
iphydf
a743464623
Move OSX to stage 1 of Travis.
This avoids its dependency on FreeBSD.
2018-08-12 15:37:37 +00:00
zugz (tox)
fb89c03dd2
Add simple deterministic random number generator for tests 2018-08-12 15:22:34 +00:00
iphydf
3fe0551417
Assert that we don't divide by 0 in random_testing.cc.
This is always true due to the condition function, but if we introduce a
bug that makes the condition not be applied, this causes undefined
behaviour.
2018-08-12 14:52:52 +00:00
iphydf
d92c96e783
Fix a few warnings from clang.
Also remove the use of a VLA in a context where there can be unbounded
memory allocations.
2018-08-12 14:09:59 +00:00
iphydf
f0f456398d
Check that the save file size isn't larger than our address space. 2018-08-12 12:05:01 +00:00
iphydf
1de8b020cb
Remove all uses of the PAIR macro in toxav. 2018-08-12 11:38:23 +00:00
iphydf
5d15b5930d
Remove last use of the MIN macro.
We use functions for this instead.
2018-08-12 11:38:23 +00:00
iphydf
503d9f7e22
Add deprecation notice to some UPPER_CASE enums.
The enumerators won't change, but the type name will change in 0.3.0.
Reasoning:
- Type names in toxcore start with an uppercase letter and either have at
  least one lowercase letter in them, or are less than 4 characters long.
- Constants consist of 4 or more uppercase letters or underscores.

By these rules, "DHT" is a type name, but "TOX_USER_STATUS" is a
constant. We provide Tox_User_Status as an alternative for now, and will
switch to that in 0.3.0, removing the UPPER_CASE versions.
2018-08-11 16:28:24 +00:00
iphydf
678720d2fe
Split out conference type (text/av) from identifier. 2018-08-11 13:12:49 +00:00
iphydf
463cbcb19a
Use the crypto random functions instead of rand().
Presumably the uses of `rand()` were fine because they were not used in
security-sensitive places, but having to think about whether a crappy RNG
is acceptable in each situation requires effort that could better be
spent elsewhere.

Also, this means that once we have a custom deterministic RNG for
testing, that RNG is used everywhere, so all the code is deterministic.

It also allowed us to delete a system-specific function that wasn't used
anywhere except in a call to `srand()`.
2018-08-10 14:53:27 +00:00
zugz (tox)
afab28f0ff
Fix typo in loop over assocs. 2018-08-09 22:47:21 +00:00
Robin Lindén
ffd71e895b
Release 0.2.5 2018-08-08 19:38:31 +02:00
endoffile78
cd98ec4c16
Fix error message in m_send_generic_message 2018-08-04 13:12:07 -05:00
iphydf
788fa224a5
Remove unused m_callback_log function.
The logger callback can only be set once at the beginning, because it
requires user data coming from `Tox_Options`.
2018-08-04 11:44:14 +00:00
iphydf
064ffe5875
Make a separate struct Tox containing the Messenger.
This allows Tox to contain additional data on top of Messenger, making
Messenger not necessarily the most top-level object. E.g. groups are
built on Messenger and currently awkwardly void-pointered into it to
pretend there is no cyclic dependency.
2018-08-04 09:29:15 +00:00
iphydf
7f8b29c346
Avoid multiple for-next expressions.
All for-loops in toxcore are of the form

    for (<for-init>; <for-cond>; <for-next>) { <body> }

`for-init` can be a variable declaration (like `int i = 0`), an
assignment (like `i = 0`), or empty.

`for-cond` can be any expression.

`for-next` can be an assignment or a single increment/decrement
expression (like `++i` or `--i`).

No other forms are allowed, so e.g. comma expressions in any of these are
not allowed (so no `for (i = 0, j = n; ...; ++i, --j)`).
2018-08-04 09:04:42 +00:00
zugz
aa63c1330c
Fix problems with initial connections and name-setting in conferences
* test names in conference_test
* raise error on attempt to invite friend to group before we are connected
* revise handling of temporary invited connections
    We are now careful not to prematurely delete a connection to a peer
    established during the invitation process; namely, before we have sufficient
    other connections and have confirmed that we have an alternative route to the
    peer.
* process out-of-order messages from a peer
* don't reset names when handling a Peer Response
2018-08-02 22:03:18 +01:00
hugbubby
3a4987da18
Fix autotools build
Mosts of the tests in auto_tests weren't running when the project
was built using autotools. This fixes that.
2018-07-30 12:48:21 +00:00
iphydf
1f27fcb5af
Add by_id and get_id functions, renaming from *_uid.
`UID` sounds like `User ID`. While it is a Unique ID, the property of an
"identifier" is generally that it identifies a unique thing, so the 'U'
is redundant, and `GUID` as a globally unique id (which is likely also
true for these IDs) has a specific meaning and syntax, so we're not using
that. So, we just say conference `id`.
2018-07-28 16:39:44 +00:00
hugbubby
051eb1d5a7
auto_test fixture and filenames
Renamed a poorly named test, fixed up a few printf statements,
substituted some unsigned integers with fixed size counterparts,
and implemmented the auto_run_test.h fixture for the lossy and
lossless packet tests.
2018-07-28 16:14:06 +00:00
hugbubby
c4d58403f9
More fixed_width ints and incorporating file_saving_test.c
The file_saving_test.c was not included in the cmake list
and thus was ignored by travis and "make check". I found this
out while introducing ck_assert_msg into the integration test.

Furthermore, removed some variable width integers from encryptsave_test.c,
and the SRunner utilization. Implemmented ck_assert_msg, reorganized some
loops, and removed some longs in file_transfer_test.c.
2018-07-23 15:10:22 +00:00
iphydf
f627a26a7b
Run Clang global static analysis on Travis.
This uses a single .cc file containing almost all the code in the
repository to perform whole program analysis.
2018-07-22 02:34:30 +00:00
iphydf
7245ac11ef
Avoid implementations in .h files or #including .c files.
Also, avoid the need for putting `_XOPEN_SOURCE` in every test file.
2018-07-21 20:44:26 +00:00
iphydf
7c2b95ef5e
Remove redundant casts to the same type.
Also removed an unused identifier in messenger_test.c.
2018-07-21 15:09:39 +00:00
iphydf
adb12d5340
Add github usernames to TODOs. 2018-07-21 14:56:21 +00:00
iphydf
b6b3cdbf25
Synchronise parameter names in headers with those in the implementation. 2018-07-21 14:46:31 +00:00
iphydf
9a96bb9a5b
Reduce nesting by doing more early returns on error.
This almost entirely avoids any else-after-return in toxcore. One case is
left, and that one is more readable this way.

Why no else after return: https://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return
Why exemptions exist: https://blog.mozilla.org/nnethercote/2009/08/31/no-else-after-return-considered-harmful/
2018-07-21 14:22:41 +00:00
iphydf
253abe5de4
Make resize in list.c return bool instead of 0/1. 2018-07-21 11:44:58 +00:00
iphydf
c1b7edbed3
Add missing braces in dht_test.c.
astyle doesn't catch all of these.
2018-07-21 13:01:34 +02:00
iphydf
affaaee210
Run buildifier on c-toxcore BUILD files. 2018-07-21 01:13:29 +00:00
Robin Lindén
a672b3c56e
Release v0.2.4 2018-07-20 22:52:14 +02:00
Jan Malakhovski
246165954c
Introduce several TODOs 2018-07-19 19:24:00 +00:00
Jan Malakhovski
669bdf23ee
Rename m_handle_custom_lossy_packet -> m_handle_lossy_packet
This function handles all lossy packets, including AV.
2018-07-19 19:24:00 +00:00
Jan Malakhovski
e7a5f52c14
Collect PACKET_ID* constants in net_crypto.h, cleanup their uses 2018-07-19 19:24:00 +00:00
iphydf
3f6b6842f3
Use string comparison operator in configure.ac.
.. to compare strings. `==` is for numeric values.
2018-07-19 16:53:48 +00:00
iphydf
bf79fdbb43
Link -lsocket and -lnsl for socket functions on Solaris.
Also, added some #defines to make symbols visible that are in BSD but not
in UNIX. Solaris needs these, since it's fairly strict with its symbol
visibility in system headers.
2018-07-19 15:05:26 +00:00
zugz
7c05b3a85e
replace LOGGER_ERROR with LOGGER_DEBUG on send_data_packet() failure in send_lossless_packet() 2018-07-18 21:17:10 +00:00
iphydf
7f6c681cfa
Use enums for group packet types.
Also moved some macros up to the beginning of `group.c`. This change
brings us closer to the PGC PR.
2018-07-18 21:05:42 +00:00
hugbubby
a592f0fa87 Wrong use of unsigned integer. 2018-07-18 13:55:30 -07:00
hugbubby
864d1c15e4 Using stdint instead of int/long
Did my best to surmise the size requirements of
these integers, will do the rest of the tests soon. Also added a todo
and made an obsessive change to a for loop.
2018-07-18 13:55:30 -07:00
iphydf
392eef7900
Correct the max hostname length constant.
256 bytes including NUL byte is confusing and makes for really annoying
bindings to other languages that don't account for NUL bytes in their
string length. We pass C strings, not byte arrays, for hostnames, so 255
makes more sense here.
2018-07-18 00:32:54 +00:00
iphydf
13aa33a0f8
Set _XOPEN_SOURCE to 700 for FreeBSD. 2018-07-16 01:03:30 +00:00
iphydf
9eacfafff7
Set C++11/C99 flag manually in older cmake on not-msvc.
These flags are needed so the code actually compiles, so can't only be
set on Travis.
2018-07-15 23:01:32 +00:00
Maxim Biro
c0b4cd156f
Simplify Travis-CI FreeBSD build 2018-07-15 18:37:10 -04:00
iphydf
b4cf9808e9
Use the correct repository name in the coverage badge. 2018-07-15 16:52:04 +00:00
iphydf
90a63e8188
Add conference_by_uid and conference_get_uid functions.
These are useful once we have persistent group chats, so clients can
store data associated with this permanent group identifier.
2018-07-13 19:30:02 +00:00
iphydf
3d5fd9c2d0
Limit number of group chats to 65536.
By changing numchats from uint32_t to uint16_t. This is done in PGC. This
PR is making that change in master to reduce the diff in the PGC branch.

Also:
* Inverted groupnumber_not_valid and renamed to is_groupnumber_valid.
* Renamed realloc_groupchats to realloc_conferences and made it return bool.
* Added setup_conference function that currently just zeroes the
  conference structure but later will initialise more values.
* Made some `i` iterator variables local to the for-loop using
  for-init-decl. This is also done in PGC.
2018-07-12 23:58:24 +00:00