summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@broadpark.no>2019-02-06 14:09:57 +0100
committerTor Egge <Tor.Egge@broadpark.no>2019-02-06 14:09:57 +0100
commitd93960e181aa7010f4de80b5b3c5ac21c602ed41 (patch)
treef349126505986e84c0af787b7f69c3c4d396227d /vespalib
parent7e93d5dac4c722f1efa0e85e511a90084264a99f (diff)
Eliminate clang warning in vespalib
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/CMakeLists.txt1
-rw-r--r--vespalib/src/tests/alignedmemory/.cvsignore3
-rw-r--r--vespalib/src/tests/alignedmemory/.gitignore4
-rw-r--r--vespalib/src/tests/alignedmemory/CMakeLists.txt8
-rw-r--r--vespalib/src/tests/alignedmemory/DESC1
-rw-r--r--vespalib/src/tests/alignedmemory/FILES1
-rw-r--r--vespalib/src/tests/alignedmemory/alignedmemory_test.cpp68
-rw-r--r--vespalib/src/tests/net/send_fd/send_fd_test.cpp4
-rw-r--r--vespalib/src/tests/stllike/string_test.cpp19
-rw-r--r--vespalib/src/vespa/vespalib/data/slime/type.h8
-rw-r--r--vespalib/src/vespa/vespalib/stllike/asciistream.cpp4
-rw-r--r--vespalib/src/vespa/vespalib/trace/tracenode.h2
-rw-r--r--vespalib/src/vespa/vespalib/util/CMakeLists.txt1
-rw-r--r--vespalib/src/vespa/vespalib/util/alignedmemory.cpp29
-rw-r--r--vespalib/src/vespa/vespalib/util/alignedmemory.h70
15 files changed, 30 insertions, 193 deletions
diff --git a/vespalib/CMakeLists.txt b/vespalib/CMakeLists.txt
index 8306b55f73c..a395e3aab45 100644
--- a/vespalib/CMakeLists.txt
+++ b/vespalib/CMakeLists.txt
@@ -16,7 +16,6 @@ vespa_define_module(
src/apps/vespa-drop-file-from-cache
TESTS
- src/tests/alignedmemory
src/tests/alloc
src/tests/approx
src/tests/array
diff --git a/vespalib/src/tests/alignedmemory/.cvsignore b/vespalib/src/tests/alignedmemory/.cvsignore
deleted file mode 100644
index 0cc06a2789a..00000000000
--- a/vespalib/src/tests/alignedmemory/.cvsignore
+++ /dev/null
@@ -1,3 +0,0 @@
-.depend
-Makefile
-alignedmemory_test
diff --git a/vespalib/src/tests/alignedmemory/.gitignore b/vespalib/src/tests/alignedmemory/.gitignore
deleted file mode 100644
index 8777f6e4632..00000000000
--- a/vespalib/src/tests/alignedmemory/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-.depend
-Makefile
-alignedmemory_test
-vespalib_alignedmemory_test_app
diff --git a/vespalib/src/tests/alignedmemory/CMakeLists.txt b/vespalib/src/tests/alignedmemory/CMakeLists.txt
deleted file mode 100644
index 332e941f935..00000000000
--- a/vespalib/src/tests/alignedmemory/CMakeLists.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-vespa_add_executable(vespalib_alignedmemory_test_app TEST
- SOURCES
- alignedmemory_test.cpp
- DEPENDS
- vespalib
-)
-vespa_add_test(NAME vespalib_alignedmemory_test_app COMMAND vespalib_alignedmemory_test_app)
diff --git a/vespalib/src/tests/alignedmemory/DESC b/vespalib/src/tests/alignedmemory/DESC
deleted file mode 100644
index 4f3b4f32604..00000000000
--- a/vespalib/src/tests/alignedmemory/DESC
+++ /dev/null
@@ -1 +0,0 @@
-alignedmemory test. Take a look at alignedmemory.cpp for details.
diff --git a/vespalib/src/tests/alignedmemory/FILES b/vespalib/src/tests/alignedmemory/FILES
deleted file mode 100644
index d0363c78367..00000000000
--- a/vespalib/src/tests/alignedmemory/FILES
+++ /dev/null
@@ -1 +0,0 @@
-alignedmemory.cpp
diff --git a/vespalib/src/tests/alignedmemory/alignedmemory_test.cpp b/vespalib/src/tests/alignedmemory/alignedmemory_test.cpp
deleted file mode 100644
index d53e8f212c0..00000000000
--- a/vespalib/src/tests/alignedmemory/alignedmemory_test.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/log/log.h>
-LOG_SETUP("alignedmemory_test");
-#include <vespa/vespalib/testkit/testapp.h>
-#include <vespa/vespalib/util/alignedmemory.h>
-
-using namespace vespalib;
-
-TEST_SETUP(Test);
-
-int
-Test::Main()
-{
- TEST_INIT("alignedmemory_test");
- { // aligned alloc
- AlignedMemory mem8(32, 8);
- AlignedMemory mem16(32, 16);
- AlignedMemory mem512(32, 512);
- AlignedMemory mem7(32, 7);
-
- EXPECT_EQUAL(0u, ((uintptr_t)mem8.get()) % 8);
- EXPECT_EQUAL(0u, ((uintptr_t)mem16.get()) % 16);
- EXPECT_EQUAL(0u, ((uintptr_t)mem512.get()) % 512);
- EXPECT_EQUAL(0u, ((uintptr_t)mem7.get()) % 7);
- }
- { // swap
- AlignedMemory a(32, 8);
- AlignedMemory b(32, 8);
- char *pa = a.get();
- char *pb = b.get();
-
- EXPECT_EQUAL(pa, a.get());
- EXPECT_EQUAL(pb, b.get());
- a.swap(b);
- EXPECT_EQUAL(pb, a.get());
- EXPECT_EQUAL(pa, b.get());
- b.swap(a);
- EXPECT_EQUAL(pa, a.get());
- EXPECT_EQUAL(pb, b.get());
- }
- { // std::swap
- AlignedMemory a(32, 8);
- AlignedMemory b(32, 8);
- char *pa = a.get();
- char *pb = b.get();
-
- EXPECT_EQUAL(pa, a.get());
- EXPECT_EQUAL(pb, b.get());
- std::swap(a, b);
- EXPECT_EQUAL(pb, a.get());
- EXPECT_EQUAL(pa, b.get());
- std::swap(a, b);
- EXPECT_EQUAL(pa, a.get());
- EXPECT_EQUAL(pb, b.get());
- }
- { // construct with zero size
- AlignedMemory null(0, 0);
- char *expect = 0;
- EXPECT_EQUAL(expect, null.get());
- }
- { // const get()
- const AlignedMemory null(0, 0);
- const char *expect = 0;
- const char *got = null.get();
- EXPECT_EQUAL(expect, got);
- }
- TEST_DONE();
-}
diff --git a/vespalib/src/tests/net/send_fd/send_fd_test.cpp b/vespalib/src/tests/net/send_fd/send_fd_test.cpp
index ce7e7f20b30..e9921f75207 100644
--- a/vespalib/src/tests/net/send_fd/send_fd_test.cpp
+++ b/vespalib/src/tests/net/send_fd/send_fd_test.cpp
@@ -74,7 +74,7 @@ void send_fd(SocketHandle &socket, SocketHandle fd) {
hdr->cmsg_level = SOL_SOCKET;
hdr->cmsg_type = SCM_RIGHTS;
hdr->cmsg_len = CMSG_LEN(sizeof(int));
- int *fd_dst = (int *) CMSG_DATA(hdr);
+ int *fd_dst = (int *) (void *) CMSG_DATA(hdr);
fd_dst[0] = fd.get();
ssize_t res = sendmsg(socket.get(), &msg, 0);
ASSERT_EQUAL(res, 1);
@@ -97,7 +97,7 @@ SocketHandle recv_fd(SocketHandle &socket) {
bool type_ok = ((hdr->cmsg_level == SOL_SOCKET) &&
(hdr->cmsg_type == SCM_RIGHTS));
ASSERT_TRUE(type_ok);
- int *fd_src = (int *) CMSG_DATA(hdr);
+ int *fd_src = (int *) (void *) CMSG_DATA(hdr);
fprintf(stderr, "got fd: %d\n", fd_src[0]);
return SocketHandle(fd_src[0]);
}
diff --git a/vespalib/src/tests/stllike/string_test.cpp b/vespalib/src/tests/stllike/string_test.cpp
index 96c095667ee..885c13172b1 100644
--- a/vespalib/src/tests/stllike/string_test.cpp
+++ b/vespalib/src/tests/stllike/string_test.cpp
@@ -27,12 +27,27 @@ TEST("test iterator assignment") {
EXPECT_TRUE(strstr(s.c_str(), "mumbo jumbo.") == nullptr);
}
+namespace {
+
+template <typename S>
+void assign(S &lhs, const S &rhs) __attribute__((noinline));
+
+template <typename S>
+void
+assign(S &lhs, const S &rhs)
+{
+ lhs = rhs;
+}
+
+}
+
+
TEST("test self assignment of small string") {
const char * text = "abc";
string s(text);
const char * addr(reinterpret_cast<const char *>(&s));
EXPECT_TRUE((addr < s.c_str()) && (s.c_str() < addr + sizeof(s)));
- s = s;
+ assign(s, s);
EXPECT_EQUAL(text, s);
}
@@ -41,7 +56,7 @@ TEST("test self assignment of big string") {
string s(text);
const char * addr(reinterpret_cast<const char *>(&s));
EXPECT_TRUE((addr > s.c_str()) || (s.c_str() > addr + sizeof(s)));
- s = s;
+ assign(s, s);
EXPECT_EQUAL(text, s);
}
diff --git a/vespalib/src/vespa/vespalib/data/slime/type.h b/vespalib/src/vespa/vespalib/data/slime/type.h
index 1f4ac1a5ff9..e9699fe5a70 100644
--- a/vespalib/src/vespa/vespalib/data/slime/type.h
+++ b/vespalib/src/vespa/vespalib/data/slime/type.h
@@ -40,6 +40,14 @@ typedef TypeType<4> STRING;
typedef TypeType<5> DATA;
typedef TypeType<6> ARRAY;
typedef TypeType<7> OBJECT;
+extern template struct TypeType<NIX::ID>;
+extern template struct TypeType<BOOL::ID>;
+extern template struct TypeType<LONG::ID>;
+extern template struct TypeType<DOUBLE::ID>;
+extern template struct TypeType<STRING::ID>;
+extern template struct TypeType<DATA::ID>;
+extern template struct TypeType<ARRAY::ID>;
+extern template struct TypeType<OBJECT::ID>;
} // namespace vespalib::slime
} // namespace vespalib
diff --git a/vespalib/src/vespa/vespalib/stllike/asciistream.cpp b/vespalib/src/vespa/vespalib/stllike/asciistream.cpp
index 35f7b0e1be7..78c8f9a9bda 100644
--- a/vespalib/src/vespa/vespalib/stllike/asciistream.cpp
+++ b/vespalib/src/vespa/vespalib/stllike/asciistream.cpp
@@ -477,7 +477,7 @@ asciistream& asciistream::operator<<(const void* p)
asciistream & asciistream::operator << (float v)
{
- if ((_floatSpec == fixed)) {
+ if (_floatSpec == fixed) {
printFixed(v);
} else {
printScientific(v);
@@ -487,7 +487,7 @@ asciistream & asciistream::operator << (float v)
asciistream & asciistream::operator << (double v)
{
- if ((_floatSpec == fixed)) {
+ if (_floatSpec == fixed) {
printFixed(v);
} else {
printScientific(v);
diff --git a/vespalib/src/vespa/vespalib/trace/tracenode.h b/vespalib/src/vespa/vespalib/trace/tracenode.h
index 732a4f8bf7a..b44881b99b4 100644
--- a/vespalib/src/vespa/vespalib/trace/tracenode.h
+++ b/vespalib/src/vespa/vespalib/trace/tracenode.h
@@ -50,7 +50,7 @@ public:
TraceNode & operator =(const TraceNode &);
TraceNode(TraceNode &&) noexcept;
- TraceNode & operator =(TraceNode &&) noexcept = default;
+ TraceNode & operator =(TraceNode &&) = default;
~TraceNode();
/**
diff --git a/vespalib/src/vespa/vespalib/util/CMakeLists.txt b/vespalib/src/vespa/vespalib/util/CMakeLists.txt
index fdf7524c82f..2f64e01d79c 100644
--- a/vespalib/src/vespa/vespalib/util/CMakeLists.txt
+++ b/vespalib/src/vespa/vespalib/util/CMakeLists.txt
@@ -2,7 +2,6 @@
vespa_add_library(vespalib_vespalib_util OBJECT
SOURCES
active.cpp
- alignedmemory.cpp
alloc.cpp
approx.cpp
array.cpp
diff --git a/vespalib/src/vespa/vespalib/util/alignedmemory.cpp b/vespalib/src/vespa/vespalib/util/alignedmemory.cpp
deleted file mode 100644
index dcc95ddd0ef..00000000000
--- a/vespalib/src/vespa/vespalib/util/alignedmemory.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-
-#include "alignedmemory.h"
-#include <stdint.h>
-
-namespace vespalib {
-
-AlignedMemory::AlignedMemory(size_t size, size_t align)
- : _alloc(size == 0 ? 0 : new char[size + ((align > 1) ? (align - 1) : 0)]),
- _align(_alloc)
-{
- if (align > 1) {
- _align += (align - (((uintptr_t)_alloc) % align)) % align;
- }
-}
-
-void
-AlignedMemory::swap(AlignedMemory &rhs)
-{
- std::swap(_alloc, rhs._alloc);
- std::swap(_align, rhs._align);
-}
-
-AlignedMemory::~AlignedMemory()
-{
- delete[] _alloc;
-}
-
-} // namespace search
diff --git a/vespalib/src/vespa/vespalib/util/alignedmemory.h b/vespalib/src/vespa/vespalib/util/alignedmemory.h
deleted file mode 100644
index e99417547c1..00000000000
--- a/vespalib/src/vespa/vespalib/util/alignedmemory.h
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-
-#pragma once
-
-#include <algorithm>
-
-namespace vespalib {
-
-/**
- * Simple utility class used to allocate and own an aligned chunk of
- * memory. The owned memory will be allocated with 'malloc' and will
- * be freed using 'free' on the same pointer as was returned from
- * 'malloc'.
- **/
-class AlignedMemory
-{
-private:
- char *_alloc;
- char *_align;
-
- AlignedMemory(const AlignedMemory &rhs);
- AlignedMemory &operator=(const AlignedMemory &rhs);
-public:
- /**
- * Allocate a chunk of memory with the specified size and
- * alignment. Specifying a zero size will make the object
- * contain a null pointer.
- *
- * @param size amount of memory to allocate
- * @param align wanted memory alignment
- **/
- AlignedMemory(size_t size, size_t align);
-
- /**
- * Get pointer to the aligned memory chunk owned by this object.
- * @return aligned memory chunk
- **/
- char *get() { return _align; }
-
- /**
- * Get pointer to the aligned memory chunk owned by this object.
- * @return aligned memory chunk
- **/
- const char *get() const { return _align; }
-
- /**
- * Swap the memory owned by this object with the memory owned by
- * another object.
- *
- * @param rhs the other object to swap with
- **/
- void swap(AlignedMemory &rhs);
-
- /**
- * Free the memory owned by this object.
- **/
- ~AlignedMemory();
-};
-
-} // namespace vespalib
-
-namespace std {
-
-template <>
-inline void swap<vespalib::AlignedMemory>(vespalib::AlignedMemory &a, vespalib::AlignedMemory &b) {
- a.swap(b);
-}
-
-} // namespace std
-