From f0c25fc20fe8a91d413e6ebfcb6d256de3c76be1 Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Mon, 17 Apr 2017 22:54:03 +0300 Subject: [PATCH] streamed_mutation: fix non-POD argument to C-style variadic function Clang warns that passing a non-POD to a C-style variadic function will result in an abort(). That happens to be exactly what we want, but to silence the warning, use a template instead. Since templates aren't allowed in local classes, move the containing class to namespace scope. --- streamed_mutation.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/streamed_mutation.cc b/streamed_mutation.cc index 7b7057aa2e..5a1bf99d41 100644 --- a/streamed_mutation.cc +++ b/streamed_mutation.cc @@ -88,14 +88,20 @@ void mutation_fragment::destroy_data() noexcept } } +namespace { + +struct get_key_visitor { + const clustering_key_prefix& operator()(const clustering_row& cr) { return cr.key(); } + const clustering_key_prefix& operator()(const range_tombstone& rt) { return rt.start; } + template + const clustering_key_prefix& operator()(const T&) { abort(); } +}; + +} + const clustering_key_prefix& mutation_fragment::key() const { assert(has_key()); - struct get_key_visitor { - const clustering_key_prefix& operator()(const clustering_row& cr) { return cr.key(); } - const clustering_key_prefix& operator()(const range_tombstone& rt) { return rt.start; } - const clustering_key_prefix& operator()(...) { abort(); } - }; return visit(get_key_visitor()); }