mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Merge pull request #11687 from Minty-Meeo/warnings
Resolve GCC/Clang Warnings
This commit is contained in:
@ -3,42 +3,45 @@
|
||||
|
||||
#include "Common/Crypto/bn.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
|
||||
static void bn_zero(u8* d, int n)
|
||||
static void bn_zero(u8* d, const size_t n)
|
||||
{
|
||||
std::memset(d, 0, n);
|
||||
}
|
||||
|
||||
static void bn_copy(u8* d, const u8* a, int n)
|
||||
static void bn_copy(u8* d, const u8* a, const size_t n)
|
||||
{
|
||||
std::memcpy(d, a, n);
|
||||
}
|
||||
|
||||
int bn_compare(const u8* a, const u8* b, int n)
|
||||
int bn_compare(const u8* a, const u8* b, const size_t n)
|
||||
{
|
||||
return std::memcmp(a, b, n);
|
||||
}
|
||||
|
||||
void bn_sub_modulus(u8* a, const u8* N, int n)
|
||||
void bn_sub_modulus(u8* a, const u8* N, const size_t n)
|
||||
{
|
||||
u8 c = 0;
|
||||
for (int i = n - 1; i >= 0; --i)
|
||||
for (size_t i = n; i > 0;)
|
||||
{
|
||||
--i;
|
||||
u32 dig = N[i] + c;
|
||||
c = (a[i] < dig);
|
||||
a[i] -= dig;
|
||||
}
|
||||
}
|
||||
|
||||
void bn_add(u8* d, const u8* a, const u8* b, const u8* N, int n)
|
||||
void bn_add(u8* d, const u8* a, const u8* b, const u8* N, const size_t n)
|
||||
{
|
||||
u8 c = 0;
|
||||
for (int i = n - 1; i >= 0; --i)
|
||||
for (size_t i = n; i > 0;)
|
||||
{
|
||||
--i;
|
||||
u32 dig = a[i] + b[i] + c;
|
||||
c = (dig >= 0x100);
|
||||
d[i] = dig;
|
||||
@ -51,11 +54,11 @@ void bn_add(u8* d, const u8* a, const u8* b, const u8* N, int n)
|
||||
bn_sub_modulus(d, N, n);
|
||||
}
|
||||
|
||||
void bn_mul(u8* d, const u8* a, const u8* b, const u8* N, int n)
|
||||
void bn_mul(u8* d, const u8* a, const u8* b, const u8* N, const size_t n)
|
||||
{
|
||||
bn_zero(d, n);
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
for (size_t i = 0; i < n; i++)
|
||||
{
|
||||
for (u8 mask = 0x80; mask != 0; mask >>= 1)
|
||||
{
|
||||
@ -66,13 +69,13 @@ void bn_mul(u8* d, const u8* a, const u8* b, const u8* N, int n)
|
||||
}
|
||||
}
|
||||
|
||||
void bn_exp(u8* d, const u8* a, const u8* N, int n, const u8* e, int en)
|
||||
void bn_exp(u8* d, const u8* a, const u8* N, const size_t n, const u8* e, const size_t en)
|
||||
{
|
||||
u8 t[512];
|
||||
|
||||
bn_zero(d, n);
|
||||
d[n - 1] = 1;
|
||||
for (int i = 0; i < en; i++)
|
||||
for (size_t i = 0; i < en; i++)
|
||||
{
|
||||
for (u8 mask = 0x80; mask != 0; mask >>= 1)
|
||||
{
|
||||
@ -86,7 +89,7 @@ void bn_exp(u8* d, const u8* a, const u8* N, int n, const u8* e, int en)
|
||||
}
|
||||
|
||||
// only for prime N -- stupid but lazy, see if I care
|
||||
void bn_inv(u8* d, const u8* a, const u8* N, int n)
|
||||
void bn_inv(u8* d, const u8* a, const u8* N, const size_t n)
|
||||
{
|
||||
u8 t[512], s[512];
|
||||
|
||||
|
@ -3,13 +3,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
|
||||
// bignum arithmetic
|
||||
|
||||
int bn_compare(const u8* a, const u8* b, int n);
|
||||
void bn_sub_modulus(u8* a, const u8* N, int n);
|
||||
void bn_add(u8* d, const u8* a, const u8* b, const u8* N, int n);
|
||||
void bn_mul(u8* d, const u8* a, const u8* b, const u8* N, int n);
|
||||
void bn_inv(u8* d, const u8* a, const u8* N, int n); // only for prime N
|
||||
void bn_exp(u8* d, const u8* a, const u8* N, int n, const u8* e, int en);
|
||||
int bn_compare(const u8* a, const u8* b, size_t n);
|
||||
void bn_sub_modulus(u8* a, const u8* N, size_t n);
|
||||
void bn_add(u8* d, const u8* a, const u8* b, const u8* N, size_t n);
|
||||
void bn_mul(u8* d, const u8* a, const u8* b, const u8* N, size_t n);
|
||||
void bn_inv(u8* d, const u8* a, const u8* N, size_t n); // only for prime N
|
||||
void bn_exp(u8* d, const u8* a, const u8* N, size_t n, const u8* e, size_t en);
|
||||
|
@ -486,7 +486,7 @@ FSTEntry ScanDirectoryTree(std::string directory, bool recursive)
|
||||
}
|
||||
else if (cur_depth < prev_depth)
|
||||
{
|
||||
while (dir_fsts.size() - 1 != cur_depth)
|
||||
while (dir_fsts.size() != static_cast<size_t>(cur_depth) + 1u)
|
||||
{
|
||||
calc_dir_size(dir_fsts.top());
|
||||
dir_fsts.pop();
|
||||
|
@ -33,8 +33,8 @@ public:
|
||||
Response Fetch(const std::string& url, Method method, const Headers& headers, const u8* payload,
|
||||
size_t size, AllowedReturnCodes codes = AllowedReturnCodes::Ok_Only);
|
||||
|
||||
static int CurlProgressCallback(Impl* impl, double dlnow, double dltotal, double ulnow,
|
||||
double ultotal);
|
||||
static int CurlProgressCallback(Impl* impl, curl_off_t dltotal, curl_off_t dlnow,
|
||||
curl_off_t ultotal, curl_off_t ulnow);
|
||||
std::string EscapeComponent(const std::string& string);
|
||||
|
||||
private:
|
||||
@ -95,11 +95,12 @@ HttpRequest::Response HttpRequest::Post(const std::string& url, const std::strin
|
||||
reinterpret_cast<const u8*>(payload.data()), payload.size(), codes);
|
||||
}
|
||||
|
||||
int HttpRequest::Impl::CurlProgressCallback(Impl* impl, double dlnow, double dltotal, double ulnow,
|
||||
double ultotal)
|
||||
int HttpRequest::Impl::CurlProgressCallback(Impl* impl, curl_off_t dltotal, curl_off_t dlnow,
|
||||
curl_off_t ultotal, curl_off_t ulnow)
|
||||
{
|
||||
// Abort if callback isn't true
|
||||
return !impl->m_callback(dlnow, dltotal, ulnow, ultotal);
|
||||
return !impl->m_callback(static_cast<s64>(dltotal), static_cast<s64>(dlnow),
|
||||
static_cast<s64>(ultotal), static_cast<s64>(ulnow));
|
||||
}
|
||||
|
||||
HttpRequest::Impl::Impl(std::chrono::milliseconds timeout_ms, ProgressCallback callback)
|
||||
@ -116,7 +117,7 @@ HttpRequest::Impl::Impl(std::chrono::milliseconds timeout_ms, ProgressCallback c
|
||||
if (m_callback)
|
||||
{
|
||||
curl_easy_setopt(m_curl.get(), CURLOPT_PROGRESSDATA, this);
|
||||
curl_easy_setopt(m_curl.get(), CURLOPT_PROGRESSFUNCTION, CurlProgressCallback);
|
||||
curl_easy_setopt(m_curl.get(), CURLOPT_XFERINFOFUNCTION, CurlProgressCallback);
|
||||
}
|
||||
|
||||
// Set up error buffer
|
||||
|
@ -25,8 +25,7 @@ public:
|
||||
};
|
||||
|
||||
// Return false to abort the request
|
||||
using ProgressCallback =
|
||||
std::function<bool(double dlnow, double dltotal, double ulnow, double ultotal)>;
|
||||
using ProgressCallback = std::function<bool(s64 dltotal, s64 dlnow, s64 ultotal, s64 ulnow)>;
|
||||
|
||||
explicit HttpRequest(std::chrono::milliseconds timeout_ms = std::chrono::milliseconds{3000},
|
||||
ProgressCallback callback = nullptr);
|
||||
|
@ -70,12 +70,10 @@ std::string SettingsHandler::GetValue(std::string_view key) const
|
||||
|
||||
void SettingsHandler::Decrypt()
|
||||
{
|
||||
const u8* str = m_buffer.data();
|
||||
while (m_position < m_buffer.size())
|
||||
{
|
||||
decoded.push_back((u8)(m_buffer[m_position] ^ m_key));
|
||||
m_position++;
|
||||
str++;
|
||||
m_key = (m_key >> 31) | (m_key << 1);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user