summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Maste <emaste@adaranet.com>2012-07-27 17:27:15 -0400
committerBen Pfaff <blp@nicira.com>2012-07-27 14:32:36 -0700
commit69e6d7542abce62590ae99eb20f4775dc54fe8cc (patch)
tree0f3b392912885f4ae303553b82d09b83371f953e
parent78065c09bff56b1a29470afcd1d7835e85cf8f87 (diff)
downloadopenvswitch-69e6d7542abce62590ae99eb20f4775dc54fe8cc.tar.gz
Avoid implementation-defined strerror behaviour
POSIX states that the string returned by strerror() may be overwritten by a subsequent call (i.e., because it returns a pointer to a static buffer). Make a copy of one of the two strerror() strings to avoid this. Background: FreeBSD historically returned such a pointer only in the case of an invalid errno. With the addition of NLS strerror was changed to do so for all calls. Prior to this change I had confusing results from the test suite like "... is 22 (Invalid argument) but should be 0 (Invalid argument)". Signed-off-by: Ed Maste <emaste@adaranet.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
-rw-r--r--tests/test-vconn.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/tests/test-vconn.c b/tests/test-vconn.c
index 3398c4aa3..31451a27e 100644
--- a/tests/test-vconn.c
+++ b/tests/test-vconn.c
@@ -56,8 +56,9 @@ static void
check_errno(int a, int b, const char *as, const char *file, int line)
{
if (a != b) {
+ char *str_b = strdup(strerror(abs(b)));
ovs_fatal(0, "%s:%d: %s is %d (%s) but should be %d (%s)",
- file, line, as, a, strerror(abs(a)), b, strerror(abs(b)));
+ file, line, as, a, strerror(abs(a)), b, str_b);
}
}