Skip to content
Snippets Groups Projects
Commit f281ca9c authored by Niels Möller's avatar Niels Möller
Browse files

(read_file): Display a message if fopen fails.

Rev: src/nettle/examples/io.c:1.8
parent 7a7fd9b9
No related branches found
No related tags found
No related merge requests found
...@@ -30,6 +30,10 @@ ...@@ -30,6 +30,10 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdlib.h> #include <stdlib.h>
/* For errno and strerror */
#include <errno.h>
#include <string.h>
#include "io.h" #include "io.h"
#define RANDOM_DEVICE "/dev/urandom" #define RANDOM_DEVICE "/dev/urandom"
...@@ -74,8 +78,10 @@ read_file(const char *name, unsigned max_size, char **contents) ...@@ -74,8 +78,10 @@ read_file(const char *name, unsigned max_size, char **contents)
f = fopen(name, "rb"); f = fopen(name, "rb");
if (!f) if (!f)
return 0; {
werror("Opening `%s' falied: %s\n", name, strerror(errno));
return 0;
}
buffer = NULL; buffer = NULL;
if (max_size && max_size < 100) if (max_size && max_size < 100)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment