diff options
-rw-r--r-- | lib/util.c | 20 | ||||
-rw-r--r-- | tests/ofproto-macros.at | 1 |
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/ ' } ] |