Commit 913bc430 authored by Andreas Gustafsson's avatar Andreas Gustafsson
Browse files

use isc_file_fopen() and isc_file_fclose();

use the logging system, not UNEXPECTED_ERROR()
parent 84fcfe53
...@@ -779,23 +779,26 @@ isc_result_t ...@@ -779,23 +779,26 @@ isc_result_t
dns_master_dump(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version, dns_master_dump(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
const dns_master_style_t *style, const char *filename) const dns_master_style_t *style, const char *filename)
{ {
FILE *f; FILE *f = NULL;
isc_result_t result; isc_result_t result;
f = fopen(filename, "w"); result = isc_file_fopen(filename, "w", &f);
if (f == NULL) { if (result != ISC_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__, isc_log_write(dns_lctx, ISC_LOGCATEOGORY_GENERAL,
"could not open %s", DNS_LOGMODULE_MASTERDUMP, ISC_LOG_ERROR,
filename); "dumping master file: %s: open: %s", filename,
isc_result_totext(result));
return (ISC_R_UNEXPECTED); return (ISC_R_UNEXPECTED);
} }
result = dns_master_dumptostream(mctx, db, version, style, f); result = dns_master_dumptostream(mctx, db, version, style, f);
if (fclose(f) != 0) { result = isc_file_fclose(f);
UNEXPECTED_ERROR(__FILE__, __LINE__, if (result != ISC_R_SUCCESS) {
"error closing %s", isc_log_write(dns_lctx, ISC_LOGCATEOGORY_GENERAL,
filename); DNS_LOGMODULE_MASTERDUMP, ISC_LOG_ERROR,
"dumping master file: %s: close: %s", filename,
isc_result_totext(result));
return (ISC_R_UNEXPECTED); return (ISC_R_UNEXPECTED);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment