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 10:42:45 UTC
[trafficserver] branch master updated: Clang: fix ats_scoped_fd in
CacheTool.cc
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 603c9e7 Clang: fix ats_scoped_fd in CacheTool.cc
603c9e7 is described below
commit 603c9e70a4c652faf11f1280e4c8da4e602b5f3f
Author: Alan M. Carroll <am...@apache.org>
AuthorDate: Wed May 9 09:52:16 2018 -0500
Clang: fix ats_scoped_fd in CacheTool.cc
---
CMakeLists.txt | 1 +
cmd/traffic_cache_tool/CacheTool.cc | 2 +-
lib/ts/Makefile.am | 1 +
lib/ts/unit-tests/test_scoped_resource.cc | 50 +++++++++++++++++++++++++++++++
4 files changed, 53 insertions(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 590a202..5096bc5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1350,6 +1350,7 @@ add_executable(test_tslib
lib/ts/unit-tests/test_MT_hashtable.cc
lib/ts/unit-tests/test_Scalar.cc
lib/ts/unit-tests/test_string_view.cc
+ lib/ts/unit-tests/test_scoped_resource.cc
lib/ts/unit-tests/test_TextView.cc
)
diff --git a/cmd/traffic_cache_tool/CacheTool.cc b/cmd/traffic_cache_tool/CacheTool.cc
index 05c13dd..fc3562a 100644
--- a/cmd/traffic_cache_tool/CacheTool.cc
+++ b/cmd/traffic_cache_tool/CacheTool.cc
@@ -723,7 +723,7 @@ Span::loadDevice()
ats_scoped_fd fd{_path.open(flags)};
- if (fd != ts::NO_FD) {
+ if (fd.isValid()) {
if (ink_file_get_geometry(fd, _geometry)) {
off_t offset = ts::CacheSpan::OFFSET;
CacheStoreBlocks span_hdr_size(1); // default.
diff --git a/lib/ts/Makefile.am b/lib/ts/Makefile.am
index b0d7ea7..2cc746d 100644
--- a/lib/ts/Makefile.am
+++ b/lib/ts/Makefile.am
@@ -274,6 +274,7 @@ test_tslib_SOURCES = \
unit-tests/test_MT_hashtable.cc \
unit-tests/test_Scalar.cc \
unit-tests/test_string_view.cc \
+ unit-tests/test_scoped_resource.cc \
unit-tests/test_TextView.cc
CompileParseRules_SOURCES = CompileParseRules.cc
diff --git a/lib/ts/unit-tests/test_scoped_resource.cc b/lib/ts/unit-tests/test_scoped_resource.cc
new file mode 100644
index 0000000..4108236
--- /dev/null
+++ b/lib/ts/unit-tests/test_scoped_resource.cc
@@ -0,0 +1,50 @@
+/** @file
+
+ IpMap unit tests.
+
+ @section license License
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#include <ts/ink_memory.h>
+#include <catch.hpp>
+
+ats_scoped_fd
+fixed_fd()
+{
+ ats_scoped_fd zret{5};
+ return zret;
+}
+
+ats_scoped_fd
+direct_fixed_fd()
+{
+ return ats_scoped_fd{6};
+}
+
+TEST_CASE("scoped_resource", "[libts][scoped]")
+{
+ ats_scoped_fd no_fd;
+ REQUIRE(-1 == no_fd);
+ ats_scoped_fd fd1{fixed_fd()};
+ REQUIRE(fd1 == 5);
+ ats_scoped_fd fd2{direct_fixed_fd()};
+ REQUIRE(6 == fd2);
+ ats_scoped_fd fd3{ats_scoped_fd()};
+ REQUIRE(-1 == fd3);
+};
--
To stop receiving notification emails like this one, please contact
amc@apache.org.