develooper Front page | perl.perl5.porters | Postings from November 2015

PerlIO-mmap: unused function PerlIOMmap_close()

Thread Next
From:
Dave Mitchell
Date:
November 24, 2015 12:22
Subject:
PerlIO-mmap: unused function PerlIOMmap_close()
Message ID:
20151124122150.GN2958@iabyn.com
Since v5.23.4-26-g0b057af, which made static, various functions that
weren't used outside their src files, blead has been warning:

mmap.xs:253:1: warning: ‘PerlIOMmap_close’ defined but not used [-Wunused-function]

This is because ext/PerlIO-mmap/mmap.xs defines a whole bunch of static
functions like PerlIOMmap_flush, PerlIOMmap_fill etc, then populates a big
vtable with them:

    static PERLIO_FUNCS_DECL(PerlIO_mmap) = {
        sizeof(PerlIO_funcs),
        "mmap",
        sizeof(PerlIOMmap),
        PERLIO_K_BUFFERED|PERLIO_K_RAW,
        PerlIOBuf_pushed,
        PerlIOBuf_popped,
        PerlIOBuf_open,
        PerlIOBase_binmode,         /* binmode */
        NULL,
        PerlIOBase_fileno,
        PerlIOMmap_dup,
        PerlIOBuf_read,
        PerlIOMmap_unread,
        PerlIOMmap_write,
        PerlIOBuf_seek,
        PerlIOBuf_tell,
        PerlIOBuf_close,
        PerlIOMmap_flush,
        PerlIOMmap_fill,
        PerlIOBase_eof,
        PerlIOBase_error,
        PerlIOBase_clearerr,
        PerlIOBase_setlinebuf,
        PerlIOMmap_get_base,
        PerlIOBuf_bufsiz,
        PerlIOBuf_get_ptr,
        PerlIOBuf_get_cnt,
        PerlIOBuf_set_ptrcnt,
    };

Note that some of the slots use the generic PerlIOBuf_* functions rather
than Mmap-specific ones. In the particular case of close, the vtable uses
PerlIOBuf_close, yet the src file still defines:

    static IV
    PerlIOMmap_close(pTHX_ PerlIO *f)
    {
        PerlIOMmap * const m = PerlIOSelf(f, PerlIOMmap);
        PerlIOBuf * const b = &m->base;
        IV code = PerlIO_flush(f);
        if (m->bbuf) {
            b->buf = m->bbuf;
            m->bbuf = NULL;
            b->ptr = b->end = b->buf;
        }
        if (PerlIOBuf_close(aTHX_ f) != 0)
            code = -1;
        return code;
    }

Is anyone familiar enough with this code to know whether
PerlIOMmap_close() can just be deleted, or whether it should populate the
close slot in the vtable?



-- 
print+qq&$}$"$/$s$,$a$d$g$s$@$.$q$,$:$.$q$^$,$@$a$~$;$.$q$m&if+map{m,^\d{0\,},,${$::{$'}}=chr($"+=$&||1)}q&10m22,42}6:17a2~2.3@3;^2dg3q/s"&=~m*\d\*.*g

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About