// License along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <assert.h>
+#include <errno.h>
#include <fcntl.h>
#include <stddef.h>
#include <stdio.h>
unsigned char *buf = NULL;
{
int fd = open(argv[1], O_RDONLY | O_CLOEXEC);
- assert(fd != -1);
+ if (fd == -1) {
+ fprintf(stderr, "%s\n", strerror(errno));
+ return EXIT_FAILURE;
+ }
struct stat sb;
memset(&sb, 0, sizeof(struct stat));
- assert(fstat(fd, &sb) == 0);
+ if (fstat(fd, &sb) != 0) {
+ fprintf(stderr, "%s\n", strerror(errno));
+ return EXIT_FAILURE;
+ }
len = (size_t)sb.st_size;
buf = mmap(NULL, len, PROT_READ, MAP_SHARED, fd, 0);
}