Commit Graph

1966 Commits

Author SHA1 Message Date
iphydf 09bb9b8a23 cleanup: Make Networking_Core pointer-to-const where possible. 2022-01-16 01:09:44 +00:00
iphydf c081a50201 cleanup: Use pointer cast instead of memcpy in qsort callback.
No need to make copies of the data. There is no concurrency in qsort.
2022-01-16 00:12:44 +00:00
iphydf 0d27eb2f90 cleanup: Deduplicate a somewhat complex loop in DHT.c. 2022-01-15 21:25:14 +00:00
iphydf 2671095f4a cleanup: Merge crypto_core and crypto_core_mem.
The remaining memory functions are small and don't need their own file.
2022-01-15 01:34:14 +00:00
iphydf 6823fcbae1 cleanup: Stop using strerror directly.
We have a more portable wrapper that is now also thread-safe. Also
stopped using sprintf in the one place we used it. This doesn't really
help much, but it allows us to forbid sprintf globally.
2022-01-15 01:25:56 +00:00
iphydf fdacd81524 cleanup: Remove our only use of sprintf.
Replaced with snprintf.
2022-01-15 00:52:51 +00:00
iphydf d23222c92f chore: Run static analysers in multiple variants.
Currently: 1) libsodium and 2) nacl.

Note that the "nacl" variant is actually libsodium. We just want to make
sure the static analysers see the `VANILLA_NACL` code paths.
2022-01-14 10:45:11 +00:00
sudden6 2073d02c33 fix: don't count filetransfer as sending until accepted
This fixes high CPU load in c-toxcore due to started but not accepted
file transfers causing lots of iterations in do_all_filetransfers(...).
Additionally this skips expensive calls max_speed_reached(...).
2022-01-13 21:41:12 +00:00
iphydf 4a2cb37e4b fix: Fix some uninitialised memory errors found by valgrind and msan.
Also added a valgrind build to run it on every pull request. I've had to
disable a few tests because valgrind makes those run infinitely slowly,
consistently timing them out.
2022-01-13 20:15:21 +00:00
iphydf 9b7279ab24 chore: Run tokstyle with 3 cores.
This seems to be the sweet spot for the current tokstyle implementation.
4 cores gives the same speedup, 5 also, 6 makes it slower, and 2 also
makes it slower.
2022-01-12 18:52:46 +00:00
iphydf f5f22a5c76 chore: Enable layering check in all c-toxcore build files. 2022-01-12 18:33:13 +00:00
iphydf cfb0aa8f25 cleanup: Remove extra parens around function arguments. 2022-01-12 07:02:29 +00:00
iphydf c1b32bd7a1 chore: Enable compiler layering check.
This ensures that we're explicit about what we depend on and avoids
transitive dependencies.
2022-01-11 15:26:32 +00:00
sudden6 7dd8dbd897 intercept network, crypto and time
This fuzzing harness must be as deterministic as possible for the fuzzer
to detect additional coverage reliably.
2022-01-10 21:05:49 +01:00
iphydf f46f51e554 cleanup: Don't use memcpy where assignment can be used.
See https://github.com/TokTok/hs-tokstyle/pull/104.
2022-01-10 10:58:42 +00:00
Robin Linden 23df660fd2 Remove always-true check in receivepacket error handling 2022-01-10 02:27:13 +01:00
Robin Linden 091dc6c833 Fix many MSVC auto tests failing due to WSAECONNRESET 2022-01-10 02:27:13 +01:00
iphydf 73484d8995 cleanup: Use calloc instead of malloc for struct allocations.
`malloc` is used only for byte/int arrays. Also, we no longer allow plain
`void *` allocations. Every allocation should have a real value type.
2022-01-09 22:42:50 +00:00
iphydf 9ab77e015d cleanup: Fix calloc argument order.
See https://github.com/TokTok/hs-tokstyle/pull/102
2022-01-09 18:42:20 +00:00
iphydf 83d5d0d280 cleanup: Remove useless parentheses. 2022-01-06 20:36:03 +00:00
jfreegman 7318127dca Remove dead code
Neither of these clauses can ever be reached.

Also attempt to fix travis Windows build
2022-01-01 19:44:11 -05:00
iphydf 8cd4827a14 cleanup: Reduce the scope of for-loop iterator variables.
Found by tokstyle after https://github.com/TokTok/hs-tokstyle/pull/95.
2022-01-01 03:26:41 +00:00
iphydf 6f61de54d3 chore: Add "tcc" and "compcert" compiler targets.
It's nice we are able to compile with `tcc`. Let's not break that.
CompCert is also neat, but its interpreter mode doesn't work on tox, so
we only use the compiler.
2021-12-30 23:09:23 +00:00
zugz (tox) 64a48c0e78 cleanup: Remove hardening code from DHT 2021-12-30 00:00:01 +00:00
jfreegman d8397c93c8 Put breaks inside case bracers 2021-12-25 12:30:39 -05:00
iphydf 29eb3dd490 chore: Remove apidsl comment from tox.h.
There is no more apidsl, so you can edit tox.h manually now.
2021-12-23 15:33:03 +00:00
iphydf 2f546a9710 chore: Rename test source to match standard.
All tests should end in `_test.c` or `_test.cc` for unit tests.
2021-12-23 03:50:16 +00:00
iphydf aa64ecc34e cleanup: Sync comments in all toxcore/*.[ch]. 2021-12-22 10:48:53 +00:00
iphydf f49168e209 chore: Make all function comments doxygen style /** comments.
This way, they become eligible for the tokstyle comment sync check.
2021-12-22 10:48:53 +00:00
jfreegman e92a67ed5f Merge friend_connections from NGC fork 2021-12-21 15:07:21 -05:00
iphydf 24f49fc917 chore: Fix up a few source code comment and style issues.
Tokstyle no longer allows:
* Includes inside an `extern "C"`
* Comments on function definition and declaration to be different.
* Doxygen comments commenting on other doxygen comments.
2021-12-21 18:14:53 +00:00
iphydf 4841fc9439 cleanup: Move sodium.h include to front of network.c.
I missed this one because cimple didn't recurse into `#ifdef`.
2021-12-21 15:01:12 +00:00
iphydf 74bf0fc2c8 chore: Disable -Wmissing-braces.
This flag isn't helpful for the most common case of aggregate
initialisation, namely `{0}`. We don't want to be writing `{{{0}}}` with
some brittle number of braces.
2021-12-21 12:04:04 +00:00
iphydf 3f0ab46229 cleanup: Pull #include directives to the beginning of the file.
We won't be allowing includes to appear after other declarations.
2021-12-20 11:53:14 +00:00
jfreegman b07a159856 Remove redundant (and incorrect) comments 2021-12-19 15:14:24 -05:00
sudden6 fe4df5b6a3 refactor: rename variable to clarify purpose 2021-12-19 21:07:18 +01:00
iphydf 4746a8b3af cleanup: Remove apidsl; remove crypto_memcmp.
* `crypto_memcmp` was replaced by more specific functions. We never want
  to compare arbitrary amounts of data this way. We use these functions
  to compare key material.
* apidsl has been bothering people, so now we un-bother them. You're
  welcome.
* Added the memlock/unlock functions from the New Group Chats branch.
* Remove some system dependencies in crypto_core_mem.c.
* Renamed UPPERCASE_NAMES to Snake_Camel_Case names.
2021-12-19 19:22:38 +00:00
iphydf 27f7c8beaa chore: Tie down the use of doxygen comments.
These should only be used before a toplevel thing that can be commented on.
2021-12-15 18:35:48 +00:00
iphydf d9ab91970d cleanup: Remove apidsl for everything except the public API.
Apidsl is not powerful enough to express all the things we need and
doesn't know how `#include` works. The generated headers are more complex
than they should be.
2021-12-15 17:36:29 +00:00
jfreegman 8bff6a38f8 Remove unused function argument from set_tcp_connection_status() 2021-12-15 12:30:23 -05:00
iphydf f49ea44daa cleanup: Remove crypto_pwhash import.
Vanilla nacl builds won't have toxencryptsave.
2021-12-15 17:16:35 +00:00
iphydf 6b75f8b889 chore: Remove config.h.
This aligns the autotools build with the cmake build, which doesn't have
a config.h file. It also removes the ambiguity of config.h and
other/bootstrap_daemon/src/config.h.
2021-12-15 10:26:50 +00:00
jfreegman 44450d3590 merge tcp_connection changes from new groupchats fork 2021-12-14 16:57:28 -05:00
iphydf 2ba2cbd8e9 chore: Fix gen-file.sh: it wasn't globbing properly.
Also fix crypto_core_test.cc to comply with the stack frame limit.
2021-12-14 21:26:52 +00:00
jfreegman 570dcdb807 merge DHT.c/h and network.c changes from new groupchats fork 2021-12-14 13:54:52 -05:00
jfreegman f45807a0f2 merge onion.c changes from new groupchats fork 2021-12-14 13:03:14 -05:00
iphydf 74bc87f277 test: Make ERROR logging fatal in tests.
This doesn't currently work, because we get a lot of errors during tests.
This should not happen. Either those errors are warnings, or something is
wrong with either the code or the test.
2021-12-14 13:00:25 +00:00
iphydf 5c53e6a30f chore: Add autotools build; exempt crypto_pwhash from tokstyle. 2021-12-13 18:47:45 +00:00
iphydf fd32c87707 cleanup: Don't include "config.h" unless needed.
Currently only `crypto_core_mem.c` needs this. We should try not to
depend on configure'd values. Also note: config.h is only created and
used in the autotools build. In CMake, we pass `-D` flags directly.
2021-12-12 22:18:38 +00:00
jfreegman d66adbecac Address some unused return values
We now either log errors or properly propagate them. In the case of
ping_send_request we make the function return void because it doesn't
seem to matter whether or not it succeeds.
2021-12-11 10:46:50 -05:00