mirror of
https://github.com/xmrig/xmrig.git
synced 2024-11-17 08:17:40 +00:00
Fix Visual Studio warnings.
This commit is contained in:
parent
9975b4e4cd
commit
a07b0e5953
21 changed files with 43 additions and 39 deletions
|
@ -159,6 +159,8 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES MSVC)
|
||||||
|
|
||||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Ox /Ot /Oi /MT /GL")
|
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Ox /Ot /Oi /MT /GL")
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Ox /Ot /Oi /MT /GL")
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Ox /Ot /Oi /MT /GL")
|
||||||
|
add_definitions(/D_CRT_SECURE_NO_WARNINGS)
|
||||||
|
add_definitions(/D_CRT_NONSTDC_NO_WARNINGS)
|
||||||
|
|
||||||
elseif (CMAKE_CXX_COMPILER_ID MATCHES Clang)
|
elseif (CMAKE_CXX_COMPILER_ID MATCHES Clang)
|
||||||
|
|
||||||
|
|
2
src/3rdparty/getopt/getopt.h
vendored
2
src/3rdparty/getopt/getopt.h
vendored
|
@ -56,7 +56,7 @@
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma warning(disable:4996);
|
#pragma warning(disable:4996)
|
||||||
|
|
||||||
#define __GETOPT_H__
|
#define __GETOPT_H__
|
||||||
|
|
||||||
|
|
2
src/3rdparty/jansson/dump.c
vendored
2
src/3rdparty/jansson/dump.c
vendored
|
@ -5,6 +5,8 @@
|
||||||
* it under the terms of the MIT license. See LICENSE for details.
|
* it under the terms of the MIT license. See LICENSE for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#pragma warning(disable:4090)
|
||||||
|
|
||||||
#ifndef _GNU_SOURCE
|
#ifndef _GNU_SOURCE
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
#endif
|
#endif
|
||||||
|
|
2
src/3rdparty/jansson/hashtable.c
vendored
2
src/3rdparty/jansson/hashtable.c
vendored
|
@ -5,6 +5,8 @@
|
||||||
* it under the terms of the MIT license. See LICENSE for details.
|
* it under the terms of the MIT license. See LICENSE for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#pragma warning(disable:4334)
|
||||||
|
|
||||||
#if HAVE_CONFIG_H
|
#if HAVE_CONFIG_H
|
||||||
#include <jansson_private_config.h>
|
#include <jansson_private_config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
2
src/3rdparty/jansson/load.c
vendored
2
src/3rdparty/jansson/load.c
vendored
|
@ -1034,8 +1034,8 @@ json_t *json_loadf(FILE *input, size_t flags, json_error_t *error)
|
||||||
|
|
||||||
static int fd_get_func(int *fd)
|
static int fd_get_func(int *fd)
|
||||||
{
|
{
|
||||||
uint8_t c;
|
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
|
uint8_t c;
|
||||||
if (read(*fd, &c, 1) == 1)
|
if (read(*fd, &c, 1) == 1)
|
||||||
return c;
|
return c;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -68,7 +68,7 @@ int Cpu::optimalThreadsCount(int algo, bool doubleHash, int maxCpuUsage)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((float) count / m_totalThreads * 100) > maxCpuUsage) {
|
if (((float) count / m_totalThreads * 100) > maxCpuUsage) {
|
||||||
count = ceil((float) m_totalThreads * (maxCpuUsage / 100.0));
|
count = (int) ceil((float) m_totalThreads * (maxCpuUsage / 100.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
return count < 1 ? 1 : count;
|
return count < 1 ? 1 : count;
|
||||||
|
|
|
@ -41,8 +41,8 @@ public:
|
||||||
static void init();
|
static void init();
|
||||||
static void setAffinity(int id, uint64_t mask);
|
static void setAffinity(int id, uint64_t mask);
|
||||||
|
|
||||||
static inline bool hasAES() { return m_flags & AES; }
|
static inline bool hasAES() { return (m_flags & AES) != 0; }
|
||||||
static inline bool isX64() { return m_flags & X86_64; }
|
static inline bool isX64() { return (m_flags & X86_64) != 0; }
|
||||||
static inline const char *brand() { return m_brand; }
|
static inline const char *brand() { return m_brand; }
|
||||||
static inline int cores() { return m_totalCores; }
|
static inline int cores() { return m_totalCores; }
|
||||||
static inline int l2() { return m_l2_cache; }
|
static inline int l2() { return m_l2_cache; }
|
||||||
|
|
|
@ -50,8 +50,8 @@ public:
|
||||||
static void release();
|
static void release();
|
||||||
|
|
||||||
static inline bool isDoubleHash() { return m_doubleHash; }
|
static inline bool isDoubleHash() { return m_doubleHash; }
|
||||||
static inline bool isHugepagesAvailable() { return m_flags & HugepagesAvailable; }
|
static inline bool isHugepagesAvailable() { return (m_flags & HugepagesAvailable) != 0; }
|
||||||
static inline bool isHugepagesEnabled() { return m_flags & HugepagesEnabled; }
|
static inline bool isHugepagesEnabled() { return (m_flags & HugepagesEnabled) != 0; }
|
||||||
static inline int flags() { return m_flags; }
|
static inline int flags() { return m_flags; }
|
||||||
static inline int threads() { return m_threads; }
|
static inline int threads() { return m_threads; }
|
||||||
|
|
||||||
|
|
|
@ -85,9 +85,8 @@ static BOOL SetLockPagesPrivilege() {
|
||||||
|
|
||||||
static LSA_UNICODE_STRING StringToLsaUnicodeString(LPCTSTR string) {
|
static LSA_UNICODE_STRING StringToLsaUnicodeString(LPCTSTR string) {
|
||||||
LSA_UNICODE_STRING lsaString;
|
LSA_UNICODE_STRING lsaString;
|
||||||
DWORD dwLen = 0;
|
|
||||||
|
|
||||||
dwLen = wcslen(string);
|
DWORD dwLen = (DWORD) wcslen(string);
|
||||||
lsaString.Buffer = (LPWSTR) string;
|
lsaString.Buffer = (LPWSTR) string;
|
||||||
lsaString.Length = (USHORT)((dwLen) * sizeof(WCHAR));
|
lsaString.Length = (USHORT)((dwLen) * sizeof(WCHAR));
|
||||||
lsaString.MaximumLength = (USHORT)((dwLen + 1) * sizeof(WCHAR));
|
lsaString.MaximumLength = (USHORT)((dwLen + 1) * sizeof(WCHAR));
|
||||||
|
|
|
@ -371,7 +371,7 @@ bool Options::parseArg(int key, uint64_t arg)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_retries = arg;
|
m_retries = (int) arg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'R': /* --retry-pause */
|
case 'R': /* --retry-pause */
|
||||||
|
@ -380,7 +380,7 @@ bool Options::parseArg(int key, uint64_t arg)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_retryPause = arg;
|
m_retryPause = (int) arg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 't': /* --threads */
|
case 't': /* --threads */
|
||||||
|
@ -389,7 +389,7 @@ bool Options::parseArg(int key, uint64_t arg)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_threads = arg;
|
m_threads = (int) arg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'v': /* --av */
|
case 'v': /* --av */
|
||||||
|
@ -398,7 +398,7 @@ bool Options::parseArg(int key, uint64_t arg)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_algoVariant = arg;
|
m_algoVariant = (int) arg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1003: /* --donate-level */
|
case 1003: /* --donate-level */
|
||||||
|
@ -407,7 +407,7 @@ bool Options::parseArg(int key, uint64_t arg)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_donateLevel = arg;
|
m_donateLevel = (int) arg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1004: /* --max-cpu-usage */
|
case 1004: /* --max-cpu-usage */
|
||||||
|
@ -416,7 +416,7 @@ bool Options::parseArg(int key, uint64_t arg)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_maxCpuUsage = arg;
|
m_maxCpuUsage = (int) arg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1007: /* --print-time */
|
case 1007: /* --print-time */
|
||||||
|
@ -425,7 +425,7 @@ bool Options::parseArg(int key, uint64_t arg)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_printTime = arg;
|
m_printTime = (int) arg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1020: /* --cpu-affinity */
|
case 1020: /* --cpu-affinity */
|
||||||
|
@ -609,7 +609,7 @@ bool Options::setAlgo(const char *algo)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < ARRAY_SIZE(algo_names); i++) {
|
for (size_t i = 0; i < ARRAY_SIZE(algo_names); i++) {
|
||||||
if (algo_names[i] && !strcmp(algo, algo_names[i])) {
|
if (algo_names[i] && !strcmp(algo, algo_names[i])) {
|
||||||
m_algo = i;
|
m_algo = (int) i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -311,7 +311,7 @@ static inline void cn_implode_scratchpad(const __m128i *input, __m128i *output)
|
||||||
template<size_t ITERATIONS, size_t MEM, size_t MASK, bool SOFT_AES>
|
template<size_t ITERATIONS, size_t MEM, size_t MASK, bool SOFT_AES>
|
||||||
inline void cryptonight_hash(const void *__restrict__ input, size_t size, void *__restrict__ output, cryptonight_ctx *__restrict__ ctx)
|
inline void cryptonight_hash(const void *__restrict__ input, size_t size, void *__restrict__ output, cryptonight_ctx *__restrict__ ctx)
|
||||||
{
|
{
|
||||||
keccak(static_cast<const uint8_t*>(input), size, ctx->state0, 200);
|
keccak(static_cast<const uint8_t*>(input), (int) size, ctx->state0, 200);
|
||||||
|
|
||||||
cn_explode_scratchpad<MEM, SOFT_AES>((__m128i*) ctx->state0, (__m128i*) ctx->memory);
|
cn_explode_scratchpad<MEM, SOFT_AES>((__m128i*) ctx->state0, (__m128i*) ctx->memory);
|
||||||
|
|
||||||
|
@ -365,8 +365,8 @@ inline void cryptonight_hash(const void *__restrict__ input, size_t size, void *
|
||||||
template<size_t ITERATIONS, size_t MEM, size_t MASK, bool SOFT_AES>
|
template<size_t ITERATIONS, size_t MEM, size_t MASK, bool SOFT_AES>
|
||||||
inline void cryptonight_double_hash(const void *__restrict__ input, size_t size, void *__restrict__ output, struct cryptonight_ctx *__restrict__ ctx)
|
inline void cryptonight_double_hash(const void *__restrict__ input, size_t size, void *__restrict__ output, struct cryptonight_ctx *__restrict__ ctx)
|
||||||
{
|
{
|
||||||
keccak((const uint8_t *) input, size, ctx->state0, 200);
|
keccak((const uint8_t *) input, (int) size, ctx->state0, 200);
|
||||||
keccak((const uint8_t *) input + size, size, ctx->state1, 200);
|
keccak((const uint8_t *) input + size, (int) size, ctx->state1, 200);
|
||||||
|
|
||||||
const uint8_t* l0 = ctx->memory;
|
const uint8_t* l0 = ctx->memory;
|
||||||
const uint8_t* l1 = ctx->memory + MEM;
|
const uint8_t* l1 = ctx->memory + MEM;
|
||||||
|
|
|
@ -148,7 +148,7 @@ void blake256_update(state *S, const uint8_t *data, uint64_t datalen) {
|
||||||
|
|
||||||
if (datalen > 0) {
|
if (datalen > 0) {
|
||||||
memcpy((void *) (S->buf + left), (void *) data, datalen >> 3);
|
memcpy((void *) (S->buf + left), (void *) data, datalen >> 3);
|
||||||
S->buflen = (left << 3) + datalen;
|
S->buflen = (left << 3) + (int) datalen;
|
||||||
} else {
|
} else {
|
||||||
S->buflen = 0;
|
S->buflen = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,8 +92,7 @@ void ConsoleLog::message(int level, const char* fmt, va_list args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const size_t len = 64 + strlen(fmt) + 2;
|
char *buf = new char[64 + strlen(fmt) + 2];
|
||||||
char *buf = new char[len];
|
|
||||||
|
|
||||||
sprintf(buf, "[%d-%02d-%02d %02d:%02d:%02d]%s %s%s\n",
|
sprintf(buf, "[%d-%02d-%02d %02d:%02d:%02d]%s %s%s\n",
|
||||||
stime.tm_year + 1900,
|
stime.tm_year + 1900,
|
||||||
|
@ -113,8 +112,7 @@ void ConsoleLog::message(int level, const char* fmt, va_list args)
|
||||||
|
|
||||||
void ConsoleLog::text(const char* fmt, va_list args)
|
void ConsoleLog::text(const char* fmt, va_list args)
|
||||||
{
|
{
|
||||||
const int len = 64 + strlen(fmt) + 2;
|
char *buf = new char[64 + strlen(fmt) + 2];
|
||||||
char *buf = new char[len];
|
|
||||||
|
|
||||||
sprintf(buf, "%s%s\n", fmt, m_colors ? Log::kCL_N : "");
|
sprintf(buf, "%s%s\n", fmt, m_colors ? Log::kCL_N : "");
|
||||||
|
|
||||||
|
@ -129,7 +127,7 @@ void ConsoleLog::print(char *fmt, va_list args)
|
||||||
|
|
||||||
uv_buf_t buf;
|
uv_buf_t buf;
|
||||||
buf.base = strdup(m_buf);
|
buf.base = strdup(m_buf);
|
||||||
buf.len = strlen(buf.base);
|
buf.len = (ULONG) strlen(buf.base);
|
||||||
|
|
||||||
uv_write_t *req = new uv_write_t;
|
uv_write_t *req = new uv_write_t;
|
||||||
req->data = buf.base;
|
req->data = buf.base;
|
||||||
|
|
|
@ -88,7 +88,7 @@ void FileLog::onWrite(uv_fs_t *req)
|
||||||
|
|
||||||
void FileLog::write(char *data, size_t size)
|
void FileLog::write(char *data, size_t size)
|
||||||
{
|
{
|
||||||
uv_buf_t buf = uv_buf_init(data, size);
|
uv_buf_t buf = uv_buf_init(data, (unsigned int) size);
|
||||||
uv_fs_t *req = static_cast<uv_fs_t*>(malloc(sizeof(uv_fs_t)));
|
uv_fs_t *req = static_cast<uv_fs_t*>(malloc(sizeof(uv_fs_t)));
|
||||||
req->data = buf.base;
|
req->data = buf.base;
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ int64_t Client::send(char *data, size_t size)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uv_buf_t buf = uv_buf_init(data, size ? size : strlen(data));
|
uv_buf_t buf = uv_buf_init(data, (unsigned int) (size ? size : strlen(data)));
|
||||||
|
|
||||||
uv_write_t *req = new uv_write_t;
|
uv_write_t *req = new uv_write_t;
|
||||||
req->data = buf.base;
|
req->data = buf.base;
|
||||||
|
@ -464,7 +464,7 @@ void Client::reconnect()
|
||||||
}
|
}
|
||||||
|
|
||||||
m_failures++;
|
m_failures++;
|
||||||
m_listener->onClose(this, m_failures);
|
m_listener->onClose(this, (int) m_failures);
|
||||||
|
|
||||||
m_expire = uv_now(uv_default_loop()) + m_retryPause;
|
m_expire = uv_now(uv_default_loop()) + m_retryPause;
|
||||||
}
|
}
|
||||||
|
@ -501,7 +501,7 @@ void Client::onAllocBuffer(uv_handle_t *handle, size_t suggested_size, uv_buf_t
|
||||||
auto client = getClient(handle->data);
|
auto client = getClient(handle->data);
|
||||||
|
|
||||||
buf->base = &client->m_recvBuf.base[client->m_recvBufPos];
|
buf->base = &client->m_recvBuf.base[client->m_recvBufPos];
|
||||||
buf->len = client->m_recvBuf.len - client->m_recvBufPos;
|
buf->len = client->m_recvBuf.len - (ULONG) client->m_recvBufPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -548,7 +548,7 @@ void Client::onRead(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf)
|
||||||
auto client = getClient(stream->data);
|
auto client = getClient(stream->data);
|
||||||
if (nread < 0) {
|
if (nread < 0) {
|
||||||
if (nread != UV_EOF && !client->m_quiet) {
|
if (nread != UV_EOF && !client->m_quiet) {
|
||||||
LOG_ERR("[%s:%u] read error: \"%s\"", client->m_url.host(), client->m_url.port(), uv_strerror(nread));
|
LOG_ERR("[%s:%u] read error: \"%s\"", client->m_url.host(), client->m_url.port(), uv_strerror((int) nread));
|
||||||
}
|
}
|
||||||
|
|
||||||
return client->close();;
|
return client->close();;
|
||||||
|
|
|
@ -82,7 +82,7 @@ bool Job::setBlob(const char *blob)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fromHex(blob, m_size * 2, m_blob)) {
|
if (!fromHex(blob, (int) m_size * 2, m_blob)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,9 +44,9 @@ public:
|
||||||
inline const char *id() const { return m_id; }
|
inline const char *id() const { return m_id; }
|
||||||
inline const uint8_t *blob() const { return m_blob; }
|
inline const uint8_t *blob() const { return m_blob; }
|
||||||
inline int poolId() const { return m_poolId; }
|
inline int poolId() const { return m_poolId; }
|
||||||
|
inline size_t size() const { return m_size; }
|
||||||
inline uint32_t *nonce() { return reinterpret_cast<uint32_t*>(m_blob + 39); }
|
inline uint32_t *nonce() { return reinterpret_cast<uint32_t*>(m_blob + 39); }
|
||||||
inline uint32_t diff() const { return m_diff; }
|
inline uint32_t diff() const { return (uint32_t) m_diff; }
|
||||||
inline uint32_t size() const { return m_size; }
|
|
||||||
inline uint64_t target() const { return m_target; }
|
inline uint64_t target() const { return m_target; }
|
||||||
inline void setNicehash(bool nicehash) { m_nicehash = nicehash; }
|
inline void setNicehash(bool nicehash) { m_nicehash = nicehash; }
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ private:
|
||||||
int m_poolId;
|
int m_poolId;
|
||||||
VAR_ALIGN(16, char m_id[64]);
|
VAR_ALIGN(16, char m_id[64]);
|
||||||
VAR_ALIGN(16, uint8_t m_blob[84]); // Max blob size is 84 (75 fixed + 9 variable), aligned to 96. https://github.com/xmrig/xmrig/issues/1 Thanks fireice-uk.
|
VAR_ALIGN(16, uint8_t m_blob[84]); // Max blob size is 84 (75 fixed + 9 variable), aligned to 96. https://github.com/xmrig/xmrig/issues/1 Thanks fireice-uk.
|
||||||
uint32_t m_size;
|
size_t m_size;
|
||||||
uint64_t m_diff;
|
uint64_t m_diff;
|
||||||
uint64_t m_target;
|
uint64_t m_target;
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#pragma warning(disable:4244)
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
|
@ -121,7 +121,7 @@ bool Url::parse(const char *url)
|
||||||
memcpy(m_host, base, size - 1);
|
memcpy(m_host, base, size - 1);
|
||||||
m_host[size - 1] = '\0';
|
m_host[size - 1] = '\0';
|
||||||
|
|
||||||
m_port = strtol(port, nullptr, 10);
|
m_port = (uint16_t) strtol(port, nullptr, 10);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -140,7 +140,7 @@ void FailoverStrategy::onResultAccepted(Client *client, int64_t seq, uint32_t di
|
||||||
|
|
||||||
void FailoverStrategy::add(const Url *url, const char *agent)
|
void FailoverStrategy::add(const Url *url, const char *agent)
|
||||||
{
|
{
|
||||||
Client *client = new Client(m_pools.size(), agent, this);
|
Client *client = new Client((int) m_pools.size(), agent, this);
|
||||||
client->setUrl(url);
|
client->setUrl(url);
|
||||||
client->setRetryPause(Options::i()->retryPause() * 1000);
|
client->setRetryPause(Options::i()->retryPause() * 1000);
|
||||||
|
|
||||||
|
|
|
@ -127,8 +127,8 @@ double Hashrate::calc(size_t threadId, size_t ms) const
|
||||||
}
|
}
|
||||||
|
|
||||||
double hashes, time;
|
double hashes, time;
|
||||||
hashes = lastestHashCnt - earliestHashCount;
|
hashes = (double) lastestHashCnt - earliestHashCount;
|
||||||
time = lastestStamp - earliestStamp;
|
time = (double) lastestStamp - earliestStamp;
|
||||||
time /= 1000.0;
|
time /= 1000.0;
|
||||||
|
|
||||||
return hashes / time;
|
return hashes / time;
|
||||||
|
|
Loading…
Reference in a new issue