freebsd-dev/sbin/ipf/libipf/ipf_perror.c
Cy Schubert 2582ae5740 ipfilter: Adjust userland returns to conform to style(9)
Adjust ipfilter's userland return statements to conform to style(9).

MFC after:	1 month
2022-01-03 18:06:43 -08:00

41 lines
650 B
C

#include <fcntl.h>
#include <sys/ioctl.h>
#include "ipf.h"
void
ipf_perror(int err, char *string)
{
if (err == 0)
fprintf(stderr, "%s\n", string);
else
fprintf(stderr, "%s: %s\n", string, ipf_strerror(err));
}
int
ipf_perror_fd( int fd, ioctlfunc_t iocfunc, char *string)
{
int save;
int realerr;
save = errno;
if ((*iocfunc)(fd, SIOCIPFINTERROR, &realerr) == -1)
realerr = 0;
errno = save;
fprintf(stderr, "%d:", realerr);
ipf_perror(realerr, string);
return(realerr ? realerr : save);
}
void
ipferror(int fd, char *msg)
{
if (fd >= 0) {
ipf_perror_fd(fd, ioctl, msg);
} else {
fprintf(stderr, "0:");
perror(msg);
}
}