Browse Source

* return proper error code in macro DB_READ/DB_WRITE

master
Alex 'AdUser' Z 8 years ago
parent
commit
1310895f32
  1. 10
      src/database.c

10
src/database.c

@ -22,18 +22,12 @@
errno = 0; \ errno = 0; \
memset((buf), 0x0, (len)); \ memset((buf), 0x0, (len)); \
bytes = pread((db)->fd, (buf), (len), (off)); \ bytes = pread((db)->fd, (buf), (len), (off)); \
if (errno) { \ if (errno) { return IMDB_ERR_SYSTEM; }
strncpy((db)->error, strerror(errno), sizeof(db->error)); \
return IMDB_ERR_SYSTEM; \
}
#define DB_WRITE(db, buf, len, off) \ #define DB_WRITE(db, buf, len, off) \
errno = 0; \ errno = 0; \
bytes = pwrite((db)->fd, (buf), (len), (off)); \ bytes = pwrite((db)->fd, (buf), (len), (off)); \
if (errno) { \ if (errno) { return IMDB_ERR_SYSTEM; }
strncpy((db)->error, strerror(errno), sizeof(db->error)); \
return IMDB_ERR_SYSTEM; \
}
const char *imdb_hdr_fmt = "IMDB v%02u, CAPS: %s;"; const char *imdb_hdr_fmt = "IMDB v%02u, CAPS: %s;";

Loading…
Cancel
Save