1
0
mirror of https://github.com/GOSTSec/sgminer synced 2025-01-29 16:04:33 +00:00

Bugfix: Return failure, rather than quit, if BFwrite fails

This commit is contained in:
Luke Dashjr 2012-05-02 10:34:31 -04:00 committed by Con Kolivas
parent 4ba9006d0e
commit 06023e549e

View File

@ -79,14 +79,18 @@ static void BFgets(char *buf, size_t bufLen, int fd)
buf[0] = '\0';
}
static void BFwrite(int fd, const void *buf, ssize_t bufLen)
static ssize_t BFwrite2(int fd, const void *buf, ssize_t bufLen)
{
ssize_t ret = write(fd, buf, bufLen);
if (unlikely(ret != bufLen))
quit(1, "BFwrite failed");
return write(fd, buf, bufLen);
}
#define BFwrite(fd, buf, bufLen) do { \
if ((bufLen) != BFwrite2(fd, buf, bufLen)) { \
applog(LOG_ERR, "Error writing to BitForce (" #buf ")"); \
return 0; \
} \
} while(0)
#define BFclose(fd) close(fd)
static bool bitforce_detect_one(const char *devpath)