Is it acceptable style to copy a whole function over to one other file?

I'm looking at the files in src/usr.bin/ssh/ and would like to re-use
fmt_connection() in serverloop.c.  It is used only in packet.c so far.
Duplicating it in serverloop.c would mean that it then exists in two
files.

style(9) says:

        "Functions that are used locally in more than one module
        go into a separate header file, e.g., extern.h."

Checking the other files in that directory for repeated function
prototypes, I see that it looks like over 30 items are defined in
exactly two different files.  For example, both scp.c and sftp.c
contain variants of

static
void suspchild(int signo)

but both

void
ssh_sandbox_parent_preauth(struct ssh_sandbox *box, pid_t child_pid)

and

void
ssh_sandbox_parent_finish(struct ssh_sandbox *box)

are duplicated verbatim in both sandbox-pledge.c and sandbox-rlimit.c

So is two the limit?

/Lars

Reply via email to