Skip to content

Commit

Permalink
fix g++ 7.3 warnings (ubuntu 18.04)
Browse files Browse the repository at this point in the history
  • Loading branch information
tpruvot committed Jun 24, 2018
1 parent d9f242b commit 654e8a1
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ static char *getpoolnfo(char *params)

static void gpuhwinfos(int gpu_id)
{
char buf[256];
char buf[512];
char pstate[8];
char* card;
struct cgpu_info *cgpu = NULL;
Expand Down
14 changes: 12 additions & 2 deletions scrypt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,17 @@ using namespace Concurrency;

#if _MSC_VER > 1800
#undef _THROW1
#if __cplusplus < 201101L
#define _THROW1(x) throw(std::bad_alloc)
#else
#define _THROW1(x) noexcept(false)
#endif
#elif !defined(_MSC_VER)
#if __cplusplus < 201101L
#define _THROW1(x) throw(std::bad_alloc)
#else
#define _THROW1(x) noexcept(false)
#endif
#endif

// A thin wrapper around the builtin __m128i type
Expand All @@ -63,9 +73,9 @@ class uint32x4_t
void * operator new[](size_t size) _THROW1(_STD bad_alloc) { void *p; if ((p = _aligned_malloc(size, 16)) == 0) { static const std::bad_alloc nomem; _RAISE(nomem); } return (p); }
void operator delete[](void *p) { _aligned_free(p); }
#else
void * operator new(size_t size) throw(std::bad_alloc) { void *p; if (posix_memalign(&p, 16, size) < 0) { static const std::bad_alloc nomem; throw nomem; } return (p); }
void * operator new(size_t size) _THROW1(_STD bad_alloc) { void *p; if (posix_memalign(&p, 16, size) < 0) { static const std::bad_alloc nomem; throw nomem; } return (p); }
void operator delete(void *p) { free(p); }
void * operator new[](size_t size) throw(std::bad_alloc) { void *p; if (posix_memalign(&p, 16, size) < 0) { static const std::bad_alloc nomem; throw nomem; } return (p); }
void * operator new[](size_t size) _THROW1(_STD bad_alloc) { void *p; if (posix_memalign(&p, 16, size) < 0) { static const std::bad_alloc nomem; throw nomem; } return (p); }
void operator delete[](void *p) { free(p); }
#endif
uint32x4_t() { };
Expand Down
5 changes: 2 additions & 3 deletions scrypt/test_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,22 @@ texture<uint4, 2, cudaReadModeElementType> texRef2D_4_V;

template <int ALGO> __device__ __forceinline__ void block_mixer(uint4 &b, uint4 &bx, const int x1, const int x2, const int x3);

static __host__ __device__ uint4& operator^=(uint4& left, const uint4& right) {
static __device__ uint4& operator^=(uint4& left, const uint4& right) {
left.x ^= right.x;
left.y ^= right.y;
left.z ^= right.z;
left.w ^= right.w;
return left;
}

static __host__ __device__ uint4& operator+=(uint4& left, const uint4& right) {
static __device__ uint4& operator+=(uint4& left, const uint4& right) {
left.x += right.x;
left.y += right.y;
left.z += right.z;
left.w += right.w;
return left;
}


/* write_keys writes the 8 keys being processed by a warp to the global
* scratchpad. To effectively use memory bandwidth, it performs the writes
* (and reads, for read_keys) 128 bytes at a time per memory location
Expand Down
4 changes: 2 additions & 2 deletions scrypt/titan_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ __constant__ uint32_t c_SCRATCH_WU_PER_WARP_1; // (SCRATCH * WU_PER_WARP)-1

template <int ALGO> __device__ __forceinline__ void block_mixer(uint4 &b, uint4 &bx, const int x1, const int x2, const int x3);

static __host__ __device__ uint4& operator ^= (uint4& left, const uint4& right) {
static __device__ uint4& operator ^= (uint4& left, const uint4& right) {
left.x ^= right.x;
left.y ^= right.y;
left.z ^= right.z;
left.w ^= right.w;
return left;
}

static __host__ __device__ uint4& operator += (uint4& left, const uint4& right) {
static __device__ uint4& operator += (uint4& left, const uint4& right) {
left.x += right.x;
left.y += right.y;
left.z += right.z;
Expand Down
8 changes: 4 additions & 4 deletions sia/sia-rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ char* sia_getheader(CURL *curl, struct pool_infos *pool)
struct data_buffer all_data = { 0 };
struct curl_slist *headers = NULL;
char data[256] = { 0 };
char url[512];
char url[512*3];

// nanopool
snprintf(url, 512, "%s/miner/header?address=%s&worker=%s", //&longpoll
snprintf(url, sizeof(url), "%s/miner/header?address=%s&worker=%s", //&longpoll
pool->url, pool->user, pool->pass);

if (opt_protocol)
Expand Down Expand Up @@ -148,15 +148,15 @@ bool sia_submit(CURL *curl, struct pool_infos *pool, struct work *work)
struct data_buffer all_data = { 0 };
struct curl_slist *headers = NULL;
char buf[256] = { 0 };
char url[512];
char url[512*3];

if (opt_protocol)
applog_hex(work->data, 80);
//applog_hex(&work->data[8], 16);
//applog_hex(&work->data[10], 4);

// nanopool
snprintf(url, 512, "%s/miner/header?address=%s&worker=%s",
snprintf(url, sizeof(url), "%s/miner/header?address=%s&worker=%s",
pool->url, pool->user, pool->pass);

if (opt_protocol)
Expand Down
4 changes: 2 additions & 2 deletions util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ static json_t *json_rpc_call(CURL *curl, const char *url,
json_t *json_rpc_call_pool(CURL *curl, struct pool_infos *pool, const char *req,
bool longpoll_scan, bool longpoll, int *curl_err)
{
char userpass[512];
char userpass[768];
// todo, malloc and store that in pool array
snprintf(userpass, sizeof(userpass), "%s%c%s", pool->user,
strlen(pool->pass)?':':'\0', pool->pass);
Expand All @@ -627,7 +627,7 @@ json_t *json_rpc_call_pool(CURL *curl, struct pool_infos *pool, const char *req,
/* called only from longpoll thread, we have the lp_url */
json_t *json_rpc_longpoll(CURL *curl, char *lp_url, struct pool_infos *pool, const char *req, int *curl_err)
{
char userpass[512];
char userpass[768];
snprintf(userpass, sizeof(userpass), "%s%c%s", pool->user,
strlen(pool->pass)?':':'\0', pool->pass);

Expand Down

0 comments on commit 654e8a1

Please sign in to comment.