Commit Graph

11 Commits

Author SHA1 Message Date
Dmytro Lytovchenko 312d18281d
C++ modernize: Replace MIN/MAX with type safe std::min/std::max (#1806)
* C++ modernize: Replace MIN/MAX with type safe std::min/std::max

* Template std::min/max invocations now explicitly use largest integer type

* torrent.cc did not have <algorithm> included

* MIN/MAX Changes for subprocess-win32.cc

* Using type{} style cast instead of template parameter in std::min/max

* 32-bit type cast errors with uint64_t versus size_t

* 32-bit type cast errors inout.cc and file.cc

* Missing include in windows code; Type cast error fixed

* Missing macro in win32 daemon; Replaced MIN in commented code with std::min

* Update libtransmission/tr-getopt.cc

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>

* Update libtransmission/file-posix.cc

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>

* Update tests/libtransmission/copy-test.cc

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>

* Update libtransmission/peer-mgr.cc

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>

* Strlen returns size_t, remove cast

Co-authored-by: Charles Kerr <charles@charleskerr.com>
Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>
2021-09-19 15:41:35 -05:00
Mike Gelfand db3d40d0ed Switch to clang-format for code formatting, include Mac client 2021-08-16 00:38:29 +03:00
Charles Kerr a4dd67ae45
chore: fix some fixmes (#1449)
* chore: remove assertions that were flagged for removal

* chore: remove unneeded check

* refactor: move tr_peerIoAddrStr to net.h

* refactor: formatter API now takes size_t args

* chore: remove out-of-date FIXME comment

* refactor: cleanup logging win32 ifdefs
2020-09-13 16:43:29 -05:00
Charles Kerr e127b20c05
chore: fix compiler warnings (#1412)
* chore: fix compiler warnings
2020-08-27 18:41:26 -05:00
Mike Gelfand ff8d0dbf3b Switch from UNUSED macro to TR_UNUSED macro
Since there is no way to mark parameters as [potentially] unused in
standard C and when using MSVC compiler, use the widely accepted
cast-to-void approach instead.
2020-08-18 14:19:55 +03:00
Mike Gelfand 077f4d8d2b Require C11, switch to standard static_assert 2020-08-18 14:19:55 +03:00
Charles Kerr 677dc73eac
refactor: use GTest for running tests (#1383)
* refactor: use google-test on libtransmission tests
2020-08-11 13:11:55 -05:00
Charles Kerr abac811dd2
fix: gcc warnings in libtransmission/ and utils/ (#843)
* fix: __attribute__(__printf__) warnings

* fix: implicit fallthrough warning

* fixup! fix: implicit fallthrough warning

* fix: disable warnings for 3rd party code

Since we want to leave upstream code as-is

* fixup! fix: disable warnings for 3rd party code

* fixup! fix: disable warnings for 3rd party code

* silence spurious alignment warning

Xrefs
Discussion: https://stackoverflow.com/a/35554349
Macro inspiration: 90ac46f710/f/src/util/util_safealign.h (_35)

* fixup! fix: disable warnings for 3rd party code

* fixup! fix: implicit fallthrough warning

* make uncrustify happy

* remove uncrustify-test.sh

that's probably off-topic for this PR

* fixup! fix: __attribute__(__printf__) warnings

* Update libtransmission/CMakeLists.txt

Co-Authored-By: ckerr <ckerr@github.com>

* fixup! silence spurious alignment warning

* use -w for DISABLE_WARNINGS in Clang

* refactor: fix libtransmission deprecation warnings

* fix: pthread_create's start_routine's return value

This was defined as `void` on non-Windows but should have been `void*`

* chore: uncrustify

* fix: add DISABLE_WARNINGS option for SunPro Studio

* fix "unused in lambda capture" warnings by clang++

* fix 'increases required alignment' warning

Caused from storing int16_t's in a char array.

* fix net.c 'increases required alignment' warning

The code passes in a `struct sockaddr_storage*` which is a padded struct
large enough for the necessary alignment. Unfortunately it was recast as
a `struct sockaddr*` which has less padding and a smaller alignment. The
warning occrred because of these differing alignments.

* make building quieter so warnings are more visible

* fixup! fix 'increases required alignment' warning

* Fix -Wcast-function-type warnings in GTK+ app code

https://gitlab.gnome.org/GNOME/gnome-terminal/issues/96 talks about both
the issue and its solution.

GCC 8's -Wcast-function-type, enabled by -Wextra, is problematic in glib
applications because it's idiomatic there to recast function signatures,
e.g. `g_slist_free(list, (GFunc)g_free, NULL);`.

Disabling the warning with pragmas causes "unrecognized pragma" warnings
on clang and older versions of gcc, and disabling the warning could miss
actual bugs. GCC defines `void (*)(void)` as a special case that matches
anything so we can silence warnings by double-casting through GCallback.

In the previous example, the warning is silenced by changing the code to
read `g_slist_free(list, (GFunc)(GCallback)g_free, NULL);`).

* fixup! fix "unused in lambda capture" warnings by clang++

* fixup! fix "unused in lambda capture" warnings by clang++

* fix two more libtransmission compiler warnings

* fix: in watchdir, use TR_ENABLE_ASSERTS not NDEBUG
2019-11-06 11:27:03 -06:00
Mike Gelfand 82df3a87f4 Update to Uncrustify 0.68.1
Tweak a few rules in the process. Now all code in cli, daemon, gtk,
libtransmission, qt, and utils is properly formatted with no manual
intervention.
2019-02-15 09:21:48 +03:00
Mike Gelfand 30c7c05cbb Refactor completion scripts execution
There're still a few issues here and there, but overall I believe it's now
better than it was before.
2017-11-28 10:03:08 +03:00
Mike Gelfand f701d501a8 Move generic macros to a separate tr-macros.h file 2017-06-18 17:11:20 +03:00