fix: silence some sonarcloud warnings (#1493)

* refactor: add null ptr check in initPeerRow()

* refactor: add a nullptr gurad in icon_cache_get_mime_type_icon

* chore: silence two "break notreached" warnings

* chore: silence sonarcloud html warnings

* chore: silence sonarcloud uninitialized var warning

* chore: silence sonarcloud nullptr warning
This commit is contained in:
Charles Kerr 2020-10-31 16:23:43 -05:00 committed by GitHub
parent 973e63d897
commit e59fe7daaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 74 additions and 62 deletions

View File

@ -1390,15 +1390,16 @@ static GtkListStore* peer_store_new(void)
static void initPeerRow(GtkListStore* store, GtkTreeIter* iter, char const* key, char const* torrentName,
tr_peer_stat const* peer)
{
int q[4];
char collated_name[128];
char const* client = peer->client;
g_return_if_fail(peer != NULL);
char const* client = peer->client;
if (client == NULL || g_strcmp0(client, "Unknown Client") == 0)
{
client = "";
}
int q[4];
char collated_name[128];
if (sscanf(peer->addr, "%d.%d.%d.%d", q, q + 1, q + 2, q + 3) != 4)
{
g_strlcpy(collated_name, peer->addr, sizeof(collated_name));

View File

@ -183,20 +183,15 @@ static GdkPixbuf* _get_icon_pixbuf(GIcon* icon, int size, GtkIconTheme* theme)
static GdkPixbuf* icon_cache_get_mime_type_icon(IconCache* icons, char const* mime_type)
{
GIcon* icon;
char const* key = NULL;
GdkPixbuf* pixbuf;
icon = g_content_type_get_icon(mime_type);
key = _icon_cache_get_icon_key(icon);
GIcon* icon = g_content_type_get_icon(mime_type);
char const* key = _icon_cache_get_icon_key(icon);
if (key == NULL)
{
key = VOID_PIXBUF_KEY;
}
pixbuf = g_hash_table_lookup(icons->cache, key);
g_return_val_if_fail(icons != NULL, NULL);
GdkPixbuf* pixbuf = g_hash_table_lookup(icons->cache, key);
if (pixbuf != NULL)
{
g_object_ref(pixbuf);

View File

@ -1830,7 +1830,6 @@ static void torrentStart(tr_torrent* tor, bool bypass_queue)
case TR_STATUS_SEED:
case TR_STATUS_DOWNLOAD:
return; /* already started */
break;
case TR_STATUS_SEED_WAIT:
case TR_STATUS_DOWNLOAD_WAIT:
@ -1847,7 +1846,6 @@ static void torrentStart(tr_torrent* tor, bool bypass_queue)
* we'll know what completeness to use/announce */
tor->startAfterVerify = true;
return;
break;
case TR_STATUS_STOPPED:
if (!bypass_queue && torrentShouldQueue(tor))

View File

@ -198,7 +198,11 @@ static void tr_variant_string_set_string(struct tr_variant_string* str, char con
if (len < sizeof(str->str.buf))
{
str->type = TR_STRING_TYPE_BUF;
memcpy(str->str.buf, bytes, len);
if (len > 0)
{
memcpy(str->str.buf, bytes, len);
}
str->str.buf[len] = '\0';
str->len = len;
}
@ -1067,7 +1071,7 @@ void tr_variantMergeDicts(tr_variant* target, tr_variant const* source)
{
if (tr_variantIsBool(val))
{
bool boolVal;
bool boolVal = false;
tr_variantGetBool(val, &boolVal);
tr_variantDictAddBool(target, key, boolVal);
}

View File

@ -1,4 +1,5 @@
<html>
<!DOCTYPE html>
<html lang="en">
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8" />
@ -37,15 +38,15 @@
<div class="pagetitle">
<h1>Transmission crashed, what should I do? </h1>
</div>
<p>Post the crash log on the <a href="https://forum.transmissionbt.com/viewforum.php?f=4">support forums</a> so that the issue can be fixed as quickly as possible. Crash logs are held in <i>~/Library/Logs/CrashReporter/</i>.
<p>Post the crash log on the <a href="https://forum.transmissionbt.com/viewforum.php?f=4">support forums</a> so that the issue can be fixed as quickly as possible. Crash logs are held in <em>~/Library/Logs/CrashReporter/</em>.
<p>If your torrents' progress are incorrect when you reopen Transmission (e.g. they are starting from 0%) then you should manually recheck them. <a href="check.html">Click here</a> for instructions.
<p>
<div class="pagetitle">
<h1>What do the colors mean in the pieces box? </h1>
</div>
<p><font color="blue">Blue</font>: we have this piece - lighter shades of blue (progress only) indicate incomplete pieces <br>
<font color="green">Green</font>: connected peers have this piece (available only) - the darker the green, the more there are <br>
<font color="gray">White</font>: no connected peers have this piece (available) or we do not have any of this piece (progress) <br>
<p><span style="color: blue">Blue</span>: we have this piece - lighter shades of blue (progress only) indicate incomplete pieces <br>
<span style="color: green">Green</span>: connected peers have this piece (available only) - the darker the green, the more there are <br>
<span style="color: gray">White</span>: no connected peers have this piece (available) or we do not have any of this piece (progress) <br>
<p>
<div class="pagetitle">
@ -65,11 +66,11 @@
<div class="pagetitle">
<h1>What do the stats in the Activity tab of the Inspector mean? </h1>
</div>
<p> <i>Have</i> is the sum of verified and unverified data. The <i>Verified</i> amount, in brackets, is how much checksum-verified data you have downloaded.<br>
<i>Downloaded</i> is all the data you have downloaded. <br>
<i>Uploaded</i> is all of the data you have uploaded. <br>
<i>Failed DL</i> is data that failed our checksum test and needs to be downloaded again. <br>
<i>Ratio</i> is the ratio of download data to uploaded data.
<p> <em>Have</em> is the sum of verified and unverified data. The <em>Verified</em> amount, in brackets, is how much checksum-verified data you have downloaded.<br>
<em>Downloaded</em> is all the data you have downloaded. <br>
<em>Uploaded</em> is all of the data you have uploaded. <br>
<em>Failed DL</em> is data that failed our checksum test and needs to be downloaded again. <br>
<em>Ratio</em> is the ratio of download data to uploaded data.
<p>
<div class="pagetitle">
<h1>What does the 'Tracker' tab mean in the Inspector? </h1>

View File

@ -23,7 +23,7 @@
</div>
<div id="letters">
<font face="Lucida grande, arial, sans-serif"><b>Index</b></font>
<span style="font: Lucida grande, arial, sans-serif"><strong>Index</strong></span>
</div>
<div id="terms">

View File

@ -1,4 +1,5 @@
<html>
<!DOCTYPE html>
<html lang="en">
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8" />
@ -28,7 +29,7 @@
<li>Make sure you cap your upload speed, so that it isn't flooded. A good rule of thumb is about 60-70% of your maximum upload bandwidth. This can be adjusted in Preferences -> Bandwidth, or in real time using the Action menu.
<div summary="To do this" class="taskbox">
<p>eg. If your upload connection is 256 Kilobits/sec, then you should cap it at 21 KB/sec ((<b>256</b> / 8) * 0.66 = <b>21</b>).
<p>eg. If your upload connection is 256 Kilobits/sec, then you should cap it at 21 KB/sec ((<strong>256</strong> / 8) * 0.66 = <strong>21</strong>).
</div>
</li>
@ -37,7 +38,7 @@
To avoid spreading your upload too thinly, a good rule of thumb is to have at least 128 KBit/sec of upload bandwidth for every torrent you wish to run simultaneously.
<div summary="To do this" class="taskbox">
<p>eg. If your upload bandwidth is 256 KBit/sec, then you should only have two (<b>256</b>/128 = <b>2</b>) downloading transfers in the queue.
<p>eg. If your upload bandwidth is 256 KBit/sec, then you should only have two (<strong>256</strong>/128 = <strong>2</strong>) downloading transfers in the queue.
</div>
</li>
</ol>
@ -46,4 +47,4 @@
</div>
</body>
</html>
</html>

View File

@ -1,4 +1,5 @@
<html>
<!DOCTYPE html>
<html lang="en">
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8" />
@ -33,4 +34,4 @@
</div>
</body>
</html>
</html>

View File

@ -1,4 +1,5 @@
<html>
<!DOCTYPE html>
<html lang="en">
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8" />
@ -159,4 +160,4 @@
</div>
</body>
</html>
</html>

View File

@ -1,4 +1,5 @@
<html>
<!DOCTYPE html>
<html lang="en">
<a name="network"></a>
@ -31,4 +32,4 @@
</div>
</body>
</html>
</html>

View File

@ -1,4 +1,5 @@
<html>
<!DOCTYPE html>
<html lang="en">
<a name="peers"></a>
@ -39,15 +40,15 @@
<div class="pagetitle">
<h1>What are 'connections'?</h1>
</div>
<p><i>Global maximum connections</i> (Preferences -> Peers) is the total number of peers that Transmission will connect to across all of your transfers. Connections per torrent can also be adjusted here, as well as in the Inspector.
<p><em>Global maximum connections</em> (Preferences -> Peers) is the total number of peers that Transmission will connect to across all of your transfers. Connections per torrent can also be adjusted here, as well as in the Inspector.
<p>It is recommended that these values are left at their default setting, as allowing too many connections will severely hinder web browsing and other online activities, as well as possibly crashing your router. Increase this value at your own risk!
<p>
<div summary="To do this" class="taskbox">
<p>Recommended settings:
<ul>
<li><b>Global maximum connections</b>: 200 </li>
<li><b>Maximum connections for new transfers</b>: 60 </li>
<li><strong>Global maximum connections</strong>: 200 </li>
<li><strong>Maximum connections for new transfers</strong>: 60 </li>
</ul>
</div>
<p>
@ -61,4 +62,4 @@
</div>
</body>
</html>
</html>

View File

@ -1,4 +1,5 @@
<html>
<!DOCTYPE html>
<html lang="en">
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8" />
@ -32,4 +33,4 @@
</div>
</body>
</html>
</html>

View File

@ -1,4 +1,5 @@
<html>
<!DOCTYPE html>
<html lang="en">
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8" />
@ -72,4 +73,4 @@
</div>
</body>
</html>
</html>

View File

@ -1 +1,2 @@
<html> <head> <META http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link media="all" rel="stylesheet" href="../styles/TransBody.css" /> <title>Port Forwarding FAQ</title> </head> <body> <div id="mainbox"> <div id="banner"> <a name="menus"></a> <div id="machelp"> <a class="bread" href="../index.html">Transmission Help</a> </div> <div id="index"> <a class="leftborder" href="../html/index2.html">Index</a></div> </div> </div> <div class="pagetitle"> <h1>How do I Port Forward?</h1> </div> <p>If your router supports NAT-PMP, UPnP, or you have Apple AirPort, Transmission can map its port automatically. Most routers manufactured since 2001 have this feature. <div summary="To do this" class="taskbox"> <ol> <li>Open Transmission. </li> <li>Go to Preferences -> Network, and check 'Automatically map port'. </li> <li>If you get a green dot and 'Port is Open' then you have successfully port forwarded!</li> <p>If you get a red dot and the message 'Port is closed', <a href="troubleshoot.html">click here</a>.</li> </ol> </div> <p>If you don't have a compatible router, it is simple to forward Transmission's port manually. For instructions <a href="pfrouter.html">click here</a>.</li> <p>If you don't use a router, and your modem is directly connected to your computer, you'll need to open Transmission's port in the Mac OS X firewall. For instructions <a href="pffirewall.html">click here</a>.<br><br> <b>Note:</b> It is highly recommended you enable the Mac OS X firewall if you are not using a router.</li> <p>Keep in mind that many DSL modems also function as routers, so port forwarding may still be necessary, even though your computer is directly connected to the modem. <p> </div> </body> </html>
<!DOCTYPE html>
<html lang="en"> <head> <META http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link media="all" rel="stylesheet" href="../styles/TransBody.css" /> <title>Port Forwarding FAQ</title> </head> <body> <div id="mainbox"> <div id="banner"> <a name="menus"></a> <div id="machelp"> <a class="bread" href="../index.html">Transmission Help</a> </div> <div id="index"> <a class="leftborder" href="../html/index2.html">Index</a></div> </div> </div> <div class="pagetitle"> <h1>How do I Port Forward?</h1> </div> <p>If your router supports NAT-PMP, UPnP, or you have Apple AirPort, Transmission can map its port automatically. Most routers manufactured since 2001 have this feature. <div summary="To do this" class="taskbox"> <ol> <li>Open Transmission. </li> <li>Go to Preferences -> Network, and check 'Automatically map port'. </li> <li>If you get a green dot and 'Port is Open' then you have successfully port forwarded!</li> <p>If you get a red dot and the message 'Port is closed', <a href="troubleshoot.html">click here</a>.</li> </ol> </div> <p>If you don't have a compatible router, it is simple to forward Transmission's port manually. For instructions <a href="pfrouter.html">click here</a>.</li> <p>If you don't use a router, and your modem is directly connected to your computer, you'll need to open Transmission's port in the Mac OS X firewall. For instructions <a href="pffirewall.html">click here</a>.<br><br> <em>Note:</em> It is highly recommended you enable the Mac OS X firewall if you are not using a router.</li> <p>Keep in mind that many DSL modems also function as routers, so port forwarding may still be necessary, even though your computer is directly connected to the modem. <p> </div> </body> </html>

View File

@ -1,4 +1,5 @@
<html>
<!DOCTYPE html>
<html lang="en">
<a name="remote"></a>
@ -21,7 +22,7 @@
<div class="pagetitle">
<h1>What is remote access? </h1>
</div>
<p>Transmission has a web interface which can be used to monitor and manage your transfers over the internet. Other applications, such as <i>transmission-remote</i>, can also control Transmission. If you want to use the web interface, or another remote control application, check 'Enable remote access'. Leave this option unchecked if you are only going to be managing your transfers on your local machine.
<p>Transmission has a web interface which can be used to monitor and manage your transfers over the internet. Other applications, such as <em>transmission-remote</em>, can also control Transmission. If you want to use the web interface, or another remote control application, check 'Enable remote access'. Leave this option unchecked if you are only going to be managing your transfers on your local machine.
<p>For security purposes, you can password protect access to Transmission, as well as restrict access to a trusted list of external IP addresses. To add an address to the list, click the + button.
<p>You can view the web interface on your local computer by clicking the 'Launch web interface' button. To view it on a remote location:
<div summary="To do this" class="taskbox">
@ -29,8 +30,8 @@
<li>Open your web browser</li>
<li>In the address bar, enter "http://localip:port/transmission/web/", where: </li>
<ul>
<li><i>localip</i> is the IP address of the computer Transmission is running on.</li>
<li><i>port</i> is the port specified in Preferences -> Remote.</li>
<li><em>localip</em> is the IP address of the computer Transmission is running on.</li>
<li><em>port</em> is the port specified in Preferences -> Remote.</li>
</ul>
</ol>
</div>
@ -38,4 +39,4 @@
</div>
</body>
</html>
</html>

View File

@ -1,4 +1,5 @@
<html>
<!DOCTYPE html>
<html lang="en">
<a name="script"></a>
@ -37,4 +38,4 @@
</div>
</body>
</html>
</html>

View File

@ -1,4 +1,5 @@
<html>
<!DOCTYPE html>
<html lang="en">
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8" />
@ -28,16 +29,16 @@
<div class="pagetitle">
<h1>What does 'announce' mean? </h1>
</div>
<p>When Transmission <i>announces</i>, it is updating its presence to the tracker and asking for more peers. This happens periodically, at the discretion of the tracker, however can be manually invoked via Transfers menu >> Update Tracker.
<p>When Transmission <em>announces</em>, it is updating its presence to the tracker and asking for more peers. This happens periodically, at the discretion of the tracker, however can be manually invoked via Transfers menu >> Update Tracker.
<p>
<div class="pagetitle">
<h1>What does 'scrape' mean? </h1>
</div>
<p><i>Scraping</i> the tracker simply means asking for information about the swarm itself. For example, the number of peers, seeds etc.
<p><em>Scraping</em> the tracker simply means asking for information about the swarm itself. For example, the number of peers, seeds etc.
<p>
</div>
</body>
</html>
</html>

View File

@ -1,4 +1,5 @@
<html>
<!DOCTYPE html>
<html lang="en">
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8" />
@ -64,7 +65,7 @@
</div>
<p>Another possible reason your port remains closed could be because your router is not the only device on the network which needs to be configured.
<p>For example, your network might resemble the following: <b>ADSL modem/router --> AirPort extreme --> MacBook.</b>
<p>For example, your network might resemble the following: <em>ADSL modem/router --> AirPort extreme --> MacBook.</em>
<p>If you have multiple routers in your home network (such as in the example above), you have two options. The easiest way is to turn one of the routers into 'Bridge mode' which means you then only have to configure one device rather than all of them. So, in our above example, we would set the AirPort extreme to 'Bridge'. See your router's help documentation for instructions.

View File

@ -1,4 +1,5 @@
<html>
<!DOCTYPE html>
<html lang="en">
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8" />
@ -38,4 +39,4 @@
</div>
</body>
</html>
</html>