Browse Source

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

nfactor-troky
Luke Dashjr 13 years ago committed by Con Kolivas
parent
commit
06023e549e
  1. 14
      driver-bitforce.c

14
driver-bitforce.c

@ -79,14 +79,18 @@ static void BFgets(char *buf, size_t bufLen, int fd) @@ -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)

Loading…
Cancel
Save