Commit Graph

5224 Commits

Author SHA1 Message Date
iphydf
e855135916
chore: Enable a bunch more warnings in GCC builds.
g++ doesn't emit these warnings properly, so the `run-gcc` tool, which
compiles code as C++, doesn't work for all of these. There are a few
builds that do use GCC, e.g. the sonar-scan build, so these flags will
be passed at some point in CI.
2022-02-28 23:26:35 +00:00
iphydf
fe4da6a541
cleanup: Log at ERROR level when connect() fails.
Failure is defined as either being passed an invalid IP/Port, or some
unexpected error code.
2022-02-28 14:01:01 +00:00
iphydf
3ef96f7096
cleanup: Remove *all* boolean-int conversions.
These were found by the new cimple type check which is completely
unforgiving to implicit boolean conversions. After this PR, there should
be no more implicit int-to-bool or bool-to-int conversions.
2022-02-27 00:29:43 +00:00
iphydf
163e9c3b03
cleanup: Remove more boolean conversions (and a bugfix).
These were found by the new stronger type check in cimple. The one
bugfix is in `crypto_sha512_cmp`, which used to think `crypto_verify_32`
returns bool while actually it's -1/0/1.
2022-02-26 00:03:56 +00:00
iphydf
e230ad4d09
cleanup: Comply with strict include ordering.
Tokstyle will require this format:
- Optionally a single include (the module header).
- System includes.
- Local includes.

In headers, there is no module header to include, so system includes
come first there.
2022-02-25 16:44:35 +00:00
iphydf
093927ba4f
test: Add mallocfail and proxy test to our coverage runs. 2022-02-25 01:55:28 +00:00
iphydf
50b0ec824f
cleanup: Avoid creating invalid enum values.
Enums should be fairly strong type guarantees about the possible value
range. The API says the return value is unspecified, so this is not a
breaking change.
2022-02-25 01:22:55 +00:00
iphydf
cad7cf8344
cleanup: Remove superfluous parentheses on the rhs of assignments. 2022-02-25 01:02:11 +00:00
iphydf
aa72c47125
test: Add test coverage docker build for local tests.
This uses mallocfail to further increase coverage using the existing
tests. Also:
* Moved the non-auto "tox_one_test" to gtest. This should be
  split into smaller tests later.
* Changed `hole_punching` to `bool`.
2022-02-24 16:24:28 +00:00
iphydf
2ce6f5b169
fix: Report failure to DHT bootstrap back to the client.
Also reduce log verbosity a bit.
2022-02-24 11:37:47 +00:00
jfreegman
de67c4067c
Fix issue with friend finding taking too long after disconnects
This forces the onion to consider all friends as new after a 10 second
period of the onion being disconnected. new friends are aggressively
searched for in the DHT, whereas old friends are only searched for in
intervals spanning minutes.
2022-02-23 20:10:23 -05:00
iphydf
7ca14d4f52
cleanup: Change valid status of onion friend to bool.
Also renamed it to `is_valid`, since that's what the comment says it
means.
2022-02-24 00:57:09 +00:00
Robin Linden
0ac930e1f6
cleanup: Clean up comparing bools with ints 2022-02-23 22:50:12 +00:00
Robin Linden
0ca2882b92
cleanup: Remove yet more implicit bool conversions 2022-02-23 22:00:46 +00:00
iphydf
c2c7c9f0fd
cleanup: Remove more implicit bool conversions.
Also use `bool` type in place of `uint8_t` which was the old bool type
in toxcore before C99.
2022-02-23 22:00:46 +00:00
sudden6
3e6fc59f91
chore: remove cpufeatures.c
The method to detect CPU features in Android has changed and this is no
longer needed.
2022-02-23 20:59:06 +01:00
iphydf
b13590a86d
cleanup: Mark all local non-pointers as const where possible. 2022-02-23 19:30:01 +00:00
iphydf
17c8f50f44
cleanup: Reduce name shadowing; remove ptr-to-bool conversions.
Missed a few of those in check-c. check-cimple now catches these with a
stronger type check.

Other changes:
* `ptr + int` must always have the `ptr` first, so `int + ptr` is not
  allowed anymore.
* `close` and `time` were shadowing libc functions. `file_data` was
  shadowed in a function (and is not a good function name anyway), so
  renamed to `send_file_data` which is more descriptive.
* Within a function, all local variables of the same name must have the
  same type.
* The `strerror_r` change wasn't necessary, but I kept it because it
  seems a bit clearer to me now. `#ifdef`s inside functions are a bit
  confusing sometimes.
2022-02-23 17:30:53 +00:00
iphydf
70d75ae9a3
cleanup: Remove implicit conversions from uint32_t to bool. 2022-02-22 23:25:23 +00:00
sudden6
e42441e3cf
chore: remove DHT_test.c since it's unused 2022-02-22 22:30:27 +01:00
iphydf
6be655c56c
cleanup: Return boolean constants, not ints from bool functions. 2022-02-22 17:50:17 +00:00
iphydf
b7f95bbe70
cleanup: Remove any disallowed casts.
The ones in toxav weren't needed. The ones in network.c are
non-trivially correct. Now, the code is more easily verifiable.
2022-02-22 02:19:29 +00:00
iphydf
b8ce394e64
fix: Null function pointer dereference. 2022-02-22 01:55:15 +00:00
iphydf
2760966836
cleanup: Avoid casting function pointers.
Also added declarations using the `_cb` type for each of the callback
handlers in tox.h. This forces cppcheck to check whether the parameter
names in the definitions agree with the `_cb` parameter names.
2022-02-21 20:02:47 +00:00
iphydf
f98137d697
refactor: Move tox_new_log to auto_test_support.
This is only used in auto tests.
2022-02-21 17:39:10 +00:00
iphydf
e7bc611dac
cleanup: Enable most cppcheck warnings as errors.
Cleaned up some of the warnings it gives. Disabled the ones that are
less useful for us at this time.
2022-02-21 17:17:36 +00:00
iphydf
86a528a37a
chore: Add a .clang-format that mostly agrees with astyle. 2022-02-21 16:16:16 +00:00
iphydf
a9ccf1be26
cleanup: Remove all implicit bool conversions in if-conditions.
Note to reviewer: please review carefully. This was done manually.
2022-02-21 15:10:22 +00:00
sudden6
fff2b1c4e7
fix: out-of-memory condition by corrupted save file
Don't allocate the memory trusting the values in a toxsave file.
2022-02-21 13:54:32 +01:00
sudden6
12dbafbd18
fix: memory leak during conference load
This was found in our continous fuzzing setup.
2022-02-20 21:23:09 +01:00
iphydf
6a6bc029de
cleanup: Remove unused execution trace library. 2022-02-19 11:44:13 +00:00
iphydf
a6426d7e7a
chore: Make coverity scan a nightly job.
Instead of on every push. It only produces results once a day anyway.
2022-02-19 02:47:36 +00:00
iphydf
68f4e5c0fa
chore: Simplify and speed up windows builds using docker image. 2022-02-19 00:47:37 +00:00
iphydf
c44930d323
chore: Fix build-args in win32/win64 docker build. 2022-02-19 00:46:34 +00:00
iphydf
570485e186
chore: Add docker image builds for windows cross compiler. 2022-02-19 00:08:33 +00:00
Robin Linden
1937ee39c3
Release 0.2.16 2022-02-19 00:51:01 +01:00
iphydf
d46091072d
chore: Remove msan from all CIs except circleci.
It doesn't work yet and is wasting CI resources.
2022-02-18 22:21:01 +00:00
iphydf
c5e3bca6de
chore: Simplify and speed up nacl build using toxchat/nacl. 2022-02-18 22:13:42 +00:00
iphydf
4389c71619
test: Add a profiling script and Dockerfile.
This works on my kernel. If your kernel is older/newer, you may need a
different alpine base image that matches your kernel more closely.
2022-02-18 21:38:55 +00:00
sudden6
fde2a7d16d
fix: properly deallocate frozen peers 2022-02-18 15:59:55 +01:00
iphydf
84a03bc2ed
cleanup: Enable tokstyle's -Wlarge-struct-params. 2022-02-18 10:49:46 +00:00
iphydf
87c38ece30
cleanup: Avoid implicit bool conversions in logical operators. 2022-02-18 10:24:31 +00:00
iphydf
cc045d6343
cleanup: Avoid implicit boolean and floating point conversions in decls.
Also avoid implicit enum-to-int.
2022-02-18 03:26:12 +00:00
iphydf
598a365e1f
fix: Fix return type of functions returning uint64_t.
They were losing precision by going through uint32_t.
2022-02-18 00:30:40 +00:00
iphydf
7b2f6c34c6
cleanup: Apply stronger type checks and fix errors.
Found a bug, too: file recv and chunk events were intermittently
converting to `uint32_t`, losing precision.
2022-02-17 22:34:56 +00:00
jfreegman
0f3534656f
Improve how we share TCP relays with friends
Previously we would try to send three random TCP relays that we're
connected to to each friend once every 5 minutes. The problem with
this method is that it could take an extraordinarily long time
to share every relay; some relays might be consistently skipped
while others might be sent repeatedly. Moreover, there's no
guarantee that the nodes you try to send are actually online.
This leads to a prety unreliable and flaky way of sharing.

Now we reduce the timer to two minutes, and cycle through the list
trying 3 nodes each share attempt. This guarantees that every online
node in our list gets shared with every friend after a fixed amount of
time (which depends on how many nodes are in the list)
2022-02-17 16:16:29 -05:00
iphydf
5e724d8909
cleanup: Avoid implicit pointer-to-bool conversion in if in toxav. 2022-02-17 20:33:24 +00:00
iphydf
933c6b7517
refactor: Compare pointers in if conditions to nullptr.
Don't use implicit ptr-to-bool conversion.
2022-02-17 19:55:29 +00:00
iphydf
43fc2374bc
refactor: Add a bit more logging; change WARNING to ERROR.
ERROR is caught in tests, so we'll use it more for things that ought not
to happen.
2022-02-16 23:05:10 +00:00
jfreegman
1f6edc6139
Fix a file transfer bug introduced in commit 2073d02
This fixes a bug where file transfers would break when the sendto()
system call failed with errno 11 (usually indicating a full packet
buffer).

The max loops constant has also been greatly reduced, as it was
excessively CPU intensive, and most connections would not benefit
from such a high value. In the future it will be set dynamically.
2022-02-15 17:47:25 -05:00