Skip to content

Commit

Permalink
Fixes to zfs_strerror()
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Kojedzinszky <[email protected]>
  • Loading branch information
rkojedzinszky committed Jan 3, 2025
1 parent cfb5106 commit cbfe177
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions include/libzutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,15 +276,14 @@ _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) {
static __thread char errbuf[2048];
static __thread pthread_mutex_t zfs_strerror_lock =
PTHREAD_MUTEX_INITIALIZER;
static __thread char errbuf[512];
static pthread_mutex_t zfs_strerror_lock = PTHREAD_MUTEX_INITIALIZER;

pthread_mutex_lock(&zfs_strerror_lock);
strlcpy(errbuf, strerror(errnum), sizeof(errbuf));
pthread_mutex_unlock(&zfs_strerror_lock);
(void) pthread_mutex_lock(&zfs_strerror_lock);
(void) strlcpy(errbuf, strerror(errnum), sizeof(errbuf));

Check failure on line 283 in include/libzutil.h

View workflow job for this annotation

GitHub Actions / checkstyle

missing space between keyword and paren
(void) pthread_mutex_unlock(&zfs_strerror_lock);

return errbuf;
return (errbuf);
}

#ifdef __cplusplus
Expand Down

0 comments on commit cbfe177

Please sign in to comment.