diff --git a/parity.c b/parity.c index e7a73636..5d403892 100644 --- a/parity.c +++ b/parity.c @@ -102,15 +102,19 @@ int parity_create(struct snapraid_parity* parity, const char* path, data_off_t* flags |= O_SEQUENTIAL; parity->f = open(parity->path, flags, 0600); if (parity->f == -1) { + /* LCOV_EXCL_START */ fprintf(stderr, "Error opening parity file '%s'. %s.\n", parity->path, strerror(errno)); return -1; + /* LCOV_EXCL_STOP */ } /* get the stat info */ ret = fstat(parity->f, &parity->st); if (ret != 0) { + /* LCOV_EXCL_START */ fprintf(stderr, "Error accessing parity file '%s'. %s.\n", parity->path, strerror(errno)); goto bail; + /* LCOV_EXCL_STOP */ } #if HAVE_POSIX_FADVISE @@ -118,8 +122,10 @@ int parity_create(struct snapraid_parity* parity, const char* path, data_off_t* /* advise sequential access */ ret = posix_fadvise(parity->f, 0, 0, POSIX_FADV_SEQUENTIAL); if (ret != 0) { + /* LCOV_EXCL_START */ fprintf(stderr, "Error advising parity file '%s'. %s.\n", parity->path, strerror(ret)); goto bail; + /* LCOV_EXCL_STOP */ } } #endif @@ -131,10 +137,12 @@ int parity_create(struct snapraid_parity* parity, const char* path, data_off_t* return 0; bail: + /* LCOV_EXCL_START */ close(parity->f); parity->f = -1; parity->valid_size = 0; return -1; + /* LCOV_EXCL_STOP */ } int parity_chsize(struct snapraid_parity* parity, data_off_t size, data_off_t* out_size, int skip_fallocate) @@ -159,8 +167,10 @@ int parity_chsize(struct snapraid_parity* parity, data_off_t size, data_off_t* o /* Checking the glibc code (2.11.1 and 2.14.1) it seems that ENOSYS */ /* may be returned in errno, so we support both the return way */ if (ret > 0) { /* if a positive error is returned, convert it to errno */ + /* LCOV_EXCL_START */ errno = ret; ret = -1; + /* LCOV_EXCL_STOP */ } } else { errno = EOPNOTSUPP; @@ -188,8 +198,10 @@ int parity_chsize(struct snapraid_parity* parity, data_off_t size, data_off_t* o /* get the stat info */ ret = fstat(parity->f, &parity->st); if (ret != 0) { + /* LCOV_EXCL_START */ fprintf(stderr, "Error accessing parity file '%s'. %s.\n", parity->path, strerror(errno)); goto bail; + /* LCOV_EXCL_STOP */ } /* return the new size */ @@ -197,12 +209,14 @@ int parity_chsize(struct snapraid_parity* parity, data_off_t size, data_off_t* o /* now check the error */ if (f_ret != 0) { + /* LCOV_EXCL_START */ if (f_errno == ENOSPC) { fprintf(stderr, "Failed to grow parity file '%s' to size %"PRIu64" using %s due lack of space.\n", parity->path, size, call); } else { fprintf(stderr, "Error growing parity file '%s' to size %"PRIu64" using %s. Do you have enough space? %s.\n", parity->path, size, call, strerror(f_errno)); } goto bail; + /* LCOV_EXCL_STOP */ } } else if (parity->st.st_size > size) { int f_ret; @@ -218,8 +232,10 @@ int parity_chsize(struct snapraid_parity* parity, data_off_t size, data_off_t* o /* get the stat info */ ret = fstat(parity->f, &parity->st); if (ret != 0) { + /* LCOV_EXCL_START */ fprintf(stderr, "Error accessing parity file '%s'. %s.\n", parity->path, strerror(errno)); goto bail; + /* LCOV_EXCL_STOP */ } /* return the new size */ @@ -227,8 +243,10 @@ int parity_chsize(struct snapraid_parity* parity, data_off_t size, data_off_t* o /* now check the error */ if (f_ret != 0) { + /* LCOV_EXCL_START */ fprintf(stderr, "Error truncating parity file '%s' to size %"PRIu64". %s.\n", parity->path, size, strerror(f_errno)); goto bail; + /* LCOV_EXCL_STOP */ } /* adjust the valid to the new size */ @@ -238,8 +256,10 @@ int parity_chsize(struct snapraid_parity* parity, data_off_t size, data_off_t* o return 0; bail: + /* LCOV_EXCL_START */ parity->valid_size = 0; return -1; + /* LCOV_EXCL_STOP */ } int parity_open(struct snapraid_parity* parity, const char* path, int skip_sequential) @@ -264,8 +284,10 @@ int parity_open(struct snapraid_parity* parity, const char* path, int skip_seque /* get the stat info */ ret = fstat(parity->f, &parity->st); if (ret != 0) { + /* LCOV_EXCL_START */ fprintf(stderr, "Error accessing parity file '%s'. %s.\n", parity->path, strerror(errno)); goto bail; + /* LCOV_EXCL_STOP */ } /* get the size of the exising data */ @@ -276,8 +298,10 @@ int parity_open(struct snapraid_parity* parity, const char* path, int skip_seque /* advise sequential access */ ret = posix_fadvise(parity->f, 0, 0, POSIX_FADV_SEQUENTIAL); if (ret != 0) { + /* LCOV_EXCL_START */ fprintf(stderr, "Error advising parity file '%s'. %s.\n", parity->path, strerror(ret)); goto bail; + /* LCOV_EXCL_STOP */ } } #endif @@ -285,10 +309,12 @@ int parity_open(struct snapraid_parity* parity, const char* path, int skip_seque return 0; bail: + /* LCOV_EXCL_START */ close(parity->f); parity->f = -1; parity->valid_size = 0; return -1; + /* LCOV_EXCL_STOP */ } int parity_sync(struct snapraid_parity* parity) @@ -301,8 +327,10 @@ int parity_sync(struct snapraid_parity* parity) /* in case of a system crash. */ ret = fsync(parity->f); if (ret != 0) { + /* LCOV_EXCL_START */ fprintf(stderr, "Error synching parity file '%s'. %s.\n", parity->path, strerror(errno)); return -1; + /* LCOV_EXCL_STOP */ } #endif @@ -315,6 +343,7 @@ int parity_close(struct snapraid_parity* parity) ret = close(parity->f); if (ret != 0) { + /* LCOV_EXCL_START */ /* invalidate for error */ parity->f = -1; parity->valid_size = 0; @@ -324,6 +353,7 @@ int parity_close(struct snapraid_parity* parity) /* In a normal filesystem (not NFS) it should never happen */ fprintf(stderr, "Error closing parity file '%s'. %s.\n", parity->path, strerror(errno)); return -1; + /* LCOV_EXCL_STOP */ } /* reset the descriptor */ @@ -344,23 +374,27 @@ int parity_write(struct snapraid_parity* parity, block_off_t pos, unsigned char* write_ret = pwrite(parity->f, block_buffer, block_size, offset); #else if (lseek(parity->f, offset, SEEK_SET) != offset) { + /* LCOV_EXCL_START */ if (errno == ENOSPC) { fprintf(stderr, "Failed to grow parity file '%s' using lseek due lack of space.\n", parity->path); } else { fprintf(stderr, "Error seeking file '%s'. %s.\n", parity->path, strerror(errno)); } return -1; + /* LCOV_EXCL_STOP */ } write_ret = write(parity->f, block_buffer, block_size); #endif if (write_ret != (ssize_t)block_size) { /* conversion is safe because block_size is always small */ + /* LCOV_EXCL_START */ if (errno == ENOSPC) { fprintf(stderr, "Failed to grow parity file '%s' using write due lack of space.\n", parity->path); } else { fprintf(stderr, "Error writing file '%s'. %s.\n", parity->path, strerror(errno)); } return -1; + /* LCOV_EXCL_STOP */ } /* adjust the size of the valid data */ @@ -390,8 +424,10 @@ int parity_read(struct snapraid_parity* parity, block_off_t pos, unsigned char* #if !HAVE_PREAD if (lseek(parity->f, offset, SEEK_SET) != offset) { + /* LCOV_EXCL_START */ fprintf(out, "Error seeking file '%s' at offset %"PRIu64". %s.\n", parity->path, offset, strerror(errno)); return -1; + /* LCOV_EXCL_STOP */ } #endif @@ -404,12 +440,16 @@ int parity_read(struct snapraid_parity* parity, block_off_t pos, unsigned char* read_ret = read(parity->f, block_buffer + count, block_size - count); #endif if (read_ret < 0) { + /* LCOV_EXCL_START */ fprintf(out, "Error reading file '%s' at offset %"PRIu64" for size %u. %s.\n", parity->path, offset + count, block_size - count, strerror(errno)); return -1; + /* LCOV_EXCL_STOP */ } if (read_ret == 0) { + /* LCOV_EXCL_START */ fprintf(out, "Unexpected end of file '%s' at offset %"PRIu64". %s.\n", parity->path, offset, strerror(errno)); return -1; + /* LCOV_EXCL_STOP */ } count += read_ret; diff --git a/util.c b/util.c index 67040174..692abb19 100644 --- a/util.c +++ b/util.c @@ -71,10 +71,12 @@ STREAM* sopen_read(const char* file) /* advise sequential access */ ret = posix_fadvise(s->handle[0].f, 0, 0, POSIX_FADV_SEQUENTIAL); if (ret != 0) { + /* LCOV_EXCL_START */ close(s->handle[0].f); free(s->handle); free(s); return 0; + /* LCOV_EXCL_STOP */ } #endif @@ -127,15 +129,19 @@ int sopen_multi_file(STREAM* s, unsigned i, const char* file) f = open(file, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_SEQUENTIAL, 0600); if (f == -1) { + /* LCOV_EXCL_START */ return -1; + /* LCOV_EXCL_STOP */ } #if HAVE_POSIX_FADVISE /* advise sequential access */ ret = posix_fadvise(f, 0, 0, POSIX_FADV_SEQUENTIAL); if (ret != 0) { + /* LCOV_EXCL_START */ close(f); return -1; + /* LCOV_EXCL_STOP */ } #endif @@ -150,29 +156,41 @@ int sclose(STREAM* s) unsigned i; if (s->state == STREAM_STATE_WRITE) { - if (sflush(s) != 0) + if (sflush(s) != 0) { + /* LCOV_EXCL_START */ fail = 1; + /* LCOV_EXCL_STOP */ + } } for(i=0;ihandle_size;++i) { - if (close(s->handle[i].f) != 0) + if (close(s->handle[i].f) != 0) { + /* LCOV_EXCL_START */ fail = 1; + /* LCOV_EXCL_STOP */ + } } free(s->handle); free(s->buffer); free(s); - if (fail) + if (fail) { + /* LCOV_EXCL_START */ return -1; + /* LCOV_EXCL_STOP */ + } return 0; } int shandle(STREAM* s) { - if (!s->handle_size) + if (!s->handle_size) { + /* LCOV_EXCL_START */ return -1; + /* LCOV_EXCL_STOP */ + } return s->handle[0].f; } @@ -181,14 +199,19 @@ int sfill(STREAM* s) { ssize_t ret; - if (s->state != STREAM_STATE_READ) + if (s->state != STREAM_STATE_READ) { + /* LCOV_EXCL_START */ return EOF; + /* LCOV_EXCL_STOP */ + } ret = read(s->handle[0].f, s->buffer, STREAM_SIZE); if (ret < 0) { + /* LCOV_EXCL_START */ s->state = STREAM_STATE_ERROR; return EOF; + /* LCOV_EXCL_STOP */ } if (ret == 0) { s->state = STREAM_STATE_EOF; @@ -215,8 +238,11 @@ int sflush(STREAM* s) ssize_t size; unsigned i; - if (s->state != STREAM_STATE_WRITE) + if (s->state != STREAM_STATE_WRITE) { + /* LCOV_EXCL_START */ return EOF; + /* LCOV_EXCL_STOP */ + } size = s->pos - s->buffer; if (!size) @@ -230,9 +256,11 @@ int sflush(STREAM* s) ret = write(s->handle[i].f, s->buffer, size); if (ret != size) { + /* LCOV_EXCL_START */ s->state = STREAM_STATE_ERROR; s->state_index = i; return EOF; + /* LCOV_EXCL_STOP */ } } @@ -280,8 +308,11 @@ int sgettok(STREAM* f, char* str, int size) *i++ = c; - if (i == send) + if (i == send) { + /* LCOV_EXCL_START */ return -1; + /* LCOV_EXCL_STOP */ + } } *i = 0; @@ -299,17 +330,19 @@ int sread(STREAM* f, void* void_data, unsigned size) unsigned char* pos = sptrget(f); /* copy it */ - while (size--) { + while (size--) *data++ = *pos++; - } sptrset(f, pos); } else { /* standard version using sputc() */ while (size--) { int c = sgetc(f); - if (c == EOF) + if (c == EOF) { + /* LCOV_EXCL_START */ return -1; + /* LCOV_EXCL_STOP */ + } *data++ = c; } @@ -341,8 +374,11 @@ int sgetline(STREAM* f, char* str, int size) *i++ = c; - if (i == send) + if (i == send) { + /* LCOV_EXCL_START */ return -1; + /* LCOV_EXCL_STOP */ + } } sptrset(f, pos); @@ -350,7 +386,9 @@ int sgetline(STREAM* f, char* str, int size) while (1) { c = sgetc(f); if (c == EOF) { + /* LCOV_EXCL_START */ break; + /* LCOV_EXCL_STOP */ } if (c == '\n') { /* remove ending carrige return to support the Windows CR+LF format */ @@ -362,8 +400,11 @@ int sgetline(STREAM* f, char* str, int size) *i++ = c; - if (i == send) + if (i == send) { + /* LCOV_EXCL_START */ return -1; + /* LCOV_EXCL_STOP */ + } } } @@ -377,13 +418,15 @@ int sgetlasttok(STREAM* f, char* str, int size) int ret; ret = sgetline(f, str, size); - if (ret < 0) + if (ret < 0) { + /* LCOV_EXCL_START */ return ret; - - while (ret > 0 && (str[ret-1] == ' ' || str[ret-1] == '\t')) { - --ret; + /* LCOV_EXCL_STOP */ } + while (ret > 0 && (str[ret-1] == ' ' || str[ret-1] == '\t')) + --ret; + str[ret] = 0; return ret; @@ -411,8 +454,10 @@ int sgetu32(STREAM* f, uint32_t* value) sungetc(c, f); return 0; } else { + /* LCOV_EXCL_START */ /* nothing read */ return -1; + /* LCOV_EXCL_STOP */ } } @@ -438,8 +483,10 @@ int sgetu64(STREAM* f, uint64_t* value) sungetc(c, f); return 0; } else { + /* LCOV_EXCL_START */ /* nothing read */ return -1; + /* LCOV_EXCL_STOP */ } } @@ -471,7 +518,9 @@ int sgethex(STREAM* f, void* void_data, int size) /* at the end check if a digit was wrong */ if (x > 0xFF) { + /* LCOV_EXCL_START */ return -1; + /* LCOV_EXCL_STOP */ } sptrset(f, pos); @@ -484,19 +533,28 @@ int sgethex(STREAM* f, void* void_data, int size) int c; c = sgetc(f); - if (c == EOF) + if (c == EOF) { + /* LCOV_EXCL_START */ return -1; + /* LCOV_EXCL_STOP */ + } b0 = strdecset[c]; c = sgetc(f); - if (c == EOF) + if (c == EOF) { + /* LCOV_EXCL_START */ return -1; + /* LCOV_EXCL_STOP */ + } b1 = strdecset[c]; b = (b0 << 4) | b1; - if (b > 0xFF) + if (b > 0xFF) { + /* LCOV_EXCL_START */ return -1; + /* LCOV_EXCL_STOP */ + } *data++ = b; } @@ -516,15 +574,21 @@ int sgetb32(STREAM* f, uint32_t* value) s = 0; loop: c = sgetc(f); - if (c == EOF) + if (c == EOF) { + /* LCOV_EXCL_START */ return -1; + /* LCOV_EXCL_STOP */ + } b = (unsigned char)c; if ((b & 0x80) == 0) { v |= (uint32_t)b << s; s += 7; - if (s >= 32) + if (s >= 32) { + /* LCOV_EXCL_START */ return -1; + /* LCOV_EXCL_STOP */ + } goto loop; } @@ -546,15 +610,21 @@ int sgetb64(STREAM* f, uint64_t* value) s = 0; loop: c = sgetc(f); - if (c == EOF) + if (c == EOF) { + /* LCOV_EXCL_START */ return -1; + /* LCOV_EXCL_STOP */ + } b = (unsigned char)c; if ((b & 0x80) == 0) { v |= (uint64_t)b << s; s += 7; - if (s >= 64) + if (s >= 64) { + /* LCOV_EXCL_START */ return -1; + /* LCOV_EXCL_STOP */ + } goto loop; } @@ -569,8 +639,11 @@ int sgetble32(STREAM* f, uint32_t* value) { unsigned char buf[4]; - if (sread(f, buf, 4) != 0) + if (sread(f, buf, 4) != 0) { + /* LCOV_EXCL_START */ return -1; + /* LCOV_EXCL_STOP */ + } *value = buf[0] | (uint32_t)buf[1] << 8 | (uint32_t)buf[2] << 16 | (uint32_t)buf[3] << 24; @@ -581,11 +654,17 @@ int sgetbs(STREAM* f, char* str, int size) { uint32_t len; - if (sgetb32(f, &len) < 0) + if (sgetb32(f, &len) < 0) { + /* LCOV_EXCL_START */ return -1; + /* LCOV_EXCL_STOP */ + } - if (len + 1 > (uint32_t)size) + if (len + 1 > (uint32_t)size) { + /* LCOV_EXCL_START */ return -1; + /* LCOV_EXCL_STOP */ + } str[len] = 0; @@ -595,8 +674,11 @@ int sgetbs(STREAM* f, char* str, int size) int sputs(const char* str, STREAM* f) { while (*str) { - if (sputc(*str++, f) != 0) + if (sputc(*str++, f) != 0) { + /* LCOV_EXCL_START */ return -1; + /* LCOV_EXCL_STOP */ + } } return 0; @@ -612,16 +694,18 @@ int swrite(const void* void_data, unsigned size, STREAM* f) unsigned char* pos = sptrget(f); /* copy it */ - while (size--) { + while (size--) *pos++ = *data++; - } sptrset(f, pos); } else { /* standard version using sputc() */ while (size--) { - if (sputc(*data++, f) != 0) + if (sputc(*data++, f) != 0) { + /* LCOV_EXCL_START */ return -1; + /* LCOV_EXCL_STOP */ + } } } @@ -697,10 +781,16 @@ int sputhex(const void* void_data, int size, STREAM* f) while (size) { unsigned b = *data; - if (sputc(strhexset[b >> 4], f) != 0) + if (sputc(strhexset[b >> 4], f) != 0) { + /* LCOV_EXCL_START */ return -1; - if (sputc(strhexset[b & 0xF], f) != 0) + /* LCOV_EXCL_STOP */ + } + if (sputc(strhexset[b & 0xF], f) != 0) { + /* LCOV_EXCL_START */ return -1; + /* LCOV_EXCL_STOP */ + } ++data; --size; @@ -768,8 +858,11 @@ int sputbs(const char* str, STREAM* f) { size_t len = strlen(str); - if (sputb32(len, f) != 0) + if (sputb32(len, f) != 0) { + /* LCOV_EXCL_START */ return -1; + /* LCOV_EXCL_STOP */ + } return swrite(str, len, f); } @@ -781,9 +874,11 @@ int ssync(STREAM* s) for(i=0;ihandle_size;++i) { if (fsync(s->handle[i].f) != 0) { + /* LCOV_EXCL_START */ s->state = STREAM_STATE_ERROR; s->state_index = i; return -1; + /* LCOV_EXCL_STOP */ } } @@ -1148,8 +1243,10 @@ void pathcpy(char* dst, size_t size, const char* src) size_t len = strlen(src); if (len + 1 > size) { + /* LCOV_EXCL_START */ fprintf(stderr, "Path too long\n"); exit(EXIT_FAILURE); + /* LCOV_EXCL_STOP */ } memcpy(dst, src, len + 1); @@ -1161,8 +1258,10 @@ void pathcat(char* dst, size_t size, const char* src) size_t src_len = strlen(src); if (dst_len + src_len + 1 > size) { + /* LCOV_EXCL_START */ fprintf(stderr, "Path too long\n"); exit(EXIT_FAILURE); + /* LCOV_EXCL_STOP */ } memcpy(dst + dst_len, src, src_len + 1); @@ -1206,8 +1305,10 @@ void pathprint(char* dst, size_t size, const char* format, ...) va_end(ap); if (len >= size) { + /* LCOV_EXCL_START */ fprintf(stderr, "Path too long\n"); exit(EXIT_FAILURE); + /* LCOV_EXCL_STOP */ } } @@ -1217,8 +1318,10 @@ void pathslash(char* dst, size_t size) if (len > 0 && dst[len - 1] != '/') { if (len + 2 >= size) { + /* LCOV_EXCL_START */ fprintf(stderr, "Path too long\n"); exit(EXIT_FAILURE); + /* LCOV_EXCL_STOP */ } dst[len] = '/'; @@ -1294,13 +1397,17 @@ int mkancestor(const char* file) /* recursively create them all */ if (mkancestor(dir) != 0) { + /* LCOV_EXCL_START */ return -1; + /* LCOV_EXCL_STOP */ } /* create it */ if (mkdir(dir, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) != 0) { + /* LCOV_EXCL_START */ fprintf(stderr, "Error creating directory '%s'. %s.\n", dir, strerror(errno)); return -1; + /* LCOV_EXCL_STOP */ } return 0; @@ -1321,11 +1428,13 @@ void* malloc_nofail(size_t size) void* ptr = malloc(size); if (!ptr) { + /* LCOV_EXCL_START */ /* don't use printf to avoid any possible extra allocation */ if (write(2, "Low Memory\n", 11) != 11) { /* ignore error */ } exit(EXIT_FAILURE); + /* LCOV_EXCL_STOP */ } #ifndef CHECKER /* Don't preinitialize when running for valgrind */ @@ -1353,11 +1462,13 @@ char* strdup_nofail(const char* str) ptr = malloc(size); if (!ptr) { + /* LCOV_EXCL_START */ /* don't use printf to avoid any possible extra allocation */ if (write(2, "Low Memory\n", 11) != 11) { /* ignore error */ } exit(EXIT_FAILURE); + /* LCOV_EXCL_STOP */ } memcpy(ptr, str, size); @@ -1374,11 +1485,13 @@ void* malloc_nofail_align(size_t size, void** freeptr) ptr = raid_malloc_align(size, freeptr); if (!ptr) { + /* LCOV_EXCL_START */ /* don't use printf to avoid any possible extra allocation */ if (write(2, "Low Memory\n", 11) != 11) { /* ignore error */ } exit(EXIT_FAILURE); + /* LCOV_EXCL_STOP */ } return ptr; @@ -1391,11 +1504,13 @@ void** malloc_nofail_vector_align(int nd, int n, size_t size, void** freeptr) ptr = raid_malloc_vector(nd, n, size, freeptr); if (!ptr) { + /* LCOV_EXCL_START */ /* don't use printf to avoid any possible extra allocation */ if (write(2, "Low Memory\n", 11) != 11) { /* ignore error */ } exit(EXIT_FAILURE); + /* LCOV_EXCL_STOP */ } return ptr; @@ -1409,9 +1524,11 @@ void mrand_vector(int n , size_t size, void** vv) void mtest_vector(int n , size_t size, void** vv) { if (raid_mtest_vector(n, size, vv) != 0) { + /* LCOV_EXCL_START */ fprintf(stderr, "DANGER! Your RAM memory is broken! DO NOT PROCEED UNTIL FIXED!\n"); fprintf(stderr, "Try running some memory test like http://www.memtest86.com/\n"); exit(EXIT_FAILURE); + /* LCOV_EXCL_STOP */ } } @@ -1480,9 +1597,11 @@ void memhash(unsigned kind, const unsigned char* seed, void* digest, const void* SpookyHash128(src, size, seed, digest); break; default: + /* LCOV_EXCL_START */ fprintf(stderr, "Internal inconsistency in hash function %u\n", kind); exit(EXIT_FAILURE); break; + /* LCOV_EXCL_STOP */ } } @@ -1492,7 +1611,10 @@ const char* hash_config_name(unsigned kind) case HASH_UNDEFINED : return "undefined"; case HASH_MURMUR3 : return "murmur3"; case HASH_SPOOKY2 : return "spooky2"; - default: return "unknown"; + default: + /* LCOV_EXCL_START */ + return "unknown"; + /* LCOV_EXCL_STOP */ } } @@ -1520,13 +1642,17 @@ int lock_lock(const char* file) f = open(file, O_CREAT | O_TRUNC | O_WRONLY, 0600); if (f == -1) { + /* LCOV_EXCL_START */ return -1; + /* LCOV_EXCL_STOP */ } /* exclusive lock, not blocking */ if (flock(f, LOCK_EX | LOCK_NB) == -1) { + /* LCOV_EXCL_START */ close(f); return -1; + /* LCOV_EXCL_STOP */ } return 0; @@ -1542,7 +1668,9 @@ int lock_unlock(int f) * that could have already opened it. */ if (close(f) == -1) { + /* LCOV_EXCL_START */ return -1; + /* LCOV_EXCL_STOP */ } return 0;