Skip to content

Commit a2622a0

Browse files
author
Tim Bradgate
committed
MB-27661 [n/n]: Fix MSVC warnings - C4273, C2491, C4244
C4273 - function : inconsistent DLL linkage. Two definitions in a file differ in their use of dllimport. C2491 - identifier : definition of dllimport function not allowed Introduce a new file to handle the API header imports/exports correctly on MSVC when using the same file for both libraries and executables. C4244 - conversion from 'type1' to 'type2', possible loss of data. An integer type is converted to a smaller integer type. This is the final commit in the fix all the MSVC compiler warnings sequence. We can now re-enable Windows build verfication compiler warnings to report on Gerrit patches. Change-Id: Ic1057b8d204d9b5328f2948cfffad7963e4d977c Reviewed-on: http://review.couchbase.org/90662 Reviewed-by: Dave Rigby <[email protected]> Tested-by: Build Bot <[email protected]>
1 parent ab71195 commit a2622a0

File tree

4 files changed

+44
-8
lines changed

4 files changed

+44
-8
lines changed

cbsasl/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ list(APPEND CBSASL_SOURCES
55
${Memcached_SOURCE_DIR}/cbsasl/client.cc
66
${Memcached_SOURCE_DIR}/cbsasl/common.cc
77
${Memcached_SOURCE_DIR}/cbsasl/log.cc
8+
${Memcached_SOURCE_DIR}/cbsasl/log_callback.cc
89
${Memcached_SOURCE_DIR}/cbsasl/mechanismfactory.cc
910
${Memcached_SOURCE_DIR}/cbsasl/mechanismfactory.h
1011
${Memcached_SOURCE_DIR}/cbsasl/plain/check_password.cc

cbsasl/log.cc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include <cbsasl/cbsasl.h>
1818
#include "cbsasl/cbsasl_internal.h"
1919

20-
#include <atomic>
2120
#include <iostream>
2221
#include <relaxed_atomic.h>
2322

@@ -27,12 +26,6 @@ namespace logging {
2726

2827
Couchbase::RelaxedAtomic<LogCallback> callback;
2928

30-
using LogCallback = void (*)(Level level, const std::string& message);
31-
32-
void set_log_callback(LogCallback logCallback) {
33-
callback.store(logCallback);
34-
}
35-
3629
void log(cbsasl_conn_t& connection, Level level, const std::string& message) {
3730
auto logger = callback.load();
3831
if (logger == nullptr) {

cbsasl/log_callback.cc

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2+
/*
3+
* Copyright 2018 Couchbase, Inc.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/*
19+
* Due to log.cc being used both in libraries and executables, the file was
20+
* not able to be compiled on Windows due to the usage of the API header
21+
* linkage. This file was created to allow for the correct API header to be
22+
* specified, and so that log.cc can be build into both libraries and
23+
* executables.
24+
*/
25+
#include <cbsasl/cbsasl.h>
26+
#include <relaxed_atomic.h>
27+
28+
namespace cb {
29+
namespace sasl {
30+
namespace logging {
31+
32+
extern Couchbase::RelaxedAtomic<LogCallback> callback;
33+
34+
CBSASL_PUBLIC_API
35+
void set_log_callback(LogCallback logCallback) {
36+
callback.store(logCallback);
37+
}
38+
} // namespace logging
39+
} // namespace sasl
40+
} // namespace cb

engines/ep/src/collections/collections_dockey.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
#include "collections/collections_dockey.h"
1919

20+
#include <gsl/gsl>
21+
2022
/**
2123
* Factory method to create a Collections::DocKey from a DocKey
2224
*/
@@ -27,7 +29,7 @@ Collections::DocKey Collections::DocKey::make(const ::DocKey& key) {
2729
}
2830
const uint8_t* collection = findCollection(key, SystemSeparator);
2931
if (collection) {
30-
return DocKey(key, collection - key.data(), 1);
32+
return DocKey(key, gsl::narrow<uint8_t>(collection - key.data()), 1);
3133
} else {
3234
// No collection found, not an error - ok for DefaultNamespace.
3335
return DocKey(key, 0, 0);

0 commit comments

Comments
 (0)