Skip to content

Commit

Permalink
Fallback to strerror() when strerror_l() isn't available
Browse files Browse the repository at this point in the history
Some C libraries, such as uClibc, do not provide strerror_l() in
which case we fallback to strerror().

Reviewed-by: Tino Reichardt <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
  • Loading branch information
behlendorf committed Oct 11, 2024
1 parent c645b07 commit 85efa64
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config/user.m4
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ AC_DEFUN([ZFS_AC_CONFIG_USER], [
ZFS_AC_CONFIG_USER_MAKEDEV_IN_MKDEV
ZFS_AC_CONFIG_USER_ZFSEXEC
AC_CHECK_FUNCS([execvpe issetugid mlockall strlcat strlcpy gettid])
AC_CHECK_FUNCS([execvpe issetugid mlockall strerror_l strlcat strlcpy gettid])
AC_SUBST(RM)
])
4 changes: 4 additions & 0 deletions include/libzutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,11 @@ _LIBZUTIL_H void update_vdev_config_dev_sysfs_path(nvlist_t *nv,
* Thread-safe strerror() for use in ZFS libraries
*/
static inline char *zfs_strerror(int errnum) {
#ifdef HAVE_STRERROR_L
return (strerror_l(errnum, uselocale(0)));
#else
return (strerror(errnum));
#endif
}

#ifdef __cplusplus
Expand Down

0 comments on commit 85efa64

Please sign in to comment.