You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by GitBox <gi...@apache.org> on 2022/02/01 00:24:55 UTC

[GitHub] [trafficserver] SolidWallOfCode commented on a change in pull request #8636: In TsSharedMutex.h, make error reporting thread-safe.

SolidWallOfCode commented on a change in pull request #8636:
URL: https://github.com/apache/trafficserver/pull/8636#discussion_r796176341



##########
File path: include/tscpp/util/TsSharedMutex.h
##########
@@ -53,6 +54,36 @@
 
 namespace ts
 {
+class Strerror
+{
+public:
+  Strerror(int err_num)
+  {
+    _c_str = strerror_r(err_num, _buf, 256);
+    if (!_c_str) {
+      _c_str = "strerror_r() call failed";
+    } else {
+      _buf[255] = '\0';
+    }
+  }
+
+  char const *
+  c_str() const
+  {
+    return (_c_str);
+  }
+
+private:
+  char _buf[256];
+  char const *_c_str;
+};
+
+#if F
+#error "F preprocessor symbol defined"
+#endif
+
+#define F(FUNC_NAME, PTR, ERR_NUM) TSFatal("%s(%p) failed: %s (%d)", (FUNC_NAME), (PTR), Strerror(ERR_NUM).c_str(), (ERR_NUM));

Review comment:
       Why have a macro instead of an inline function?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org