freebsd-dev/sbin/ipf/libipf/kvatoname.c
Cy Schubert 44bc301921 ipfilter userland: Style(9) requires a space after return
Reported by:    jrtc27
Fixes:          2582ae5740
MFC after:      1 month
2022-01-03 19:37:25 -08:00

39 lines
660 B
C

/* $FreeBSD$ */
/*
* Copyright (C) 2012 by Darren Reed.
*
* See the IPFILTER.LICENCE file for details on licencing.
*
* $Id$
*/
#include "ipf.h"
#include <fcntl.h>
#include <sys/ioctl.h>
char *
kvatoname(ipfunc_t func, ioctlfunc_t iocfunc)
{
static char funcname[40];
ipfunc_resolve_t res;
int fd;
res.ipfu_addr = func;
res.ipfu_name[0] = '\0';
fd = -1;
if ((opts & OPT_DONTOPEN) == 0) {
fd = open(IPL_NAME, O_RDONLY);
if (fd == -1)
return (NULL);
}
(void) (*iocfunc)(fd, SIOCFUNCL, &res);
if (fd >= 0)
close(fd);
strncpy(funcname, res.ipfu_name, sizeof(funcname));
funcname[sizeof(funcname) - 1] = '\0';
return (funcname);
}