summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2013-01-28 09:53:51 -0800
committerBrian Behlendorf <[email protected]>2013-01-28 10:02:38 -0800
commit14ee71efbc28086406bb255f2292b9535d845625 (patch)
tree2ef4640510a1e4d2bb84c40d9cf8c3995b01068a /lib
parentddc07fa57a2e002822ae30f2e18c5427f4e3eb74 (diff)
Use strerror() not strerror_r()
The differ() function used strerror_r() instead of strerror() because it allowed the error message to be directly copied in to a buffer. This causes two issues under Linux. * There are two versions of strerror_r() available an XSI-compliant version which returns an 'int' error code. And a GNU-specific version which return a 'char *' to the resulting error string. int strerror_r(int errnum, char *buf, size_t buflen); /* XSI */ char *strerror_r(int errnum, char *buf, size_t buflen); /* GNU */ * The most recent versions of strerror_r() are annotated with the warn_unused_result attribute. This causes the following warning since the upstream implementation casts the result to void. warning: ignoring return value of 'strerror_r', declared with attribute warn_unused_result [-Wunused-result] The cleanest way to resolve both of these problems is just to use strerror() and make a copy of the result in to the buffer. This resolves both issues and this is the only instance of strerror_r() in the code base. Signed-off-by: Brian Behlendorf <[email protected]> Closes #1231
Diffstat (limited to 'lib')
-rw-r--r--lib/libzfs/libzfs_diff.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/libzfs/libzfs_diff.c b/lib/libzfs/libzfs_diff.c
index eb05f4d5b..77d5a09ec 100644
--- a/lib/libzfs/libzfs_diff.c
+++ b/lib/libzfs/libzfs_diff.c
@@ -430,7 +430,7 @@ differ(void *arg)
if ((ofp = fdopen(di->outputfd, "w")) == NULL) {
di->zerr = errno;
- (void) strerror_r(errno, di->errbuf, sizeof (di->errbuf));
+ strncpy(di->errbuf, strerror(errno), sizeof (di->errbuf));
(void) close(di->datafd);
return ((void *)-1);
}