Commit Graph

148 Commits

Author SHA1 Message Date
tearfur
41cfdce6fd refactor: replace some C idioms with C++ ones (#5656)
* tidy up legecy practices

* remove undefined std::ignore usage

* avoid extra function stack level in daemon.cc
2023-06-22 17:58:16 -05:00
Mike Gelfand
8ca02b8f28 Avoid locale use in tr_truncd() (#5587)
`tr_parseNum<>()` is implemented with `fast_float::from_chars()`, and
the latter is documented as "expecting a locale-indepent format
equivalent to what is used by std::strtod in the default ("C") locale".
To accomodate locale independent number parsing, switch back to
locale-independent number formatting in `tr_truncd()` by both removing a
`L` format specifier from `fmt::format_to_n()` call and using a fixed
"." decimal separator when truncating the value.
2023-06-10 17:09:18 -05:00
Mike Gelfand
e8fcb025a0 fix: use user-preferred locale (#5444)
* Use user-preferred locale

Previous fix adding `L` format specifier was correct but only fixed half
of the problem, as C++ locale is set up to be "C" by default. GTK client
used to call `setlocale(LC_ALL, "")` to set up user-preferred locale
which only affected C functions and `std::locale` (used by libfmt) was
unaware of those changes.

Apply the fix to all the binaries since they're all doing some sort of
output to the user and calling libtransmission helpers, as well as using
libfmt directly.

* Improve libtransmission's json-test

Set the locale C++ way to avoid any sort of inconsistencies, and also
restore it to the old one once finished testing.

* Improve transmission-show test runner script

Quote outputs to avoid CMake error about `message()` being called with
no arguments. Capture stderr to the same output file. Fallback to `git
diff` if `diff` wasn't found. A few other minor changes.
2023-04-27 09:10:33 -05:00
Charles Kerr
7d86d67bc7 chore: prefer fmt/core.h over fmt/format.h (#5404) 2023-04-16 15:34:19 -05:00
Charles Kerr
d72cb67cfb chore: include directory name in libtransmission #includes (#5308) 2023-04-14 14:33:23 -05:00
Cœur
afa9f64feb refactor: align tr_formatter_speed_KBps with stringForSpeed: kb: mb: gb: (#5108) 2023-04-14 10:36:34 -05:00
Mike Gelfand
a216bd7cec Use locale-dependent decimal separators for user-visible numbers (#5288)
This includes percents, ratios, sizes, speeds, etc. coming from shared
formatting helpers. Previously based on sprintf-like functions using
locale, now using libfmt which doesn't use locale by default and needs
to be instructed to do it explicitly.
2023-03-23 19:48:45 -05:00
Cœur
c60bb5b834 fix: crash when magnet dn isn't utf-8 (#5244) 2023-03-19 10:36:16 -05:00
Julien
4b8cfa2e57 chore: update copyrights to 2023 (#4834) 2023-02-11 14:49:42 -06:00
Charles Kerr
724a0f48f0 fix: clang-tidy header warnings (#4686) 2023-01-28 17:58:20 -06:00
Charles Kerr
7367d465b5 style: use the new paragraph comment style everywhere (#4634) 2023-01-22 13:21:30 -06:00
Dmitry Antipov
acbf483bae refactor: switch to C++11-compatible tr_wait() from tr_wait_msec() (#4576) 2023-01-12 12:03:14 -06:00
Charles Kerr
8b1290c895 build: remove explicit iconv dependency in libtransmission (#4565) 2023-01-08 22:21:31 -06:00
Charles Kerr
9678b26984 refactor: misc-use-anonymous-namespace pt. 3 (#4539) 2023-01-07 08:27:54 -06:00
Mike Gelfand
105d23c09e Fix clang-tidy issue in iconv 2nd argument helper (#4520)
Since operators were intentionally implicit and we don't want to add more
`NOLINT` comments than necessary, rework the approach to deduce the argument
type instead and cast to it.
2023-01-02 22:59:53 +00:00
Mike Gelfand
57e6b06921 Modernize CMake code (ongoing refactoring) (#4515)
* Use imported CMake target for CURL

* Use imported CMake target for fmtlib

* Use imported CMake target for WideInteger

* Use imported CMake target for FastFloat

* Use imported CMake target for UtfCpp

* Use imported CMake target for Threads

* Use imported CMake target for Iconv

* Use imported CMake target for crypto backend

* Use imported CMake target for GTK

* Use imported CMake target for Qt

* Use imported CMake target for deflate

* Use imported CMake target for libevent

* Use imported CMake target for natpmp

* Use imported CMake target for miniupnpc

* Use imported CMake target for dht

* Use imported CMake target for psl

* Use imported CMake target for libutp

* Use imported CMake target for libb64

* Use include directories from libtransmission target
2023-01-02 16:23:51 +00:00
Mike Gelfand
128cf34123 Move jsonsl and wildmat to third-party (#4402)
* Move jsonsl to third-party

This treats it as proper 3rd-party code to which our warning and style
settings don't extend.

* Move wildmat to third-party

This treats it as proper 3rd-party code to which our warning and style
settings don't extend.

* Fixup Xcode project to match new project structure
2022-12-18 19:19:07 +00:00
Cœur
9e0b42a61d Fixed logic in tr_wildmat (#4353) 2022-12-12 16:35:40 -06:00
Charles Kerr
59335eac03 fix: sonarcloud cpp:S6004 (#4270)
reduce scope of variables by using if-based initializer
2022-11-28 21:03:28 -06:00
Charles Kerr
49393daf01 refactor: use std::optional.value_or() (#4255) 2022-11-27 14:56:34 -06:00
Charles Kerr
250e055c1d fix: warnings from clang tidy sonarcloud coverity (#4143) 2022-11-12 09:53:09 -06:00
Charles Kerr
162035a653 fix: minor recent clang warnings (#4111)
* refactor: fix modernize-use-default-member-init warning in session-thread.cc

* refactor: fix readability-named-parameter warning in session-thread.cc

* refactor: fix clang-diagnostic-unused-function warning for isSupportedSocket()

* refactor: fix clang-analyzer-deadcode.DeadStores warning in buildHandshakeMessage()

* chore: fix readability-identifier-naming warning for tr_session::session_mutex_

* chore: fix readability-identifier-naming warning for Watchdir::generic_rescan_interval_

* chore: fix readability-identifier-naming warning for __tr_current_time
2022-11-07 11:48:26 -06:00
Charles Kerr
09bb1a60f0 refactor: add more nodiscard, constexpr, and noexcept (#4089) 2022-11-03 18:08:02 -05:00
A Cœur
12e564096b fix: "Implicit conversion loses integer precision" warnings (#3960) 2022-10-25 11:14:42 -05:00
Charles Kerr
56e0a1bda8 chore: add cppcoreguidelines-pro-type-member-init to libtransmission/.clang-tidy (#3840) 2022-09-23 00:51:15 -05:00
Charles Kerr
dd12fd010a chore: iwyu headers (#3833) 2022-09-21 18:34:18 -05:00
Charles Kerr
1782dc6d7a refactor: use readability-identifier-naming in clang-tidy (#3784) 2022-09-07 11:04:28 -05:00
Charles Kerr
1062ae8f1f refactor: split tr_parseNum inout var into two vars (#3748)
build: re-enable cert-err34-c warning
2022-09-02 01:04:09 -05:00
Charles Kerr
cee339e10d refactor: remove tr_removeElementFromArray() (#3731) 2022-08-28 21:51:26 -05:00
Charles Kerr
a24679d89f refactor: modernize-avoid-c-arrays pt. 2 (#3713) 2022-08-26 13:35:28 -05:00
Charles Kerr
e8686095ed refactor: local peer discovery (#3696) 2022-08-24 16:03:30 -05:00
Charles Kerr
c532728c42 refactor: remove TR_N_ELEMENTS macro (#3674)
* refactor: use std::array for keys in transmission-remote

* refactor: use std::array for wide_module_path in platform.cc

* refactor: use std::array for value in tr_env_get_int()

* refactor: use std::array for SysStoreNames in web.cc

* chore: remove unused macro TR_N_ELEMENTS
2022-08-18 21:31:53 -05:00
Charles Kerr
c171d6df7c refactor: remove tr_utf8_validate from public API (#3671)
it was only used as an impl helper, so make it private
2022-08-18 13:23:59 -05:00
Charles Kerr
76a7994eef refactor: remove tr_free() (#3668) 2022-08-18 09:14:12 -05:00
Charles Kerr
963a8112a1 refactor: remove tr_strvDup() (#3666) 2022-08-17 21:18:44 -05:00
Charles Kerr
36675d183a refactor: avoid tr_new() in tr_main_win32() (#3664) 2022-08-17 18:26:52 -05:00
Charles Kerr
7fe2cf68b9 refactor: avoid tr_new(), tr_free() in tr_variant (#3663)
* refactor: remove unused tr_renew()

* refactor: remove unused tr_realloc()

* refactor: avoid tr_strvDup() in tr-quark
2022-08-17 14:44:18 -05:00
Charles Kerr
29f57bc296 chore: iwyu headers (#3661) 2022-08-17 11:08:36 -05:00
Charles Kerr
6b25a57899 refactor: don't use tr_free in tr_strvUtf8Clean() (#3658) 2022-08-16 21:47:07 -05:00
Charles Kerr
e49747ab51 feat: add tr_strvToBuf() (#3657)
* feat: add tr_getDefaultConfigDirToBuf()

* feat: add tr_getDefaultDownloadDirToBuf()

* feat: add tr_strvToBuf()

* feat: add tr_torrentFindFileToBuf()

* feat: add tr_torrentGetMagnetLinkToBuf()

* refactor: remove unused makeString() from tests

* feat: add tr_torrentFilenameToBuf()

* feat: add tr_torrentGetTrackerListToBuf()

* chore: remove obsolete comment references to tr_free

* chore: remove unused tr_strdup()

* chore: remove unused forward declarations
2022-08-16 19:28:57 -05:00
Charles Kerr
c7466b3ff4 fix: coverity warnings (#3632)
* fix: uninitialized field natpmp

* fix: unchecked downcast result

* fix: potential tr_error leak

* fix: potential tr_error leak

* fix: potential tr_error leak

* fix: potential nullptr dereference in test fixtures

* fix: handshake fields not initialized in constructor

* chore: cast unchecked return value to void

* chore: cast unchecked return value to void

* chore: cast unchecked return value to void

* chore: make single-arg constructors explicit

* fix: code smell make variable a pointer-to-const

* fix: code smell make variable a pointer-to-const

* chore: make single-arg constructors explicit

* chore: silence sonarcloud false warning on commented-out-code

* chore: fix code smell use std::array

* chore: make EvTimer::handleTimer() const

* chore: mark tr_bandwidth remove_child as noexcept
2022-08-13 12:11:07 -05:00
Charles Kerr
63eab54fd5 refactor: timer pt 2 (#3617)
* feat: add convenience variants of TimerMaker::create()

* refactor: use libtransmission::Timer in peer-mgr

* refactor: use libtransmission::Timer in peer-msgs

* refactor: use libtransmission::Timer in tr-utp

* refactor: use libtransmission::Timer in tr-dht

* refactor: use libtransmission::Timer in port-forwarding

* refactor: use libtransmission::Timer in webseed

* refactor: use libtransmission::Timer in tr-lpd

* refactor: use libtransmission::Timer in rpc-server

* chore: remove unused function tr_timerAdd()

* chore: remove unused function tr_gettimeofday()

* fixup! chore: remove unused function tr_timerAdd()

* fixup! refactor: use libtransmission::Timer in port-forwarding
2022-08-11 12:28:37 -05:00
Charles Kerr
c66303fae2 refactor: watchdir (#3606) 2022-08-10 08:34:51 -05:00
Charles Kerr
31a733fab7 refactor: make tr_session_id a class (#3598) 2022-08-06 14:27:37 -05:00
Charles Kerr
4bc1589c5d refactor: remove tr_win32_utf8_to_native_ex() (#3590) 2022-08-05 14:16:25 -05:00
Charles Kerr
8b983b3d1c refactor: tr_sys_path_resolve() returns a std::string (#3587)
* refactor: tr_sys_path_resolve returns std::string
2022-08-05 11:36:01 -05:00
Charles Kerr
ef34c7c4dc refactor: use std::wstring on win32 (#3578) 2022-08-03 18:07:38 -05:00
Charles Kerr
dab81c1af6 fix: readability-inconsistent-declaration-parameter-name warnings in libtransmission (#3572) 2022-08-03 01:15:37 -05:00
Charles Kerr
5eb7f75010 refactor: tr_sys_path_get_info() now returns a tr_sys_path_info (#3566)
* refactor: tr_sys_path_get_info() now returns a tr_sys_path_info

* refactor: tr_sys_file_get_info() now returns a tr_sys_path_info
2022-08-02 12:41:04 -05:00
Charles Kerr
fa6ba14dc3 refactor: remove closure struct in tr-dht (#3550)
This was the last use of tr_memdup(), so remove that too
2022-07-29 14:38:43 -05:00