1
0
mirror of https://github.com/GOSTSec/sgminer synced 2025-01-25 22:14:36 +00:00

Merge pull request #98 from kanoi/master

Fix compile warnings in api.c/ Fix midstate
This commit is contained in:
Con Kolivas 2012-01-29 22:55:59 -08:00
commit 4b994b011b
5 changed files with 39 additions and 36 deletions

46
api.c
View File

@ -336,7 +336,7 @@ struct CODES {
{ SEVERITY_ERR, MSG_MISFN, PARAM_NONE, "Missing save filename parameter" }, { SEVERITY_ERR, MSG_MISFN, PARAM_NONE, "Missing save filename parameter" },
{ SEVERITY_ERR, MSG_BADFN, PARAM_STR, "Can't open or create save file '%s'" }, { SEVERITY_ERR, MSG_BADFN, PARAM_STR, "Can't open or create save file '%s'" },
{ SEVERITY_ERR, MSG_SAVED, PARAM_STR, "Configuration saved to file '%s'" }, { SEVERITY_ERR, MSG_SAVED, PARAM_STR, "Configuration saved to file '%s'" },
{ SEVERITY_FAIL } { SEVERITY_FAIL, 0, 0, NULL }
}; };
static int bye = 0; static int bye = 0;
@ -445,7 +445,7 @@ static char *message(int messageid, int paramid, char *param2, bool isjson)
return msg_buffer; return msg_buffer;
} }
static void apiversion(SOCKETTYPE c, char *param, bool isjson) static void apiversion(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson)
{ {
if (isjson) if (isjson)
sprintf(io_buffer, "%s," JSON_VERSION "{\"CGMiner\":\"%s\",\"API\":\"%s\"}" JSON_CLOSE, sprintf(io_buffer, "%s," JSON_VERSION "{\"CGMiner\":\"%s\",\"API\":\"%s\"}" JSON_CLOSE,
@ -457,7 +457,7 @@ static void apiversion(SOCKETTYPE c, char *param, bool isjson)
VERSION, APIVERSION, SEPARATOR); VERSION, APIVERSION, SEPARATOR);
} }
static void minerconfig(SOCKETTYPE c, char *param, bool isjson) static void minerconfig(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson)
{ {
char buf[BUFSIZ]; char buf[BUFSIZ];
int cpucount = 0; int cpucount = 0;
@ -573,7 +573,7 @@ static void cpustatus(int cpu, bool isjson)
} }
#endif #endif
static void devstatus(SOCKETTYPE c, char *param, bool isjson) static void devstatus(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson)
{ {
int i; int i;
@ -610,7 +610,7 @@ static void devstatus(SOCKETTYPE c, char *param, bool isjson)
strcat(io_buffer, JSON_CLOSE); strcat(io_buffer, JSON_CLOSE);
} }
static void gpudev(SOCKETTYPE c, char *param, bool isjson) static void gpudev(__maybe_unused SOCKETTYPE c, char *param, bool isjson)
{ {
int id; int id;
@ -644,7 +644,7 @@ static void gpudev(SOCKETTYPE c, char *param, bool isjson)
} }
#ifdef WANT_CPUMINE #ifdef WANT_CPUMINE
static void cpudev(SOCKETTYPE c, char *param, bool isjson) static void cpudev(__maybe_unused SOCKETTYPE c, char *param, bool isjson)
{ {
int id; int id;
@ -678,7 +678,7 @@ static void cpudev(SOCKETTYPE c, char *param, bool isjson)
} }
#endif #endif
static void poolstatus(SOCKETTYPE c, char *param, bool isjson) static void poolstatus(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson)
{ {
char buf[BUFSIZ]; char buf[BUFSIZ];
char *status, *lp; char *status, *lp;
@ -740,7 +740,7 @@ static void poolstatus(SOCKETTYPE c, char *param, bool isjson)
strcat(io_buffer, JSON_CLOSE); strcat(io_buffer, JSON_CLOSE);
} }
static void summary(SOCKETTYPE c, char *param, bool isjson) static void summary(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson)
{ {
double utility, mhs; double utility, mhs;
@ -786,7 +786,7 @@ static void summary(SOCKETTYPE c, char *param, bool isjson)
#endif #endif
} }
static void gpuenable(SOCKETTYPE c, char *param, bool isjson) static void gpuenable(__maybe_unused SOCKETTYPE c, char *param, bool isjson)
{ {
struct thr_info *thr; struct thr_info *thr;
int gpu; int gpu;
@ -832,7 +832,7 @@ static void gpuenable(SOCKETTYPE c, char *param, bool isjson)
strcpy(io_buffer, message(MSG_GPUREN, id, NULL, isjson)); strcpy(io_buffer, message(MSG_GPUREN, id, NULL, isjson));
} }
static void gpudisable(SOCKETTYPE c, char *param, bool isjson) static void gpudisable(__maybe_unused SOCKETTYPE c, char *param, bool isjson)
{ {
int id; int id;
@ -862,7 +862,7 @@ static void gpudisable(SOCKETTYPE c, char *param, bool isjson)
strcpy(io_buffer, message(MSG_GPUDIS, id, NULL, isjson)); strcpy(io_buffer, message(MSG_GPUDIS, id, NULL, isjson));
} }
static void gpurestart(SOCKETTYPE c, char *param, bool isjson) static void gpurestart(__maybe_unused SOCKETTYPE c, char *param, bool isjson)
{ {
int id; int id;
@ -887,7 +887,7 @@ static void gpurestart(SOCKETTYPE c, char *param, bool isjson)
strcpy(io_buffer, message(MSG_GPUREI, id, NULL, isjson)); strcpy(io_buffer, message(MSG_GPUREI, id, NULL, isjson));
} }
static void gpucount(SOCKETTYPE c, char *param, bool isjson) static void gpucount(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson)
{ {
char buf[BUFSIZ]; char buf[BUFSIZ];
@ -901,7 +901,7 @@ static void gpucount(SOCKETTYPE c, char *param, bool isjson)
strcat(io_buffer, buf); strcat(io_buffer, buf);
} }
static void cpucount(SOCKETTYPE c, char *param, bool isjson) static void cpucount(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson)
{ {
char buf[BUFSIZ]; char buf[BUFSIZ];
int count = 0; int count = 0;
@ -920,7 +920,7 @@ static void cpucount(SOCKETTYPE c, char *param, bool isjson)
strcat(io_buffer, buf); strcat(io_buffer, buf);
} }
static void switchpool(SOCKETTYPE c, char *param, bool isjson) static void switchpool(__maybe_unused SOCKETTYPE c, char *param, bool isjson)
{ {
struct pool *pool; struct pool *pool;
int id; int id;
@ -983,7 +983,7 @@ static bool splitgpuvalue(char *param, int *gpu, char **value, bool isjson)
return true; return true;
} }
static void gpuintensity(SOCKETTYPE c, char *param, bool isjson) static void gpuintensity(__maybe_unused SOCKETTYPE c, char *param, bool isjson)
{ {
int id; int id;
char *value; char *value;
@ -1012,7 +1012,7 @@ static void gpuintensity(SOCKETTYPE c, char *param, bool isjson)
strcpy(io_buffer, message(MSG_GPUINT, id, intensitystr, isjson)); strcpy(io_buffer, message(MSG_GPUINT, id, intensitystr, isjson));
} }
static void gpumem(SOCKETTYPE c, char *param, bool isjson) static void gpumem(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson)
{ {
#ifdef HAVE_ADL #ifdef HAVE_ADL
int id; int id;
@ -1033,7 +1033,7 @@ static void gpumem(SOCKETTYPE c, char *param, bool isjson)
#endif #endif
} }
static void gpuengine(SOCKETTYPE c, char *param, bool isjson) static void gpuengine(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson)
{ {
#ifdef HAVE_ADL #ifdef HAVE_ADL
int id; int id;
@ -1054,7 +1054,7 @@ static void gpuengine(SOCKETTYPE c, char *param, bool isjson)
#endif #endif
} }
static void gpufan(SOCKETTYPE c, char *param, bool isjson) static void gpufan(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson)
{ {
#ifdef HAVE_ADL #ifdef HAVE_ADL
int id; int id;
@ -1075,7 +1075,7 @@ static void gpufan(SOCKETTYPE c, char *param, bool isjson)
#endif #endif
} }
static void gpuvddc(SOCKETTYPE c, char *param, bool isjson) static void gpuvddc(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson)
{ {
#ifdef HAVE_ADL #ifdef HAVE_ADL
int id; int id;
@ -1098,7 +1098,7 @@ static void gpuvddc(SOCKETTYPE c, char *param, bool isjson)
static void send_result(SOCKETTYPE c, bool isjson); static void send_result(SOCKETTYPE c, bool isjson);
void doquit(SOCKETTYPE c, char *param, bool isjson) void doquit(SOCKETTYPE c, __maybe_unused char *param, bool isjson)
{ {
if (isjson) if (isjson)
strcpy(io_buffer, JSON_START JSON_BYE); strcpy(io_buffer, JSON_START JSON_BYE);
@ -1111,7 +1111,7 @@ void doquit(SOCKETTYPE c, char *param, bool isjson)
kill_work(); kill_work();
} }
void dosave(SOCKETTYPE c, char *param, bool isjson) void dosave(__maybe_unused SOCKETTYPE c, char *param, bool isjson)
{ {
FILE *fcfg; FILE *fcfg;
@ -1158,7 +1158,7 @@ struct CMDS {
{ "gpuvddc", gpuvddc}, { "gpuvddc", gpuvddc},
{ "save", dosave }, { "save", dosave },
{ "quit", doquit }, { "quit", doquit },
{ NULL } { NULL, NULL }
}; };
static void send_result(SOCKETTYPE c, bool isjson) static void send_result(SOCKETTYPE c, bool isjson)
@ -1251,7 +1251,7 @@ void api(void)
if (!opt_api_network) { if (!opt_api_network) {
serv.sin_addr.s_addr = inet_addr(localaddr); serv.sin_addr.s_addr = inet_addr(localaddr);
if (serv.sin_addr.s_addr == INVINETADDR) { if (serv.sin_addr.s_addr == (in_addr_t)INVINETADDR) {
applog(LOG_ERR, "API2 initialisation failed (%s)%s", SOCKERRMSG, UNAVAILABLE); applog(LOG_ERR, "API2 initialisation failed (%s)%s", SOCKERRMSG, UNAVAILABLE);
return; return;
} }

View File

@ -147,6 +147,7 @@ enum {
#define unlikely(expr) (expr) #define unlikely(expr) (expr)
#define likely(expr) (expr) #define likely(expr) (expr)
#endif #endif
#define __maybe_unused __attribute__((unused))
#if defined(__i386__) #if defined(__i386__)
#define WANT_CRYPTOPP_ASM32 #define WANT_CRYPTOPP_ASM32

20
sha2.c
View File

@ -40,10 +40,10 @@
#ifndef GET_ULONG_BE #ifndef GET_ULONG_BE
#define GET_ULONG_BE(n,b,i) \ #define GET_ULONG_BE(n,b,i) \
{ \ { \
(n) = ( (unsigned long) (b)[(i) ] << 24 ) \ (n) = ( (uint32_t) (b)[(i) ] << 24 ) \
| ( (unsigned long) (b)[(i) + 1] << 16 ) \ | ( (uint32_t) (b)[(i) + 1] << 16 ) \
| ( (unsigned long) (b)[(i) + 2] << 8 ) \ | ( (uint32_t) (b)[(i) + 2] << 8 ) \
| ( (unsigned long) (b)[(i) + 3] ); \ | ( (uint32_t) (b)[(i) + 3] ); \
} }
#endif #endif
@ -95,8 +95,8 @@ void sha2_starts( sha2_context *ctx, int is224 )
static void sha2_process( sha2_context *ctx, const unsigned char data[64] ) static void sha2_process( sha2_context *ctx, const unsigned char data[64] )
{ {
unsigned long temp1, temp2, W[64]; uint32_t temp1, temp2, W[64];
unsigned long A, B, C, D, E, F, G, H; uint32_t A, B, C, D, E, F, G, H;
GET_ULONG_BE( W[ 0], data, 0 ); GET_ULONG_BE( W[ 0], data, 0 );
GET_ULONG_BE( W[ 1], data, 4 ); GET_ULONG_BE( W[ 1], data, 4 );
@ -230,7 +230,7 @@ static void sha2_process( sha2_context *ctx, const unsigned char data[64] )
void sha2_update( sha2_context *ctx, const unsigned char *input, int ilen ) void sha2_update( sha2_context *ctx, const unsigned char *input, int ilen )
{ {
int fill; int fill;
unsigned long left; uint32_t left;
if( ilen <= 0 ) if( ilen <= 0 )
return; return;
@ -241,7 +241,7 @@ void sha2_update( sha2_context *ctx, const unsigned char *input, int ilen )
ctx->total[0] += ilen; ctx->total[0] += ilen;
ctx->total[0] &= 0xFFFFFFFF; ctx->total[0] &= 0xFFFFFFFF;
if( ctx->total[0] < (unsigned long) ilen ) if( ctx->total[0] < (uint32_t) ilen )
ctx->total[1]++; ctx->total[1]++;
if( left && ilen >= fill ) if( left && ilen >= fill )
@ -281,8 +281,8 @@ static const unsigned char sha2_padding[64] =
*/ */
void sha2_finish( sha2_context *ctx, unsigned char output[32] ) void sha2_finish( sha2_context *ctx, unsigned char output[32] )
{ {
unsigned long last, padn; uint32_t last, padn;
unsigned long high, low; uint32_t high, low;
unsigned char msglen[8]; unsigned char msglen[8];
high = ( ctx->total[0] >> 29 ) high = ( ctx->total[0] >> 29 )

6
sha2.h
View File

@ -26,13 +26,15 @@
#ifndef POLARSSL_SHA2_H #ifndef POLARSSL_SHA2_H
#define POLARSSL_SHA2_H #define POLARSSL_SHA2_H
#include <stdint.h>
/** /**
* \brief SHA-256 context structure * \brief SHA-256 context structure
*/ */
typedef struct typedef struct
{ {
unsigned long total[2]; /*!< number of bytes processed */ uint32_t total[2]; /*!< number of bytes processed */
unsigned long state[8]; /*!< intermediate digest state */ uint32_t state[8]; /*!< intermediate digest state */
unsigned char buffer[64]; /*!< data block being processed */ unsigned char buffer[64]; /*!< data block being processed */
unsigned char ipad[64]; /*!< HMAC: inner padding */ unsigned char ipad[64]; /*!< HMAC: inner padding */

2
util.c
View File

@ -373,7 +373,7 @@ json_t *json_rpc_call(CURL *curl, const char *url,
headers = curl_slist_append(headers, headers = curl_slist_append(headers,
"Content-type: application/json"); "Content-type: application/json");
headers = curl_slist_append(headers, headers = curl_slist_append(headers,
"X-Mining-Extensions: longpoll rollntime"); "X-Mining-Extensions: longpoll midstate rollntime");
headers = curl_slist_append(headers, len_hdr); headers = curl_slist_append(headers, len_hdr);
headers = curl_slist_append(headers, user_agent_hdr); headers = curl_slist_append(headers, user_agent_hdr);
headers = curl_slist_append(headers, "Expect:"); /* disable Expect hdr*/ headers = curl_slist_append(headers, "Expect:"); /* disable Expect hdr*/