chunk: Externalize error reporting in chunk_write()

This avoids passing that arbitrary label just for error messages, and gives
greater flexibility in handling errors.
This commit is contained in:
Martin Willi
2014-01-23 15:55:32 +01:00
parent 37374a292a
commit b9ee059ca9
6 changed files with 52 additions and 30 deletions
+9 -1
View File
@@ -29,6 +29,7 @@
#include <getopt.h>
#include <ctype.h>
#include <time.h>
#include <errno.h>
#include <library.h>
#include <utils/debug.h>
@@ -515,11 +516,18 @@ int main(int argc, char **argv)
/* write the attribute certificate to file */
if (attr_cert->get_encoding(attr_cert, CERT_ASN1_DER, &attr_chunk))
{
if (chunk_write(attr_chunk, outfile, "attribute cert", 0022, TRUE))
if (chunk_write(attr_chunk, outfile, 0022, TRUE))
{
DBG1(DBG_APP, " written attribute cert file '%s' (%d bytes)",
outfile, attr_chunk.len);
write_serial(serial);
status = 0;
}
else
{
DBG1(DBG_APP, " writing attribute cert file '%s' failed: %s",
outfile, strerror(errno));
}
}
}
else