diff options
author | Joerg Jung <jung@cvs.openbsd.org> | 2020-02-17 19:45:01 +0000 |
---|---|---|
committer | Joerg Jung <jung@cvs.openbsd.org> | 2020-02-17 19:45:01 +0000 |
commit | 1735713db7739a79fb0f9f30c7235f2ceb2d69c2 (patch) | |
tree | 37542ecdee5d0c1920115cda53d553508f9e0d45 | |
parent | def095b3699aaaf11b4972ec7741a211157c8cba (diff) |
isc_stdio_open() wrapper function is only called in lex'er
so call fopen() directly and drop it
ok florian
-rw-r--r-- | usr.bin/dig/lib/dns/include/dns/tsig.h | 3 | ||||
-rw-r--r-- | usr.bin/dig/lib/isc/include/isc/stdio.h | 41 | ||||
-rw-r--r-- | usr.bin/dig/lib/isc/lex.c | 13 | ||||
-rw-r--r-- | usr.bin/dig/lib/isc/unix/Makefile.inc | 4 | ||||
-rw-r--r-- | usr.bin/dig/lib/isc/unix/stdio.c | 36 |
5 files changed, 10 insertions, 87 deletions
diff --git a/usr.bin/dig/lib/dns/include/dns/tsig.h b/usr.bin/dig/lib/dns/include/dns/tsig.h index cab831ad1d4..ddbb63482e6 100644 --- a/usr.bin/dig/lib/dns/include/dns/tsig.h +++ b/usr.bin/dig/lib/dns/include/dns/tsig.h @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: tsig.h,v 1.3 2020/02/16 21:12:41 florian Exp $ */ +/* $Id: tsig.h,v 1.4 2020/02/17 19:45:00 jung Exp $ */ #ifndef DNS_TSIG_H #define DNS_TSIG_H 1 @@ -22,7 +22,6 @@ /*! \file dns/tsig.h */ #include <isc/refcount.h> -#include <isc/stdio.h> #include <dns/types.h> #include <dns/name.h> diff --git a/usr.bin/dig/lib/isc/include/isc/stdio.h b/usr.bin/dig/lib/isc/include/isc/stdio.h deleted file mode 100644 index bbaffc37a96..00000000000 --- a/usr.bin/dig/lib/isc/include/isc/stdio.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE - * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -/* $Id: stdio.h,v 1.2 2020/02/13 13:53:01 jsg Exp $ */ - -#ifndef ISC_STDIO_H -#define ISC_STDIO_H 1 - -/*! \file isc/stdio.h */ - -/*% - * These functions are wrappers around the corresponding stdio functions. - * - * They return a detailed error code in the form of an an isc_result_t. ANSI C - * does not guarantee that stdio functions set errno, hence these functions - * must use platform dependent methods (e.g., the POSIX errno) to construct the - * error code. - */ - -#include <stdio.h> - -#include <isc/result.h> - -/*% Open */ -isc_result_t -isc_stdio_open(const char *filename, const char *mode, FILE **fp); - -#endif /* ISC_STDIO_H */ diff --git a/usr.bin/dig/lib/isc/lex.c b/usr.bin/dig/lib/isc/lex.c index 6e31e24553f..439eef3beac 100644 --- a/usr.bin/dig/lib/isc/lex.c +++ b/usr.bin/dig/lib/isc/lex.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: lex.c,v 1.3 2020/02/12 13:05:04 jsg Exp $ */ +/* $Id: lex.c,v 1.4 2020/02/17 19:45:00 jung Exp $ */ /*! \file */ @@ -29,10 +29,12 @@ #include <isc/parseint.h> -#include <isc/stdio.h> +#include <errno.h> #include <string.h> #include <isc/util.h> +#include "unix/errno2result.h" + typedef struct inputsource { isc_result_t result; isc_boolean_t is_file; @@ -201,7 +203,7 @@ new_source(isc_lex_t *lex, isc_boolean_t is_file, isc_boolean_t need_close, isc_result_t isc_lex_openfile(isc_lex_t *lex, const char *filename) { - isc_result_t result; + isc_result_t result = ISC_R_SUCCESS; FILE *stream = NULL; /* @@ -210,9 +212,8 @@ isc_lex_openfile(isc_lex_t *lex, const char *filename) { REQUIRE(VALID_LEX(lex)); - result = isc_stdio_open(filename, "r", &stream); - if (result != ISC_R_SUCCESS) - return (result); + if ((stream = fopen(filename, "r")) == NULL) + return (isc__errno2result(errno)); result = new_source(lex, ISC_TRUE, ISC_TRUE, stream, filename); if (result != ISC_R_SUCCESS) diff --git a/usr.bin/dig/lib/isc/unix/Makefile.inc b/usr.bin/dig/lib/isc/unix/Makefile.inc index 5536c87ac5c..4ef52df973a 100644 --- a/usr.bin/dig/lib/isc/unix/Makefile.inc +++ b/usr.bin/dig/lib/isc/unix/Makefile.inc @@ -1,5 +1,5 @@ -# $OpenBSD: Makefile.inc,v 1.4 2020/02/16 21:12:41 florian Exp $ +# $OpenBSD: Makefile.inc,v 1.5 2020/02/17 19:45:00 jung Exp $ .PATH: ${.CURDIR}/lib/isc/unix -SRCS+= app.c errno2result.c socket.c stdio.c net.c time.c +SRCS+= app.c errno2result.c socket.c net.c time.c diff --git a/usr.bin/dig/lib/isc/unix/stdio.c b/usr.bin/dig/lib/isc/unix/stdio.c deleted file mode 100644 index 18cb07cf5c9..00000000000 --- a/usr.bin/dig/lib/isc/unix/stdio.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE - * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -/* $Id: stdio.c,v 1.2 2020/02/11 23:26:12 jsg Exp $ */ - - - -#include <errno.h> - -#include <isc/stdio.h> - -#include "errno2result.h" - -isc_result_t -isc_stdio_open(const char *filename, const char *mode, FILE **fp) { - FILE *f; - - f = fopen(filename, mode); - if (f == NULL) - return (isc__errno2result(errno)); - *fp = f; - return (ISC_R_SUCCESS); -} |