Branch Coverage

lib/File/Map.xs
Criterion Covered Total %
branch 126 250 50.4


line true false branch
136 7 13 if (pagesize == 0) {
167 6 3 if (ckWARN(WARN_SUBSTR)) {
169 1 5 if (SvCUR(var) > info->fake_length)
173 8 1 if (string && len)
175 9 0 SV_CHECK_THINKFIRST_COW_DROP(var);
176 0 9 if (SvROK(var))
178 5 4 if (SvPOK(var))
179 5 0 SvPV_free(var);
0 5 SvPV_free(var);
0 0 SvPV_free(var);
0 0 SvPV_free(var);
185 25 1 if (info->real_length) {
186 1 24 if (!SvOK(var))
1 0 if (!SvOK(var))
1 0 if (!SvOK(var))
188 3 21 else if (!SvPOK(var)) {
190 0 3 const char* string = SvPV(var, len);
193 5 16 else if (SvPVX(var) != info->fake_address)
196 16 0 if (ckWARN(WARN_SUBSTR) && SvCUR(var) != info->fake_length) {
1 15 if (ckWARN(WARN_SUBSTR) && SvCUR(var) != info->fake_length) {
204 1 0 if (!SvPOK(var) || sv_len(var) != 0) {
1 0 if (!SvPOK(var) || sv_len(var) != 0) {
206 1 0 if (ckWARN(WARN_SUBSTR))
238 16 2 if (info->real_length && munmap(info->real_address, info->real_length) == -1)
0 16 if (info->real_length && munmap(info->real_address, info->real_length) == -1)
276 0 1 return (Off_t)floor(SvNV(var) + 0.5); /* hic sunt dracones */
282 0 21 if (SvTYPE(var) > SVt_PVMG && SvTYPE(var) != SVt_PVLV)
284 2 19 SV_CHECK_THINKFIRST_COW_DROP(var);
285 0 20 if (SvREADONLY(var))
287 1 19 if (SvMAGICAL(var) && mg_findext(var, PERL_MAGIC_ext, &mmap_table))
0 1 if (SvMAGICAL(var) && mg_findext(var, PERL_MAGIC_ext, &mmap_table))
289 0 20 if (SvROK(var))
291 0 20 if (SvNIOK(var))
293 0 20 if (SvPOK(var))
294 0 0 SvPV_free(var);
0 0 SvPV_free(var);
0 0 SvPV_free(var);
0 0 SvPV_free(var);
295 18 2 SvUPGRADE(var, SVt_PVMG);
318 0 17 if (address == MAP_FAILED)
353 1 18 SvTAINTED_on(var);
354 2 17 if (utf8 && !sv_utf8_decode(var))
0 2 if (utf8 && !sv_utf8_decode(var))
356 9 10 if (!writable)
362 3 0 return Fstat(fd, &info) == 0 && (S_ISREG(info.st_mode) || S_ISBLK(info.st_mode) || S_ISCHR(info.st_mode));
1 2 return Fstat(fd, &info) == 0 && (S_ISREG(info.st_mode) || S_ISBLK(info.st_mode) || S_ISCHR(info.st_mode));
1 0 return Fstat(fd, &info) == 0 && (S_ISREG(info.st_mode) || S_ISBLK(info.st_mode) || S_ISCHR(info.st_mode));
369 9 3 if (!SvMAGICAL(var) || (magic = mg_findext(var, PERL_MAGIC_ext, &mmap_table)) == NULL)
0 9 if (!SvMAGICAL(var) || (magic = mg_findext(var, PERL_MAGIC_ext, &mmap_table)) == NULL)
393 24 0 for (i = 0; i < sizeof prots / sizeof *prots; ++i) {
394 18 6 if (prots[i].length == mode_len && strnEQ(mode, prots[i].key, mode_len))
16 2 if (prots[i].length == mode_len && strnEQ(mode, prots[i].key, mode_len))
403 16 0 const char* mode = SvPV(mode_sv, mode_len);
405 1 15 return protection_pvn(mode, end ? end - mode : mode_len);
494 0 20 if (length > PTR_MAX - correction)
497 17 3 if (length)
500 1 2 if (!is_mappable(fd)) {
510 1 18 SvSETMAGIC(var);
527 9 0 for (i = 0; i < table_size; ++i) {
42 0 for (i = 0; i < table_size; ++i) {
528 8 1 if (strEQ(name, table[i].key))
28 14 if (strEQ(name, table[i].key))
537 14 1 if (PerlIO_fileno(fh) < 0)
539 28 14 for (current = fh; *current; current = PerlIONext(current)) {
540 28 0 if (!map_get(mappable, (*current)->tab->name, 0) || (*current)->flags & PERLIO_F_CRLF)
0 28 if (!map_get(mappable, (*current)->tab->name, 0) || (*current)->flags & PERLIO_F_CRLF)
550 15 1 size_t length = SvOK(length_sv) ? SvIV(length_sv) : info.st_size - offset;
15 0 size_t length = SvOK(length_sv) ? SvIV(length_sv) : info.st_size - offset;
0 15 size_t length = SvOK(length_sv) ? SvIV(length_sv) : info.st_size - offset;
1 0 size_t length = SvOK(length_sv) ? SvIV(length_sv) : info.st_size - offset;
552 15 1 if (offset < 0 || end > info.st_size && !S_ISCHR(info.st_mode))
0 15 if (offset < 0 || end > info.st_size && !S_ISCHR(info.st_mode))
0 0 if (offset < 0 || end > info.st_size && !S_ISCHR(info.st_mode))
570 8 0 const char* mode_raw = SvPV(mode, mode_len);
571 7 1 if (memchr(mode_raw, ':', mode_len) == NULL) {
574 7 0 mode_raw = SvPV(newmode, mode_len);
578 1 7 if (!do_openn(gv, mode_raw, mode_len, 0, 0, 0, NULL, &filename, 1))
579 1 0 Perl_croak(aTHX_ "Couldn't open file %s: %s", SvPV_nolen(filename), strerror(errno));
580 7 0 map_handle(var, IoIFP(GvIO(gv)), mode, offset, length_sv);
7 0 map_handle(var, IoIFP(GvIO(gv)), mode, offset, length_sv);
7 0 map_handle(var, IoIFP(GvIO(gv)), mode, offset, length_sv);
591 0 8 if (flag == -1)
593 1 7 if (length == 0)
600 0 0 if (flags & MAP_ANONYMOUS)
613 0 1 if (EMPTY_MAP(info))
615 0 0 if (SvREADONLY(var) && ckWARN(WARN_IO))
0 0 if (SvREADONLY(var) && ckWARN(WARN_IO))
617 0 0 if (msync(info->real_address, info->real_length, SvTRUE(sync) ? MS_SYNC : MS_ASYNC ) == -1)
0 0 if (msync(info->real_address, info->real_length, SvTRUE(sync) ? MS_SYNC : MS_ASYNC ) == -1)
0 0 if (msync(info->real_address, info->real_length, SvTRUE(sync) ? MS_SYNC : MS_ASYNC ) == -1)
0 0 if (msync(info->real_address, info->real_length, SvTRUE(sync) ? MS_SYNC : MS_ASYNC ) == -1)
0 0 if (msync(info->real_address, info->real_length, SvTRUE(sync) ? MS_SYNC : MS_ASYNC ) == -1)
0 0 if (msync(info->real_address, info->real_length, SvTRUE(sync) ? MS_SYNC : MS_ASYNC ) == -1)
0 0 if (msync(info->real_address, info->real_length, SvTRUE(sync) ? MS_SYNC : MS_ASYNC ) == -1)
0 0 if (msync(info->real_address, info->real_length, SvTRUE(sync) ? MS_SYNC : MS_ASYNC ) == -1)
0 0 if (msync(info->real_address, info->real_length, SvTRUE(sync) ? MS_SYNC : MS_ASYNC ) == -1)
0 0 if (msync(info->real_address, info->real_length, SvTRUE(sync) ? MS_SYNC : MS_ASYNC ) == -1)
0 0 if (msync(info->real_address, info->real_length, SvTRUE(sync) ? MS_SYNC : MS_ASYNC ) == -1)
0 0 if (msync(info->real_address, info->real_length, SvTRUE(sync) ? MS_SYNC : MS_ASYNC ) == -1)
0 0 if (msync(info->real_address, info->real_length, SvTRUE(sync) ? MS_SYNC : MS_ASYNC ) == -1)
0 0 if (msync(info->real_address, info->real_length, SvTRUE(sync) ? MS_SYNC : MS_ASYNC ) == -1)
0 0 if (msync(info->real_address, info->real_length, SvTRUE(sync) ? MS_SYNC : MS_ASYNC ) == -1)
0 0 if (msync(info->real_address, info->real_length, SvTRUE(sync) ? MS_SYNC : MS_ASYNC ) == -1)
0 0 if (msync(info->real_address, info->real_length, SvTRUE(sync) ? MS_SYNC : MS_ASYNC ) == -1)
0 0 if (msync(info->real_address, info->real_length, SvTRUE(sync) ? MS_SYNC : MS_ASYNC ) == -1)
0 0 if (msync(info->real_address, info->real_length, SvTRUE(sync) ? MS_SYNC : MS_ASYNC ) == -1)
0 0 if (msync(info->real_address, info->real_length, SvTRUE(sync) ? MS_SYNC : MS_ASYNC ) == -1)
632 0 2 if (EMPTY_MAP(info))
634 0 2 if (new_size == 0)
636 0 2 if ((info->flags & (MAP_ANONYMOUS|MAP_SHARED)) == (MAP_ANONYMOUS|MAP_SHARED))
638 0 2 if ((new_address = mremap(info->real_address, info->real_length, new_size + correction, MREMAP_MAYMOVE)) == MAP_FAILED)
655 0 0 if (EMPTY_MAP(info))
657 0 0 if (mlock(info->real_address, info->real_length) == -1)
668 0 0 if (EMPTY_MAP(info))
670 0 0 if (munlock(info->real_address, info->real_length) == -1)
684 3 0 if (EMPTY_MAP(info))
686 1 2 if (!value) {
687 1 0 if (ckWARN(WARN_PORTABLE))
688 1 0 Perl_warn(aTHX_ "Unknown advice '%s'", SvPV_nolen(name));
690 0 2 else if (madvise(info->real_address, info->real_length, SvUV(HeVAL(value))) == -1)
0 2 else if (madvise(info->real_address, info->real_length, SvUV(HeVAL(value))) == -1)
697 0 2 int prot_val = SvIOK(prot) ? SvIV(prot) : protection_sv(prot);
0 0 int prot_val = SvIOK(prot) ? SvIV(prot) : protection_sv(prot);
698 2 0 if (!EMPTY_MAP(info))
700 1 1 if (prot_val & PROT_WRITE)