Branch Coverage

lib/File/Map.xs
Criterion Covered Total %
branch 124 212 58.4


line true false branch
63 6 3 if (ckWARN(WARN_SUBSTR)) {
65 1 5 if (SvCUR(var) > info->fake_length)
69 8 1 if (string && len)
71 9 0 SV_CHECK_THINKFIRST_COW_DROP(var);
72 0 9 if (SvROK(var))
74 5 4 if (SvPOK(var))
75 5 0 SvPV_free(var);
0 5 SvPV_free(var);
0 0 SvPV_free(var);
0 0 SvPV_free(var);
82 25 1 if (info->real_length) {
83 1 24 if (!SvOK(var))
1 0 if (!SvOK(var))
1 0 if (!SvOK(var))
85 3 21 else if (!SvPOK(var)) {
87 0 3 const char* string = SvPV(var, len);
90 5 16 else if (SvPVX(var) != info->fake_address)
93 16 0 if (ckWARN(WARN_SUBSTR) && SvCUR(var) != info->fake_length) {
1 15 if (ckWARN(WARN_SUBSTR) && SvCUR(var) != info->fake_length) {
101 1 0 if (!SvPOK(var) || sv_len(var) != 0) {
1 0 if (!SvPOK(var) || sv_len(var) != 0) {
103 1 0 if (ckWARN(WARN_SUBSTR))
135 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)
173 0 1 return (Off_t)floor(SvNV(var) + 0.5); /* hic sunt dracones */
179 0 21 if (SvTYPE(var) > SVt_PVMG && SvTYPE(var) != SVt_PVLV)
181 2 19 SV_CHECK_THINKFIRST_COW_DROP(var);
182 0 20 if (SvREADONLY(var))
184 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))
186 0 20 if (SvROK(var))
188 0 20 if (SvNIOK(var))
190 0 20 if (SvPOK(var))
191 0 0 SvPV_free(var);
0 0 SvPV_free(var);
0 0 SvPV_free(var);
0 0 SvPV_free(var);
192 18 2 SvUPGRADE(var, SVt_PVMG);
198 0 17 if (address == MAP_FAILED)
232 1 18 SvTAINTED_on(var);
233 2 17 if (utf8 && !sv_utf8_decode(var))
0 2 if (utf8 && !sv_utf8_decode(var))
235 9 10 if (!writable)
241 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));
248 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)
273 24 0 for (i = 0; i < sizeof prots / sizeof *prots; ++i) {
274 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))
283 16 0 const char* mode = SvPV(mode_sv, mode_len);
285 1 15 return protection_pvn(mode, end ? end - mode : mode_len);
373 0 20 if (length > PTR_MAX - correction)
376 17 3 if (length)
379 1 2 if (!is_mappable(fd)) {
389 1 18 SvSETMAGIC(var);
406 9 0 for (i = 0; i < table_size; ++i) {
45 0 for (i = 0; i < table_size; ++i) {
407 8 1 if (strEQ(name, table[i].key))
30 15 if (strEQ(name, table[i].key))
416 15 1 if (PerlIO_fileno(fh) < 0)
418 30 15 for (current = fh; *current; current = PerlIONext(current)) {
419 30 0 if (!map_get(mappable, (*current)->tab->name, 0) || (*current)->flags & PERLIO_F_CRLF)
0 30 if (!map_get(mappable, (*current)->tab->name, 0) || (*current)->flags & PERLIO_F_CRLF)
429 14 1 size_t length = SvOK(length_sv) ? SvIV(length_sv) : info.st_size - offset;
14 0 size_t length = SvOK(length_sv) ? SvIV(length_sv) : info.st_size - offset;
0 14 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;
431 14 1 if (offset < 0 || end > info.st_size && !S_ISCHR(info.st_mode))
0 14 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))
449 8 0 const char* mode_raw = SvPV(mode, mode_len);
450 7 1 if (memchr(mode_raw, ':', mode_len) == NULL) {
453 7 0 mode_raw = SvPV(newmode, mode_len);
457 1 7 if (!do_openn(gv, mode_raw, mode_len, 0, 0, 0, NULL, &filename, 1))
458 1 0 Perl_croak(aTHX_ "Couldn't open file %s: %s", SvPV_nolen(filename), strerror(errno));
459 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);
470 0 8 if (flag == -1)
472 1 7 if (length == 0)
479 0 0 if (flags & MAP_ANONYMOUS)
492 0 1 if (EMPTY_MAP(info))
494 0 0 if (SvREADONLY(var) && ckWARN(WARN_IO))
0 0 if (SvREADONLY(var) && ckWARN(WARN_IO))
496 0 0 if (msync(info->real_address, info->real_length, sync ? MS_SYNC : MS_ASYNC ) == -1)
0 0 if (msync(info->real_address, info->real_length, sync ? MS_SYNC : MS_ASYNC ) == -1)
511 0 2 if (EMPTY_MAP(info))
513 0 2 if (new_size == 0)
515 0 2 if ((info->flags & (MAP_ANONYMOUS|MAP_SHARED)) == (MAP_ANONYMOUS|MAP_SHARED))
517 0 2 if ((new_address = mremap(info->real_address, info->real_length, new_size + correction, MREMAP_MAYMOVE)) == MAP_FAILED)
533 0 0 if (EMPTY_MAP(info))
535 0 0 if (mlock(info->real_address, info->real_length) == -1)
545 0 0 if (EMPTY_MAP(info))
547 0 0 if (munlock(info->real_address, info->real_length) == -1)
559 3 0 if (EMPTY_MAP(info))
561 1 2 if (!value) {
562 1 0 if (ckWARN(WARN_PORTABLE))
563 1 0 Perl_warn(aTHX_ "Unknown advice '%s'", SvPV_nolen(name));
565 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)
572 0 2 int prot_val = SvIOK(prot) ? SvIV(prot) : protection_sv(prot);
0 0 int prot_val = SvIOK(prot) ? SvIV(prot) : protection_sv(prot);
573 2 0 if (!EMPTY_MAP(info))
575 1 1 if (prot_val & PROT_WRITE)