summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYAMAMOTO Takashi <yamamoto@midokura.com>2016-03-16 07:19:35 +0000
committerYAMAMOTO Takashi <yamamoto@midokura.com>2016-03-24 01:09:53 +0900
commit11b7f938280797676d2163c765916c8c904251db (patch)
treeda0a9656d425945def092d31e8e3988cd2174bd3
parent1de0ef4147f52c5d715e380d1f394c7e1302e38f (diff)
downloadopenvswitch-11b7f938280797676d2163c765916c8c904251db.tar.gz
ovs_strerror, ovs_format_message: Always use "Success" for errno 0
So that testsuite can compare log messages including the string. Signed-off-by: YAMAMOTO Takashi <yamamoto@midokura.com> Acked-by: Ben Pfaff <blp@ovn.org>
-rw-r--r--lib/util.c20
-rw-r--r--tests/ofproto-macros.at1
2 files changed, 20 insertions, 1 deletions
diff --git a/lib/util.c b/lib/util.c
index e3519f2bd..bdc78f5fb 100644
--- a/lib/util.c
+++ b/lib/util.c
@@ -413,6 +413,21 @@ ovs_strerror(int error)
char *buffer;
char *s;
+ if (error == 0) {
+ /*
+ * strerror(0) varies among platforms:
+ *
+ * Success
+ * No error
+ * Undefined error: 0
+ *
+ * We want to provide a consistent result here because
+ * our testsuite has test cases which strictly matches
+ * log messages containing this string.
+ */
+ return "Success";
+ }
+
save_errno = errno;
buffer = strerror_buffer_get()->s;
@@ -2060,6 +2075,11 @@ ovs_format_message(int error)
enum { BUFSIZE = sizeof strerror_buffer_get()->s };
char *buffer = strerror_buffer_get()->s;
+ if (error == 0) {
+ /* See ovs_strerror */
+ return "Success";
+ }
+
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, error, 0, buffer, BUFSIZE, NULL);
return buffer;
diff --git a/tests/ofproto-macros.at b/tests/ofproto-macros.at
index 522d71350..2c52ecae9 100644
--- a/tests/ofproto-macros.at
+++ b/tests/ofproto-macros.at
@@ -30,7 +30,6 @@ prt==1 { sub(/[ \t]*$/, ""); print $0 }
vconn_sub() {
sed '
s/tcp:127.0.0.1:[0-9][0-9]*:/unix:/
-s/No error/Success/
'
}
]