- added typemap type names to types in Imager::API.
- make skip when Inline::C not available less verbose
- convert t/t07iolayer.t to Test::More
+- handle the possibility of strerror() returning NULL.
=================================================================
static off_t fd_seek(io_glue *ig, off_t offset, int whence);
static void fd_close(io_glue *ig);
static ssize_t fd_size(io_glue *ig);
+static const char *my_strerror(int err);
/*
* Callbacks for sources that cannot seek
/* 0 is valid - means EOF */
if (result < 0) {
- i_push_errorf(0, "read() failure: %s (%d)", strerror(errno), errno);
+ i_push_errorf(0, "read() failure: %s (%d)", my_strerror(errno), errno);
}
return result;
#endif
if (result <= 0) {
- i_push_errorf(errno, "write() failure: %s (%d)", strerror(errno), errno);
+ i_push_errorf(errno, "write() failure: %s (%d)", my_strerror(errno), errno);
}
return result;
#endif
if (result == (off_t)-1) {
- i_push_errorf(errno, "lseek() failure: %s (%d)", strerror(errno), errno);
+ i_push_errorf(errno, "lseek() failure: %s (%d)", my_strerror(errno), errno);
}
return result;
myfree(ig);
}
+/*
+=back
+
+=head1 INTERNAL FUNCTIONS
+
+=over
+
+=item my_strerror
+
+Calls strerror() and ensures we don't return NULL.
+
+On some platforms it's possible for strerror() to return NULL, this
+wrapper ensures we only get non-NULL values.
+
+=cut
+*/
+
+static
+const char *my_strerror(int err) {
+ const char *result = strerror(err);
+
+ if (!result)
+ result = "Unknown error";
+
+ return result;
+}
/*
=back