Commit Graph

143 Commits

Author SHA1 Message Date
iphydf 8b4eae4038 Remove TOX_DEBUG and have asserts always enabled.
These are cheap asserts. I've also replaced the fprintf's with
`LOGGER_ERROR` calls.
2017-01-11 19:43:08 +00:00
David Zero 8ef1f35ca7 Revert "Revert "Portability fixes""
This reverts commit 59e2a844f0, and
defines _DARWIN_C_SOURCE in toxcore/network.c
2017-01-06 04:20:00 -08:00
endoffile78 59e2a844f0 Revert "Portability fixes"
This reverts commit f3469070fe.
2017-01-05 15:16:56 -06:00
David Zero f3469070fe Portability fixes
- CFLAG gnu99 was changed to c99.
- CXXFLAG c++98 was changed to c++11.
- CFLAG -pedantic-errors was added so that non-ISO C now throws errors.
- _XOPEN_SOURCE feature test macro added and set to 600 to expose SUSv3
  and c99 definitions in modules that required them.
- Fixed tests (and bootstrap daemon logging) that were failing due to
  the altered build flags.
- Avoid string suffix misinterpretation; explicit narrowing conversion.
- Misc. additions to .gitignore to make sure build artifacts don't wind
  up in version control.
2017-01-04 13:44:39 -08:00
iphydf 96c672aef5 Compile as C++ for windows builds.
Compiling as C++ changes nothing semantically, but ensures that we don't
break C++ compatibility while also retaining C compatibility.

C++ compatibility is useful for tooling and additional diagnostics and
analyses.
2016-11-02 18:50:41 +00:00
iphydf 1977d56caa Remove return after no-return situation (and other cleanups).
Cleanups:
- Fix header guards to not use reserved names.
- Avoid name shadowing.
- Removed an unused variable found by avoiding name shadowing.
2016-09-30 19:06:44 +01:00
iphydf 15cb426166 Make toxcore code C++ compatible.
It is still C code, so still compatible with C compilers as well. This
change lets us see more clearly where implicit conversions occur by
making them explicit.
2016-09-24 21:53:50 +01:00
iphydf 0d347c2b2e Minor cleanups: unused vars, unreachable code, static globals.
- All global variables should be static unless they have an explicit
  extern declaration in a header file.
- `to_compare` was not used in encryptsave and toxav tests.
- `break` in switch cases is not required directly after `return`,
  `goto`, or a noreturn function like `abort`.
2016-09-24 20:52:09 +01:00
iphydf 63e0008b7d const-correctness in windows code. 2016-09-16 14:45:52 +01:00
iphydf 1494e474dd Ensure that all TODOs have an owner.
In the future, all TODOs added either need a bug number (TODO(#NN)) or a
person's github user name. By default, I made irungentoo the owner of
all toxcore TODOs, mannol the owner of toxav TODOs, and myself the owner
of API TODOs.
2016-09-16 12:06:02 +01:00
iphydf a8823830d3 Add some astyle options to make it do more.
It now enforces a bit more formatting. In particular, padding inside
parentheses is removed. I would like it to remove padding after unary
operators, but there seems to be no option for that.
2016-09-13 01:07:02 +01:00
iphydf 0aa2840164 Group #include directives in 3-4 groups.
1. Current module (if C file).
2. Headers from current library.
3. Headers from other library (e.g. toxcore includes in toxav).
4. System headers.
2016-09-13 00:32:02 +01:00
iphydf ad26560516 Improve static and const correctness.
- Any non-externally-visible declarations should be `static`.
- Casting away the `const` qualifier from pointers-to-const is
  dangerous. All but one instance of this are now correct. The one
  instance where we can't keep `const` is one where toxav code actually
  writes to a chunk of memory marked as `const`. This code also assumes
  4 byte alignment of data packets. I don't know whether that is a valid
  assumption, but it's likely unportable, and *not* obviously correct.
- Replaced empty parameter lists with `(void)` to avoid passing
  parameters to it. Empty parameter lists are old style declarations for
  unknown number and type of arguments.
- Commented out (as `#if DHT_HARDENING` block) the hardening code that
  was never executed.
- Minor style fix: don't use `default` in enum-switches unless the number
  of enumerators in the default case is very large. In this case, it was
  2, so we want to list them both explicitly to be warned about missing
  one if we add one in the future.
- Removed the only two function declarations from nTox.h and put them
  into nTox.c. They are not used outside and nTox is not a library.
2016-09-06 11:54:37 +01:00
iphydf a9fbdaf46b Do not use else after return.
http://llvm.org/docs/CodingStandards.html#use-early-exits-and-continue-to-simplify-code
2016-09-02 11:02:56 +01:00
iphydf 576f130615 Remove redundant return statements. 2016-08-31 23:51:39 +01:00
iphydf 3a9300368d Add newlines because astyle wants them.
We'll revert this once we move to clang-format.
2016-08-31 20:54:20 +01:00
iphydf 633da98ae6 Add braces to all if statements. 2016-08-31 20:04:16 +01:00
iphydf 13ae9e9a93 Move logging to a callback.
This removes the global logger (which by the way was deleted when the first tox
was killed, so other toxes would then stop logging). Various bits of the code
now carry a logger or pass it around. It's a bit less transparent now, but now
there is no need to have a global logger, and clients can decide what to log and
where.
2016-08-27 01:16:14 +01:00
iphydf a5e35180c7 Make tox_callback_friend_name stateless.
See #27 and #40 for details.
2016-08-18 00:01:53 +01:00
iphydf db22522741 Add missing DHT_bootstrap to CMakeLists.txt.
- This PR also adds a DEBUG cmake option that enables -DTOX_DEBUG.
- We also remove `-Wall`, because there are too many warnings, and nobody really
  looks at them at the moment. We'll see about fixing them soon. We'll also want
  to enable `-Werror` at some point.
- Finally, this PR enables `-O3` to make sure toxcore still works correctly
  under heavy compiler optimisations.
2016-08-17 22:12:39 +01:00
iphydf 5d26ce1cf5 Fix a bug I introduced that would make toxcore fail to initialise a second time.
sodium_init returns 1 when the library was already initialised. Toxcore code
wasn't prepared to handle sodium errors, so it thought it was an allocation
error.

This error is still not handled correctly. If crypto fails to initialise, it
will think it's an allocation error. Fixing this requires too many code changes,
so must be done later.
2016-08-11 18:14:54 +01:00
iphydf fc330c1fa5 Silence/fix some compiler warnings.
Some of these (like the incompatible pointers one) are really annoying for
later refactoring.
2016-08-10 13:52:40 +01:00
Roman Yepishev c886f906a8 Move argument comments to the end of line 2016-02-27 14:32:49 -05:00
Roman Yepishev 9035325e56 Remove magic numbers from addr_resolve
* Add #defines for INET/INET6 returns
* Remove magic number 3 - exact AF_INET/INET6 result found.
* Updated network_test.c
2016-02-27 11:45:02 -05:00
Roman Proskuryakov 7d66c70037 add: more comments into network.c 2016-01-27 02:14:59 +03:00
Eniz Vukovic d6fdf16520 New Adaptive BR algorithm, cleanups and fixes 2015-10-10 23:54:23 +02:00
irungentoo 0045ace8a8 Small cleanups. 2015-05-02 21:55:42 -04:00
irungentoo 2ff39d3d54 Fixed windows warning. 2015-04-14 20:56:16 -04:00
irungentoo d05e39274c Make tox_new return TOX_ERR_NEW_PORT_ALLOC for all socket related errors. 2015-04-13 08:32:33 -04:00
irungentoo 405558258d Enable SO_REUSEADDR on TCP server socket. 2015-04-11 20:24:39 -04:00
irungentoo 7afab000f7 tox_new now sets error to TOX_ERR_NEW_PORT_ALLOC when binding to port fails. 2015-03-12 13:03:14 -04:00
irungentoo 73b9cf48f9 Merge branch 'worfox-new_api' into new_api 2015-03-08 19:08:33 -04:00
Christoffer Sterner 3315fd2571 Change LOGGER_DEBUG to LOGGER_ERROR for fail bind 2015-03-07 23:45:00 +01:00
Christoffer Sterner 10ca292f24 Change fprintf debug into LOGGER_DEBUG for consistency 2015-03-07 22:39:27 +01:00
irungentoo 2af1608059 Fixed debug fprintf. 2015-03-07 16:16:25 -05:00
irungentoo 7a82565c8c Merge branch 'port_range_option' of https://github.com/saneki/toxcore into new_api 2015-03-02 21:03:34 -05:00
saneki 6e8762b30a Allow for specifying the port range to use in Tox_Options 2015-02-27 11:58:00 -06:00
mannol ad67259535 Logger fix 2015-01-10 23:29:00 +01:00
irungentoo 93a998d15a Code cleanups.
Moved some functions to onion.c.

Fixed possible portability issues.
2015-01-01 21:30:42 -05:00
irungentoo 8ac13beea4 Code cleanup.
Added length checks to ipport_pack() function.
2014-12-31 15:24:09 -05:00
Maxim Biro 377da127a1 Added HTTP proxy support 2014-12-13 23:59:50 -05:00
irungentoo 6bbb939855 Cleaned up packet length types in toxcore.
They are now all uint16_t instead of sometimes being uint32_t.

Replaced some other uint32_t with unsigned ints.
2014-11-21 20:18:29 -05:00
irungentoo 38c411ec3a Fixed iOS possible SIGPIPE issue.
Apparently on iOS UDP sockets can SIGPIPE (what the fuck apple?).
2014-09-03 07:49:51 -04:00
irungentoo 1298932deb UDP can now be disabled.
new_messenger() now takes an options struct as an argument.
2014-08-14 15:27:34 -04:00
irungentoo dbab15cf0c Remove useless code. 2014-08-14 14:43:01 -04:00
irungentoo 97ad1e62b6 Added addr_parse_ip() to network.h header.
Removed useless semicolons.
2014-07-20 20:08:00 -04:00
irungentoo bd6f8a2186 Merge branch 'mannol1-master' 2014-06-28 22:29:39 -04:00
notsecure 1f5496e43b remove pointer type warnings when building with mingw 2014-06-27 07:38:36 -04:00
Tux3 / Mlkj / !Lev.uXFMLA 3044bd8101 Fix CppCheck style errors
#if 0 the content of toxav/msi.c : int stringify_message(MSIMessage
*msg, char *dest)
This function has no effect and does not seem to be used for actively
waiting.

Fix various other style errors, reduce scope when possible, avoid
redundant writes, clarify operator priorities, etc.
2014-06-20 21:43:21 +02:00
irungentoo 07936960df Astyle and fixes. 2014-06-10 18:35:55 -04:00