You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by am...@apache.org on 2018/05/10 12:38:37 UTC
[trafficserver] branch master updated: Clang: fix CacheTool null
parameter reference.
This is an automated email from the ASF dual-hosted git repository.
amc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 38080bd Clang: fix CacheTool null parameter reference.
38080bd is described below
commit 38080bdc6e24de7ba938a2a657f4930da460bd29
Author: Alan M. Carroll <am...@apache.org>
AuthorDate: Wed May 9 08:36:46 2018 -0500
Clang: fix CacheTool null parameter reference.
---
cmd/traffic_cache_tool/CacheDefs.h | 4 ----
cmd/traffic_cache_tool/CacheTool.cc | 2 +-
cmd/traffic_cache_tool/File.h | 6 ++++--
lib/ts/BufferWriter.h | 19 +++++++++++++++++--
lib/ts/HashMD5.cc | 3 ++-
lib/ts/ink_assert.h | 5 ++---
lib/ts/ink_hrtime.cc | 1 +
lib/ts/ink_platform.h | 3 +++
mgmt/api/NetworkMessage.cc | 1 +
tools/jtest/jtest.cc | 1 +
10 files changed, 32 insertions(+), 13 deletions(-)
diff --git a/cmd/traffic_cache_tool/CacheDefs.h b/cmd/traffic_cache_tool/CacheDefs.h
index e3af406..6944a27 100644
--- a/cmd/traffic_cache_tool/CacheDefs.h
+++ b/cmd/traffic_cache_tool/CacheDefs.h
@@ -36,10 +36,6 @@
#include "Command.h"
#include "File.h"
-#if defined(MAGIC)
-#undef MAGIC
-#endif
-
namespace tag
{
struct bytes {
diff --git a/cmd/traffic_cache_tool/CacheTool.cc b/cmd/traffic_cache_tool/CacheTool.cc
index fc3562a..cf70229 100644
--- a/cmd/traffic_cache_tool/CacheTool.cc
+++ b/cmd/traffic_cache_tool/CacheTool.cc
@@ -45,8 +45,8 @@
#include <thread>
#include "File.h"
-#include "CacheDefs.h"
#include "Command.h"
+#include "CacheDefs.h"
#include "CacheScan.h"
using ts::Bytes;
diff --git a/cmd/traffic_cache_tool/File.h b/cmd/traffic_cache_tool/File.h
index 20a77f7..4d3e717 100644
--- a/cmd/traffic_cache_tool/File.h
+++ b/cmd/traffic_cache_tool/File.h
@@ -23,9 +23,11 @@
#pragma once
-#include <ts/ink_memory.h>
+#include <sys/types.h>
#include <sys/stat.h>
-#include <ts/TextView.h>
+#include <fcntl.h>
+#include "ts/ink_memory.h"
+#include "ts/TextView.h"
namespace ts
{
diff --git a/lib/ts/BufferWriter.h b/lib/ts/BufferWriter.h
index f76885b..0a298d1 100644
--- a/lib/ts/BufferWriter.h
+++ b/lib/ts/BufferWriter.h
@@ -32,7 +32,6 @@
#include <ts/TextView.h>
#include <ts/MemSpan.h>
-#include <ts/ink_assert.h>
#include <ts/BufferWriterForward.h>
namespace ts
@@ -207,7 +206,12 @@ public:
can use it to measure the number of characters a series of writes would result it (from the
extent() value) without actually writing.
*/
- FixedBufferWriter(char *buffer, size_t capacity) : _buf(buffer), _capacity(capacity) {}
+ FixedBufferWriter(char *buffer, size_t capacity);
+
+ /** Construct empty buffer.
+ * This is useful for doing sizing before allocating a buffer.
+ */
+ FixedBufferWriter(std::nullptr_t);
FixedBufferWriter(const FixedBufferWriter &) = delete;
FixedBufferWriter &operator=(const FixedBufferWriter &) = delete;
@@ -233,6 +237,9 @@ public:
write(const void *data, size_t length) override
{
size_t newSize = _attempted + length;
+#if defined(__clang_analyzer__)
+ assert(_capacity == 0 || _buf != nullptr); // make clang-analyzer happy.
+#endif
if (newSize <= _capacity) {
std::memcpy(_buf + _attempted, data, length);
@@ -752,4 +759,12 @@ bwprint(std::string &s, ts::TextView fmt, Rest &&... rest)
}
}
+// -- FixedBufferWriter --
+inline FixedBufferWriter::FixedBufferWriter(char *buffer, size_t capacity) : _buf(buffer), _capacity(capacity)
+{
+ ink_assert(_capacity == 0 || buffer != nullptr);
+}
+
+inline FixedBufferWriter::FixedBufferWriter(std::nullptr_t) : _buf(nullptr), _capacity(0) {}
+
} // end namespace ts
diff --git a/lib/ts/HashMD5.cc b/lib/ts/HashMD5.cc
index 8c658f7..c8b0340 100644
--- a/lib/ts/HashMD5.cc
+++ b/lib/ts/HashMD5.cc
@@ -19,8 +19,9 @@
limitations under the License.
*/
-#include "ts/HashMD5.h"
#include "ts/ink_assert.h"
+#include "ts/ink_config.h"
+#include "ts/HashMD5.h"
ATSHashMD5::ATSHashMD5() : md_len(0), finalized(false)
{
diff --git a/lib/ts/ink_assert.h b/lib/ts/ink_assert.h
index bc4de37..21c0db5 100644
--- a/lib/ts/ink_assert.h
+++ b/lib/ts/ink_assert.h
@@ -28,7 +28,6 @@ Assertions
#pragma once
#include "ts/ink_apidefs.h"
-#include "ts/ink_error.h"
#ifdef __cplusplus
extern "C" {
@@ -45,12 +44,12 @@ extern "C" {
inkcoreapi void _ink_assert(const char *a, const char *f, int l) TS_NORETURN;
#if defined(DEBUG) || defined(__clang_analyzer__) || defined(__COVERITY__)
-#define ink_assert(EX) ((void)(likely(EX) ? (void)0 : _ink_assert(#EX, __FILE__, __LINE__)))
+#define ink_assert(EX) ((void)(__builtin_expect(!!(EX), 1) ? (void)0 : _ink_assert(#EX, __FILE__, __LINE__)))
#else
#define ink_assert(EX) (void)(EX)
#endif
-#define ink_release_assert(EX) ((void)(likely(EX) ? (void)0 : _ink_assert(#EX, __FILE__, __LINE__)))
+#define ink_release_assert(EX) ((void)(__builtin_expect(!!(EX), 0) ? (void)0 : _ink_assert(#EX, __FILE__, __LINE__)))
#ifdef __cplusplus
}
diff --git a/lib/ts/ink_hrtime.cc b/lib/ts/ink_hrtime.cc
index 15457c3..9d89b08 100644
--- a/lib/ts/ink_hrtime.cc
+++ b/lib/ts/ink_hrtime.cc
@@ -37,6 +37,7 @@
#include <sys/param.h>
#include <sys/sysctl.h>
#endif
+#include <string.h>
#include <sys/time.h>
char *
diff --git a/lib/ts/ink_platform.h b/lib/ts/ink_platform.h
index 023fce7..2c9a883 100644
--- a/lib/ts/ink_platform.h
+++ b/lib/ts/ink_platform.h
@@ -131,6 +131,9 @@ struct ifafilt;
#ifdef HAVE_CPIO_H
#include <cpio.h>
+#if defined(MAGIC)
+#undef MAGIC
+#endif
#endif
#ifdef HAVE_STROPTS_H
diff --git a/mgmt/api/NetworkMessage.cc b/mgmt/api/NetworkMessage.cc
index b786696..10f7b07 100644
--- a/mgmt/api/NetworkMessage.cc
+++ b/mgmt/api/NetworkMessage.cc
@@ -23,6 +23,7 @@
#include "ts/ink_config.h"
#include "ts/ink_defs.h"
+#include "ts/ink_error.h"
#include "ts/ink_assert.h"
#include "ts/ink_memory.h"
#include "mgmtapi.h"
diff --git a/tools/jtest/jtest.cc b/tools/jtest/jtest.cc
index d419bc0..26c8eaa 100644
--- a/tools/jtest/jtest.cc
+++ b/tools/jtest/jtest.cc
@@ -53,6 +53,7 @@
#include <stdlib.h>
#include "ts/ink_defs.h"
+#include "ts/ink_error.h"
#include "ts/ink_memory.h"
#include "ts/ink_assert.h"
#include "ts/INK_MD5.h"
--
To stop receiving notification emails like this one, please contact
amc@apache.org.