Commit Graph

40 Commits

Author SHA1 Message Date
Antoine Cœur bdac708762
docs: fix various typos and misspellings (#2955) 2022-04-21 09:28:38 -05:00
Charles Kerr 1cc9da26ba
fix: sonarcloud (#2865)
* refactor: implement FileTreeItem::children_ with a std::vector

* fix: std::move should not be called on forwarding reference

* fix: uninitialized scalar variable

* fix: unchecked return value from library

* fix: dereference before null check

* fix: unchecked return value from library

* fix: unchecked return value from library

* fixup! refactor: implement FileTreeItem::children_ with a std::vector

* fix: signed-unsigned comparison in libtransmission tests

* fix: avoid unnecessary copy by using const reference

* fix: function should be declared const

* refactor: use fmt::format to build log timestamps

* fix: use init-statement to reduce variable scope

* fixup! refactor: use fmt::format to build log timestamps

* fix: remove tau_tracker destructor for rule-of-zero

* fix: remove tr_peerIo destructor for rule-of-zero

* Revert "fix: dereference before null check"

This reverts commit cd78967815.

* fix: signed-unsigned comparison in libtransmission tests

* fix: use init-statement to reduce variable scope

* fix: extract nested code block into separate method

* fix: extract nested code block into separate method

* fix: extract nested code block into separate method

* fix: use init-statement to reduce variable scope

* fix: extract nested code block into separate method

* fix: signed-unsigned comparison in libtransmission tests

* fixup! fix: extract nested code block into separate method

* fix: mark possibly-unused as [[maybe_unused]]

* fix: invalid stack memory reference in tr_found_file_t

* fix: signed-unsigned comparison in libtransmission tests
2022-04-02 09:06:02 -05:00
Charles Kerr 33cbe33229
refactor: remove varargs from TR_ASSERT_MSG() (#2861) 2022-04-01 18:00:51 -05:00
Charles Kerr 4177e286a1
fix: sonarcloud (#2837)
* fix: rename variable to avoid shadow warning w/UTP

* fix: add default dtor for tr_strbuf

* fix: implicit conversion may lose precision

* fix: use init-statement to reduce variable scope

* fix: implicit conversion may lose precision

* fix: extract the assignment from this expression

* fix: use init-statement to reduce variable scope

* fix: use init-statement to reduce variable scope

* fix: do not mix public and private data members

* fix: add a condition to cv.wait call

* fix: do not throw uncaught exceptions in destructor
2022-03-29 05:57:04 -05:00
Charles Kerr 9451446e6d
fix: set the destructor log level to trace (#2820)
Fixes #2816.
2022-03-25 14:14:27 -05:00
Charles Kerr 783fa500e7
fix: set the utp state change log level to trace (#2809)
Fixes #2808.
2022-03-24 13:46:34 -05:00
Charles Kerr 04a4f4a10c
refactor: a little more logging (#2800)
Co-authored-by: Mike Gelfand <mikedld@mikedld.com>
2022-03-22 11:45:56 -05:00
Charles Kerr fa8aaf7631
refactor: remove remaining vararg log messages (#2776) 2022-03-17 17:39:06 -05:00
Charles Kerr a942c67199
refactor: use fmt (#2758)
* deps: use fmt (8.1.1 tag) to build log strings

Co-authored-by: Mike Gelfand <mikedld@mikedld.com>
2022-03-13 23:43:35 -05:00
Charles Kerr d2f8e1d4e0
refactor: set logging levels (#2755) 2022-03-11 15:09:22 -06:00
Charles Kerr af339a15ed
refactor: remove deep logging (#2749)
* refactor: remove "deep logging"
2022-03-09 23:51:14 -06:00
Charles Kerr 0ac8c6079a
refactor: remove redundant MAX_BLOCK_SIZE constant (#2740) 2022-03-04 23:35:22 -08:00
Charles Kerr cdd819772d
feat: tr_runInEventThread() now takes std::function, typesafe args (#2739) 2022-03-04 20:26:03 -08:00
Charles Kerr d115ee6dfb
refactor: remove utils dep from peer-io (#2719) 2022-02-28 14:26:26 -08:00
Charles Kerr e94ddc82fc
refactor: use std::string in tr_net_strerror() (#2706) 2022-02-24 18:53:01 -06:00
Charles Kerr 46c7a7c47c
fix: unsupported peer socket type 0 assertion failure (#2687)
* refactor: downgrade unsupported socket type from assertion to log warning

Fixes #833.
2022-02-22 16:10:49 -06:00
Charles Kerr 6383e2ff5f
feat: support dscp classes in socket iptos (#2594)
* refactor: Replace ToS with DSCP

IP TOS was superseded by DSCP in RFC 2474.

Co-authored-by: dgcampea <dgcampea@outlook.com>
2022-02-10 15:35:28 -06:00
Charles Kerr ebb2ab6aee
chore: update license spdx abbreviations (#2582)
Use SPDX license list 3.0 terminology: replace deprecated identifiers
GPL-2.0" and "GPL-3.0" with "GPL-3.0-only" and "GPL-3.0-only".
2022-02-07 10:25:02 -06:00
Charles Kerr e83a57efa3
refactor: re-enable some clang-tidy rules (#2498) 2022-01-24 13:07:55 -06:00
Charles Kerr df1cca9b57
chore: update copyright years, make notices consistent (#2463) 2022-01-20 12:27:56 -06:00
Charles Kerr b0ee4007ff
refactor: include cleanups (#2392)
* refactor: include <memory> when using shared_ptr or unique_ptr

* refactor: include <cstdio> iff we use it

* refactor: include <cstring> iff we use it

* refactor: include <cstdlib> iff we use it

* refactor: include <string_view> or <string> iff we use it

* refactor: include <array> iff we use it

* refactor: include <ctime> iff we use it

* refactor: include <cctype> iff we use it

* refactor: misc #include cleanups in libtransmission
2022-01-12 20:13:58 -06:00
Charles Kerr 0e321c2d21
fix: clang warnings (#2339)
* fix: comparison-is-always-false warning

* fix: C/C++ mixing (memset() to clear a C++ object)
2021-12-25 11:22:12 -06:00
Charles Kerr bd68d3a2fd
refactor: use tr_sha1_digest_t everywhere (#2330) 2021-12-21 16:14:15 -06:00
Charles Kerr f6f0db75e1
fix: sonarcloud warnings / code smells (#2242)
* fix: use-init-statement

Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX1f6EvHJiycnfA7gfrG\&open\=AX1f6EvHJiycnfA7gfrG

* fix replace-use-of-new warning

Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX1ZNs41ZmlvCveKTzon\&open\=AX1ZNs41ZmlvCveKTzon

* fix has-virtual-functions-but-non-virtual-destructor warning

Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX1ZNs72ZmlvCveKTzo6\&open\=AX1ZNs72ZmlvCveKTzo6

* fix make-variable-const warning

Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0_a_OVNJn7rAzml_7B\&open\=AX0_a_OVNJn7rAzml_7B

* fix remove-redundant-static-specifiers

Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX06St-81usi2gyYkPTb\&open\=AX06St-81usi2gyYkPTb

* fix function-should-be-declared-const

Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX06St-81usi2gyYkPTd\&open\=AX06St-81usi2gyYkPTd

* fix use-init-statement warning

Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX06St-81usi2gyYkPTc\&open\=AX06St-81usi2gyYkPTc

* fix class-has-virtual-functions-but-non-virtual-destructor warning

Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX06Stz41usi2gyYkPTS\&open\=AX06Stz41usi2gyYkPTS

* fix remove-commented-out-code warning

Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX06St241usi2gyYkPTT\&open\=AX06St241usi2gyYkPTT

* fix remove-commented-out-code warning

Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX06St241usi2gyYkPTV\&open\=AX06St241usi2gyYkPTV

* fix has-virtual-functions-but-non-virtual-destructor warning

https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX06St241usi2gyYkPTW\&open\=AX06St241usi2gyYkPTW

* fix remove-commented-out-code warning

Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX06SuCA1usi2gyYkPTh\&open\=AX06SuCA1usi2gyYkPTh

* fix use-init-statement warning

Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0rAQvnfJ-O-YIDS9xF\&open\=AX0rAQvnfJ-O-YIDS9xF

* fix use-init-statement warning

Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0rAQvnfJ-O-YIDS9xG\&open\=AX0rAQvnfJ-O-YIDS9xG

* fix remove-redundant-access-specifier warning

Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX1ZNs5tZmlvCveKTzor\&open\=AX1ZNs5tZmlvCveKTzor

* fix use-init-statement warning

Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX01Itl7f_SST5i7BN1l\&open\=AX01Itl7f_SST5i7BN1l

* fix use-init-statement warning

Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0wDijI2l89lDvp1C9P\&open\=AX0wDijI2l89lDvp1C9P

* fix use-automatically-managed-memory-instead-of-new warning

Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX1f6E6HJiycnfA7gfrI\&open\=AX1f6E6HJiycnfA7gfrI

* fix use-init-statement warning

Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0l8vknEafnvRiIHUEv\&open\=AX0l8vknEafnvRiIHUEv

* fixup! fix has-virtual-functions-but-non-virtual-destructor warning
2021-11-27 19:58:35 -06:00
Charles Kerr da855a7257
refactor: use std mutex/lock intead of bespoke (#2194)
* refactor: use std mutex/lock intead of bespoke
2021-11-20 15:20:45 -06:00
Charles Kerr 3d38e01a13
refactor: tr_session.congestion (#2151)
* refactor: tr_session.congestion
2021-11-14 00:41:44 -06:00
Charles Kerr c472cbd88d
refactor: only use [[maybe_unused]] if arg might be used (#2033)
* refactor: [[maybe_unused]] iff arg _might_ be used

If the arg is never used, comment out its name.
If the arg is _sometimes_ used e.g. with ifdefs, use [[maybe_unused]].
2021-10-24 11:41:54 -05:00
Charles Kerr 9e716bb9dc
refactor: cppcoreguidelines-init-variables pt. 10 (#2006)
* refactor: uninit vars in peer-io.cc

* refactor: uninit vars in rpc-server.cc

* refactor: uninit vars in port-forwarding.cc

* refactor: uninit vars in torrent-ctor.cc
2021-10-22 08:51:36 -05:00
Charles Kerr b491da0ce4
refactor: add tr_peer_id_t (#2004)
* refactor: move handshake_done args into a convenience struct

* refactor: move peer_id from peerIo to tr_handshake

tr_handshake is a short-term object and tr_peerIo is long-term, so this
effectively narrows the scope of this field.

* chore: remove unused field tr_peerIo.isEncrypted

* refactor: add tr_peer_id_t type to hold peer ids.

this is a 'using' alias to a std::array<> so that code passing peer-ids
around doesn't have to memcmp / memcpy PEER_ID_LEN anymore. Also removes
the now-unused PEER_ID_LEN macro.
2021-10-21 21:40:55 -05:00
Charles Kerr fd5804fbb7
refactor: add readability-else-after-return to clang-tidy (#1956)
* refactor: add readability-else-after-return to clang-tidy
2021-10-14 14:26:38 -05:00
Charles Kerr 62372602b4
refactor: run clang-tidy on bandwidth.h, .cc (#1930)
* chore: allow vararg calls in qt/.clang-tidy

An awkward PR since this isn't intended for the qt/ codebase at all, but
rather for use with libtransmission instead. But libtransmission is *so*
noncompilant at this point that this config can't be promoted higher up
the tree yet. Instead, it needs to be callable on-request by devs.

* refactor: make clang-tidy happy with bandwidth.h, .cc

* refactor: use getFooSpeedBytesPerSecond()
2021-10-12 01:04:22 -05:00
Charles Kerr 02b9e17207
refactor: make tr_peerIo a class (#1928)
* refactor: make tr_peerIo a class

No behavioral changes.

Use `new` and `delete` and change `struct` references to `class`.

* refactor: make some tr_peerIo fields const

* refactor: reorganize tr_peerIo fields to remove padding holes

* refactor: remove redundant field tr_peerIo.isIncoming

* refactor: make tr_peerIo.inbuf, .outbuf fields const*
2021-10-11 16:54:16 -05:00
Charles Kerr 1fb5a79813
refactor: use maybe unused attribute (#1918)
* refactor: replace TR_UNUSED with [[maybe_unused]]
2021-10-10 11:52:26 -05:00
Dmytro Lytovchenko a4d7e11a14
Bandwidth.cc bring naming closer to C++ style of code in qt/ (#1914)
* Modernize bitfield.cc: Rename tr_bandwidth to Bandwidth; Move dependent structs and consts into it

* Modernize bitfield.cc: Rename internal fields to lower_snake_case_ with suffix underscore

* Modernize bitfield.cc: Remove struct in 'struct Bandwidth' type usages

Co-authored-by: Charles Kerr <charles@charleskerr.com>
2021-10-09 20:12:03 -05:00
Dmytro Lytovchenko c287b82c00
Modernize bandwidth.cc: Moved functions inside struct (#1895)
* Modernize bandwidth.cc: Move functions inside struct

* Modernize bandwidth.cc: Review notes - remove extraneous checks, move small functions into .H file, etc

* Modernize bandwidth.cc: Construction and destruction is now via C++ new/delete

* Modernize bandwidth.cc: Rename used() to notifyBandwidthConsumed()

* Modernize bandwidth.cc: Children is now unordered_set

* Modernize bandwidth.cc: Allocation functions for peer bandwidth are now using std::vector instead of ptrArrays

* Modernize bandwidth.cc: Code formatting

* Modernize bandwidth.cc: Private fields after public; Minor review notes

* Modernize bandwidth.cc: Ungroup enums into constants; Docs minor update

* Modernize bitfield.cc: Docs comments changes; Using constexpr instead of const

Co-authored-by: Charles Kerr <charles@charleskerr.com>
2021-10-09 07:52:09 -05:00
Charles Kerr 396afd8a42
refactor: remove unused tr_variant_string.session (#1881)
This was assigned but never used. Shrinks sizeof(tr_bandwidth) by 8 bytes.
2021-10-05 19:06:18 -05:00
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
Charles Kerr 7e06c6401f
fix: clang warnings (#1814)
* fix: clang nullptr dereference warning in peer-io

* fix: shared variable name clang warning in peer-io

* fix: clang nullptr dereference warning in bitfield

* fix: shadowed variable in session.cc's parse_tos()

* fix: shadowed variable warning in sessionSetImpl()

* fix: tr_stringEndsWith() shadowed variable warning

* fix: a tr_peerMgrGetNextRequests() nullptr warning
2021-09-16 23:21:50 -05:00
Dmytro Lytovchenko 43d1ece562
C++ modernization: Replace NULLs with typesafe nullptrs (#1799)
Fixing CI errors and build errors
Reverted changes: NULL in EV_SET macro; Clang-formatting
Reverted changes: MacosX *.m files reverted from master
2021-09-14 19:18:09 -05:00
Charles Kerr 4c1b627647
refactor: port libtransmission to C++ (#1787)
Port libtransmission to C++. This PR doesn't refactor everything to c++.
Its code changes are only what was necessary to compile and link as c++.
See libtransmission/README.md for details on how to submit modernization 
patches!

Co-authored-by: Mike Gelfand <mikedld@mikedld.com>
2021-09-12 12:41:49 -05:00
Renamed from libtransmission/peer-io.c (Browse further)