From 7c60c990fbed62aab1369c0e4462c4081dc3cfeb Mon Sep 17 00:00:00 2001 From: Michalis Spyrou Date: Thu, 10 Oct 2019 14:33:47 +0100 Subject: COMPMID-2486: Remove disabled compiler warnings Removed the following flags: -Wno-format-nonliteral: This had a side effect on Error.h that resulted in rewriting most of the macros. Since I was at it I removed all the va_args in order to comply with DCL50-CPP. -Wno-deprecated-increment-bool -Wno-vla-extension -Wno-mismatched-tags -Wno-redundant-move Change-Id: I7c593854ecc3b7d595b8edcbd6a86d3c2563c6bd Signed-off-by: Michalis Spyrou Reviewed-on: https://review.mlplatform.org/c/2069 Comments-Addressed: Arm Jenkins Tested-by: Arm Jenkins Reviewed-by: Georgios Pinitas --- arm_compute/core/CL/ICLKernel.h | 4 +- arm_compute/core/Error.h | 253 ++++++++++++++++++++++++-------- arm_compute/core/ITensorInfo.h | 2 +- arm_compute/core/Log.h | 12 +- arm_compute/core/Steps.h | 4 +- arm_compute/core/Strides.h | 4 +- arm_compute/core/SubTensorInfo.h | 2 +- arm_compute/core/TensorInfo.h | 2 +- arm_compute/core/TensorShape.h | 4 +- arm_compute/core/Validate.h | 6 +- arm_compute/core/Window.inl | 2 +- arm_compute/core/utils/logging/Macros.h | 21 +-- 12 files changed, 224 insertions(+), 92 deletions(-) (limited to 'arm_compute') diff --git a/arm_compute/core/CL/ICLKernel.h b/arm_compute/core/CL/ICLKernel.h index 76b40b81d1..ba368edf91 100644 --- a/arm_compute/core/CL/ICLKernel.h +++ b/arm_compute/core/CL/ICLKernel.h @@ -379,8 +379,8 @@ void ICLKernel::add_array_argument(unsigned &idx, const ICLArray *array, cons _kernel.setArg(idx++, offset_first_element); - ARM_COMPUTE_ERROR_ON_MSG(idx_start + num_arguments_per_array() != idx, - "add_%dD_array_argument() is supposed to add exactly %d arguments to the kernel", dimension_size, num_arguments_per_array()); + ARM_COMPUTE_ERROR_ON_MSG_VAR(idx_start + num_arguments_per_array() != idx, + "add_%dD_array_argument() is supposed to add exactly %d arguments to the kernel", dimension_size, num_arguments_per_array()); ARM_COMPUTE_UNUSED(idx_start); } } diff --git a/arm_compute/core/Error.h b/arm_compute/core/Error.h index 64bfbd2787..dcbba1e990 100644 --- a/arm_compute/core/Error.h +++ b/arm_compute/core/Error.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2018 ARM Limited. + * Copyright (c) 2016-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -24,7 +24,7 @@ #ifndef __ARM_COMPUTE_ERROR_H__ #define __ARM_COMPUTE_ERROR_H__ -#include +#include #include namespace arm_compute @@ -116,39 +116,31 @@ private: std::string _error_description; }; -/** Creates an error containing the error message from variable argument list +/** Creates an error containing the error message * * @param[in] error_code Error code - * @param[in] function Function in which the error occurred. - * @param[in] file Name of the file where the error occurred. - * @param[in] line Line on which the error occurred. * @param[in] msg Message to display before aborting. - * @param[in] args Variable argument list of the message. * * @return status containing the error */ -Status create_error_va_list(ErrorCode error_code, const char *function, const char *file, const int line, const char *msg, va_list args); -/** Creates an error containing the error message +Status create_error(ErrorCode error_code, std::string msg); + +/** Creates an error and the error message * * @param[in] error_code Error code - * @param[in] function Function in which the error occurred. - * @param[in] file Name of the file where the error occurred. - * @param[in] line Line on which the error occurred. + * @param[in] func Function in which the error occurred. + * @param[in] file File in which the error occurred. + * @param[in] line Line in which the error occurred. * @param[in] msg Message to display before aborting. - * @param[in] ... Variable number of arguments of the message. * * @return status containing the error */ -Status create_error(ErrorCode error_code, const char *function, const char *file, const int line, const char *msg, ...); -/** Print an error message then throw an std::runtime_error +Status create_error_msg(ErrorCode error_code, const char *func, const char *file, int line, const char *msg); +/** Throw an std::runtime_error * - * @param[in] function Function in which the error occurred. - * @param[in] file Name of the file where the error occurred. - * @param[in] line Line on which the error occurred. - * @param[in] msg Message to display before aborting. - * @param[in] ... Variable number of arguments of the message. + * @param[in] err Error status */ -[[noreturn]] void error(const char *function, const char *file, const int line, const char *msg, ...); +[[noreturn]] void throw_error(Status err); } /** To avoid unused variables warnings * @@ -162,9 +154,9 @@ Status create_error(ErrorCode error_code, const char *function, const char *file /** Creates an error with a given message * * @param[in] error_code Error code. - * @param[in] ... Message to encapsulate. + * @param[in] msg Message to encapsulate. */ -#define ARM_COMPUTE_CREATE_ERROR(error_code, ...) ::arm_compute::create_error(error_code, __func__, __FILE__, __LINE__, __VA_ARGS__) // NOLINT +#define ARM_COMPUTE_CREATE_ERROR(error_code, msg) arm_compute::create_error_msg(error_code, __func__, __FILE__, __LINE__, msg) /** Creates an error on location with a given message * @@ -172,9 +164,28 @@ Status create_error(ErrorCode error_code, const char *function, const char *file * @param[in] func Function in which the error occurred. * @param[in] file File in which the error occurred. * @param[in] line Line in which the error occurred. - * @param[in] ... Message to display before aborting. + * @param[in] msg Message to display before aborting. + */ +#define ARM_COMPUTE_CREATE_ERROR_LOC(error_code, func, file, line, msg) arm_compute::create_error_msg(error_code, func, file, line, msg) + +/** Creates an error on location with a given message. Accepts a message format + * and a variable list of arguments matching the format description. + * + * @param[in] error_code Error code. + * @param[in] func Function in which the error occurred. + * @param[in] file File in which the error occurred. + * @param[in] line Line in which the error occurred. + * @param[in] msg Error description message format. + * @param[in] ... List of arguments matching the format description. */ -#define ARM_COMPUTE_CREATE_ERROR_LOC(error_code, func, file, line, ...) ::arm_compute::create_error(error_code, func, file, line, __VA_ARGS__) // NOLINT +#define ARM_COMPUTE_CREATE_ERROR_LOC_VAR(error_code, func, file, line, msg, ...) \ + do \ + { \ + std::array out{ 0 }; \ + int offset = snprintf(out.data(), out.size(), "in %s %s:%d: ", func, file, line); \ + snprintf(out.data() + offset, out.size() - offset, msg, __VA_ARGS__); \ + arm_compute::create_error(error_code, std::string(out.data())); \ + } while(false) /** An error is returned with the given description. * @@ -206,35 +217,76 @@ Status create_error(ErrorCode error_code, const char *function, const char *file #define ARM_COMPUTE_THROW_ON_ERROR(error) \ error.throw_if_error(); +/** If the condition is true, an error is returned. Accepts a message format + * and a variable list of arguments matching the format description. + * + * @param[in] cond Condition to evaluate. + * @param[in] msg Error description message format. + * @param[in] ... List of arguments matching the format description. + */ +#define ARM_COMPUTE_RETURN_ERROR_ON_MSG_VAR(cond, msg, ...) \ + do \ + { \ + if(cond) \ + { \ + std::array out{ 0 }; \ + int offset = snprintf(out.data(), out.size(), "in %s %s:%d: ", __func__, __FILE__, __LINE__); \ + snprintf(out.data() + offset, out.size() - offset, msg, __VA_ARGS__); \ + return arm_compute::create_error(arm_compute::ErrorCode::RUNTIME_ERROR, std::string(out.data())); \ + } \ + } while(false) + /** If the condition is true, an error is returned * * @param[in] cond Condition to evaluate. - * @param[in] ... Error description message + * @param[in] msg Error description message + */ +#define ARM_COMPUTE_RETURN_ERROR_ON_MSG(cond, msg) \ + do \ + { \ + if(cond) \ + { \ + return arm_compute::create_error_msg(arm_compute::ErrorCode::RUNTIME_ERROR, __func__, __FILE__, __LINE__, msg); \ + } \ + } while(false) + +/** If the condition is true, an error is thrown. Accepts a message format + * and a variable list of arguments matching the format description. + * + * @param[in] cond Condition to evaluate. + * @param[in] func Function in which the error occurred. + * @param[in] file File in which the error occurred. + * @param[in] line Line in which the error occurred. + * @param[in] msg Error description message format. + * @param[in] ... List of arguments matching the format description. */ -#define ARM_COMPUTE_RETURN_ERROR_ON_MSG(cond, ...) \ +#define ARM_COMPUTE_RETURN_ERROR_ON_LOC_MSG_VAR(cond, func, file, line, msg, ...) \ do \ { \ if(cond) \ { \ - return ARM_COMPUTE_CREATE_ERROR(arm_compute::ErrorCode::RUNTIME_ERROR, __VA_ARGS__); \ + std::array out{ 0 }; \ + int offset = snprintf(out.data(), out.size(), "in %s %s:%d: ", func, file, line); \ + snprintf(out.data() + offset, out.size() - offset, msg, __VA_ARGS__); \ + return arm_compute::create_error(ErrorCode::RUNTIME_ERROR, std::string(out.data())); \ } \ } while(false) -/** If the condition is true, an error is thrown +/** If the condition is true, an error is thrown. * * @param[in] cond Condition to evaluate. * @param[in] func Function in which the error occurred. * @param[in] file File in which the error occurred. * @param[in] line Line in which the error occurred. - * @param[in] ... Error description message. + * @param[in] msg Message to display. */ -#define ARM_COMPUTE_RETURN_ERROR_ON_LOC_MSG(cond, func, file, line, ...) \ - do \ - { \ - if(cond) \ - { \ - return ARM_COMPUTE_CREATE_ERROR_LOC(arm_compute::ErrorCode::RUNTIME_ERROR, func, file, line, __VA_ARGS__); \ - } \ +#define ARM_COMPUTE_RETURN_ERROR_ON_LOC_MSG(cond, func, file, line, msg) \ + do \ + { \ + if(cond) \ + { \ + return arm_compute::create_error_msg(ErrorCode::RUNTIME_ERROR, func, file, line, msg); \ + } \ } while(false) /** If the condition is true, an error is returned @@ -256,31 +308,97 @@ Status create_error(ErrorCode error_code, const char *function, const char *file /** Print the given message then throw an std::runtime_error. * - * @param[in] ... Message to display before aborting. + * @param[in] func Function in which the error occurred. + * @param[in] file File in which the error occurred. + * @param[in] line Line in which the error occurred. + * @param[in] msg Message to display. + */ +#define ARM_COMPUTE_THROW_ERROR(func, file, line, msg) \ + do \ + { \ + arm_compute::throw_error(arm_compute::create_error_msg(arm_compute::ErrorCode::RUNTIME_ERROR, func, file, line, msg)); \ + } while(false) + +/** Print the given message then throw an std::runtime_error. Accepts a message format + * and a variable list of arguments matching the format description. + * + * @param[in] func Function in which the error occurred. + * @param[in] file File in which the error occurred. + * @param[in] line Line in which the error occurred. + * @param[in] msg Error description message format. + * @param[in] ... List of arguments matching the format description. + */ +#define ARM_COMPUTE_THROW_ERROR_VAR(func, file, line, msg, ...) \ + do \ + { \ + std::array out{ 0 }; \ + int offset = snprintf(out.data(), out.size(), "in %s %s:%d: ", func, file, line); \ + snprintf(out.data() + offset, out.size() - offset, msg, __VA_ARGS__); \ + arm_compute::throw_error(arm_compute::Status(arm_compute::ErrorCode::RUNTIME_ERROR, std::string(out.data()))); \ + } while(false) + +/** Print the given message then throw an std::runtime_error. Accepts a message format + * and a variable list of arguments matching the format description. + * + * @param[in] msg Error description message format. + * @param[in] ... List of arguments matching the format description. + */ +#define ARM_COMPUTE_ERROR_VAR(msg, ...) ARM_COMPUTE_THROW_ERROR_VAR(__func__, __FILE__, __LINE__, msg, __VA_ARGS__) + +/** Print the given message then throw an std::runtime_error. + * + * @param[in] msg Message to display. + */ +#define ARM_COMPUTE_ERROR(msg) ARM_COMPUTE_THROW_ERROR(__func__, __FILE__, __LINE__, msg) + +/** Print the given message then throw an std::runtime_error. Accepts a message format + * and a variable list of arguments matching the format description. + * + * @param[in] func Function in which the error occurred. + * @param[in] file File in which the error occurred. + * @param[in] line Line in which the error occurred. + * @param[in] msg Error description message format. + * @param[in] ... List of arguments matching the format description. */ -#define ARM_COMPUTE_ERROR(...) ::arm_compute::error(__func__, __FILE__, __LINE__, __VA_ARGS__) // NOLINT +#define ARM_COMPUTE_ERROR_LOC_VAR(func, file, line, msg, ...) ARM_COMPUTE_THROW_ERROR_VAR(func, file, line, msg, __VA_ARGS__) // NOLINT /** Print the given message then throw an std::runtime_error. * * @param[in] func Function in which the error occurred. * @param[in] file File in which the error occurred. * @param[in] line Line in which the error occurred. - * @param[in] ... Message to display before aborting. + * @param[in] msg Message to display. */ -#define ARM_COMPUTE_ERROR_LOC(func, file, line, ...) ::arm_compute::error(func, file, line, __VA_ARGS__) // NOLINT +#define ARM_COMPUTE_ERROR_LOC(func, file, line, msg) ARM_COMPUTE_THROW_ERROR(func, file, line, msg) // NOLINT /** If the condition is true, the given message is printed and program exits * * @param[in] cond Condition to evaluate. - * @param[in] ... Message to print if cond is false. + * @param[in] msg Message to display. */ -#define ARM_COMPUTE_EXIT_ON_MSG(cond, ...) \ - do \ - { \ - if(cond) \ - { \ - ARM_COMPUTE_ERROR(__VA_ARGS__); \ - } \ +#define ARM_COMPUTE_EXIT_ON_MSG(cond, msg) \ + do \ + { \ + if(cond) \ + { \ + ARM_COMPUTE_ERROR(msg); \ + } \ + } while(false) + +/** If the condition is true, the given message is printed and program exits. Accepts a message format + * and a variable list of arguments matching the format description. + * + * @param[in] cond Condition to evaluate. + * @param[in] msg Error description message format. + * @param[in] ... List of arguments matching the format description. + */ +#define ARM_COMPUTE_EXIT_ON_MSG_VAR(cond, msg, ...) \ + do \ + { \ + if(cond) \ + { \ + ARM_COMPUTE_ERROR_VAR(msg, __VA_ARGS__); \ + } \ } while(false) #ifdef ARM_COMPUTE_ASSERTS_ENABLED @@ -294,12 +412,22 @@ Status create_error(ErrorCode error_code, const char *function, const char *file /** If the condition is true, the given message is printed and an exception is thrown * * @param[in] cond Condition to evaluate. - * @param[in] ... Message to print if cond is false. + * @param[in] msg Message to display. */ -#define ARM_COMPUTE_ERROR_ON_MSG(cond, ...) \ - ARM_COMPUTE_EXIT_ON_MSG(cond, __VA_ARGS__) +#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg) \ + ARM_COMPUTE_EXIT_ON_MSG(cond, msg) -/** If the condition is true, the given message is printed and an exception is thrown +/** If the condition is true, the given message is printed and an exception is thrown. Accepts a message format + * and a variable list of arguments matching the format description. + * + * @param[in] cond Condition to evaluate. + * @param[in] msg Error description message format. + * @param[in] ... List of arguments matching the format description. + */ +#define ARM_COMPUTE_ERROR_ON_MSG_VAR(cond, msg, ...) \ + ARM_COMPUTE_EXIT_ON_MSG_VAR(cond, msg, __VA_ARGS__) + +/** If the condition is true, the given message is printed and an exception is thrown. * * @param[in] cond Condition to evaluate. * @param[in] func Function in which the error occurred. @@ -307,13 +435,13 @@ Status create_error(ErrorCode error_code, const char *function, const char *file * @param[in] line Line in which the error occurred. * @param[in] ... Message to print if cond is false. */ -#define ARM_COMPUTE_ERROR_ON_LOC_MSG(cond, func, file, line, ...) \ - do \ - { \ - if(cond) \ - { \ - ARM_COMPUTE_ERROR_LOC(func, file, line, __VA_ARGS__); \ - } \ +#define ARM_COMPUTE_ERROR_ON_LOC_MSG(cond, func, file, line, ...) \ + do \ + { \ + if(cond) \ + { \ + ARM_COMPUTE_ERROR_LOC_VAR(func, file, line, __VA_ARGS__); \ + } \ } while(false) /** If the condition is true, the given message is printed and an exception is thrown, otherwise value is returned @@ -325,7 +453,8 @@ Status create_error(ErrorCode error_code, const char *function, const char *file #define ARM_COMPUTE_CONST_ON_ERROR(cond, val, msg) (cond) ? throw std::logic_error(msg) : val; #else /* ARM_COMPUTE_ASSERTS_ENABLED */ #define ARM_COMPUTE_ERROR_THROW_ON(status) -#define ARM_COMPUTE_ERROR_ON_MSG(cond, ...) +#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg) +#define ARM_COMPUTE_ERROR_ON_MSG_VAR(cond, msg, ...) #define ARM_COMPUTE_ERROR_ON_LOC_MSG(cond, func, file, line, ...) #define ARM_COMPUTE_CONST_ON_ERROR(cond, val, msg) val #endif /* ARM_COMPUTE_ASSERTS_ENABLED */ @@ -345,7 +474,7 @@ Status create_error(ErrorCode error_code, const char *function, const char *file * @param[in] line Line in which the error occurred. */ #define ARM_COMPUTE_ERROR_ON_LOC(cond, func, file, line) \ - ARM_COMPUTE_ERROR_ON_LOC_MSG(cond, func, file, line, #cond) + ARM_COMPUTE_ERROR_ON_LOC_MSG(cond, func, file, line, "%s", #cond) #ifndef ARM_COMPUTE_EXCEPTIONS_DISABLED #define ARM_COMPUTE_THROW(ex) throw(ex) diff --git a/arm_compute/core/ITensorInfo.h b/arm_compute/core/ITensorInfo.h index 5aa243ecf8..5b6eb2d127 100644 --- a/arm_compute/core/ITensorInfo.h +++ b/arm_compute/core/ITensorInfo.h @@ -148,7 +148,7 @@ public: * * @return Offset in bytes from the beginning of the memory allocation to access the element (x, y, z, ...) */ - virtual size_t offset_element_in_bytes(const Coordinates &pos) const = 0; + virtual int32_t offset_element_in_bytes(const Coordinates &pos) const = 0; /** Element size in bytes calculated as data_size() * num_channels() * diff --git a/arm_compute/core/Log.h b/arm_compute/core/Log.h index 2d8d396459..a6e1592286 100644 --- a/arm_compute/core/Log.h +++ b/arm_compute/core/Log.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -96,11 +96,11 @@ * @param[in] fmt String format (printf style) * @param[in] ... Message arguments */ -#define ARM_COMPUTE_LOG_INFO_MSG_WITH_FORMAT_CORE(fmt, ...) \ - do \ - { \ - ARM_COMPUTE_CREATE_DEFAULT_CORE_LOGGER(); \ - ARM_COMPUTE_LOG_MSG_WITH_FORMAT_CORE(arm_compute::logging::LogLevel::INFO, fmt, __VA_ARGS__); \ +#define ARM_COMPUTE_LOG_INFO_MSG_WITH_FORMAT_CORE(fmt, ...) \ + do \ + { \ + ARM_COMPUTE_CREATE_DEFAULT_CORE_LOGGER(); \ + ARM_COMPUTE_LOG_MSG_WITH_FORMAT_CORE(arm_compute::logging::LogLevel::INFO, #fmt, __VA_ARGS__); \ } while(false) /** Log information level stream to the core system logger diff --git a/arm_compute/core/Steps.h b/arm_compute/core/Steps.h index 33a88a2568..d66f0f20ea 100644 --- a/arm_compute/core/Steps.h +++ b/arm_compute/core/Steps.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -37,7 +37,7 @@ namespace arm_compute /** Class to describe a number of elements in each dimension. Similar to @ref * Strides but not in bytes but number of elements. */ -class Steps : public Dimensions +class Steps : public Dimensions { public: /** Constructor to initialize the steps. diff --git a/arm_compute/core/Strides.h b/arm_compute/core/Strides.h index 105fdfde4e..f681d24c18 100644 --- a/arm_compute/core/Strides.h +++ b/arm_compute/core/Strides.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -34,7 +34,7 @@ namespace arm_compute { /** Strides of an item in bytes */ -class Strides : public Dimensions +class Strides : public Dimensions { public: /** Constructor to initialize the strides. diff --git a/arm_compute/core/SubTensorInfo.h b/arm_compute/core/SubTensorInfo.h index 3de31deb44..5aee115dd3 100644 --- a/arm_compute/core/SubTensorInfo.h +++ b/arm_compute/core/SubTensorInfo.h @@ -136,7 +136,7 @@ public: ARM_COMPUTE_ERROR_ON(_parent == nullptr); return _parent->offset_element_in_bytes(_coords); } - size_t offset_element_in_bytes(const Coordinates &pos) const override; + int32_t offset_element_in_bytes(const Coordinates &pos) const override; size_t element_size() const override { ARM_COMPUTE_ERROR_ON(_parent == nullptr); diff --git a/arm_compute/core/TensorInfo.h b/arm_compute/core/TensorInfo.h index 77913f52f9..d1a64f59ef 100644 --- a/arm_compute/core/TensorInfo.h +++ b/arm_compute/core/TensorInfo.h @@ -236,7 +236,7 @@ public: { return _offset_first_element_in_bytes; } - size_t offset_element_in_bytes(const Coordinates &pos) const override; + int32_t offset_element_in_bytes(const Coordinates &pos) const override; size_t element_size() const override { return data_size_from_type(_data_type) * _num_channels; diff --git a/arm_compute/core/TensorShape.h b/arm_compute/core/TensorShape.h index d531dcf462..79aa118731 100644 --- a/arm_compute/core/TensorShape.h +++ b/arm_compute/core/TensorShape.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2018 ARM Limited. + * Copyright (c) 2016-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -36,7 +36,7 @@ namespace arm_compute { /** Shape of a tensor */ -class TensorShape : public Dimensions +class TensorShape : public Dimensions { public: /** Constructor to initialize the tensor shape. diff --git a/arm_compute/core/Validate.h b/arm_compute/core/Validate.h index ab518ef687..76a32f4007 100644 --- a/arm_compute/core/Validate.h +++ b/arm_compute/core/Validate.h @@ -663,7 +663,7 @@ inline arm_compute::Status error_on_data_type_not_in(const char *function, const ARM_COMPUTE_RETURN_ERROR_ON_LOC(tensor_dt == DataType::UNKNOWN, function, file, line); const std::array dts_array{ { std::forward(dts)... } }; - ARM_COMPUTE_RETURN_ERROR_ON_LOC_MSG(tensor_dt != dt && std::none_of(dts_array.begin(), dts_array.end(), [&](const T & d) + ARM_COMPUTE_RETURN_ERROR_ON_LOC_MSG_VAR(tensor_dt != dt && std::none_of(dts_array.begin(), dts_array.end(), [&](const T & d) { return d == tensor_dt; }), @@ -715,7 +715,7 @@ inline arm_compute::Status error_on_data_layout_not_in(const char *function, con ARM_COMPUTE_RETURN_ERROR_ON_LOC(tensor_dl == DataLayout::UNKNOWN, function, file, line); const std::array dls_array{ { std::forward(dls)... } }; - ARM_COMPUTE_RETURN_ERROR_ON_LOC_MSG(tensor_dl != dl && std::none_of(dls_array.begin(), dls_array.end(), [&](const T & l) + ARM_COMPUTE_RETURN_ERROR_ON_LOC_MSG_VAR(tensor_dl != dl && std::none_of(dls_array.begin(), dls_array.end(), [&](const T & l) { return l == tensor_dl; }), @@ -764,7 +764,7 @@ inline arm_compute::Status error_on_data_type_channel_not_in(const char *functio { ARM_COMPUTE_RETURN_ON_ERROR(::arm_compute::error_on_data_type_not_in(function, file, line, tensor_info, std::forward(dt), std::forward(dts)...)); const size_t tensor_nc = tensor_info->num_channels(); - ARM_COMPUTE_RETURN_ERROR_ON_LOC_MSG(tensor_nc != num_channels, function, file, line, "Number of channels %d. Required number of channels %d", tensor_nc, num_channels); + ARM_COMPUTE_RETURN_ERROR_ON_LOC_MSG_VAR(tensor_nc != num_channels, function, file, line, "Number of channels %zu. Required number of channels %zu", tensor_nc, num_channels); return arm_compute::Status{}; } /** Return an error if the data type or the number of channels of the passed tensor does not match any of the data types and number of channels provided. diff --git a/arm_compute/core/Window.inl b/arm_compute/core/Window.inl index 589d6bfafc..c2131816a6 100644 --- a/arm_compute/core/Window.inl +++ b/arm_compute/core/Window.inl @@ -265,7 +265,7 @@ inline void Window::use_tensor_dimensions(const TensorShape &shape, size_t first { for(unsigned int n = first_dimension; n < shape.num_dimensions(); ++n) { - set(n, Window::Dimension(0, std::max(shape[n], static_cast(1)))); + set(n, Window::Dimension(0, std::max(shape[n], static_cast(1)))); } } diff --git a/arm_compute/core/utils/logging/Macros.h b/arm_compute/core/utils/logging/Macros.h index 5593030261..6c5bb32144 100644 --- a/arm_compute/core/utils/logging/Macros.h +++ b/arm_compute/core/utils/logging/Macros.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 ARM Limited. + * Copyright (c) 2017-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -40,14 +40,17 @@ } \ } while(false) -#define ARM_COMPUTE_LOG_MSG_WITH_FORMAT(logger_name, log_level, fmt, ...) \ - do \ - { \ - auto __logger = arm_compute::logging::LoggerRegistry::get().logger(logger_name); \ - if(__logger != nullptr) \ - { \ - __logger->log(log_level, fmt, __VA_ARGS__); \ - } \ +#define ARM_COMPUTE_LOG_MSG_WITH_FORMAT(logger_name, log_level, fmt, ...) \ + do \ + { \ + auto __logger = arm_compute::logging::LoggerRegistry::get().logger(logger_name); \ + if(__logger != nullptr) \ + { \ + size_t size = ::snprintf(nullptr, 0, fmt, __VA_ARGS__) + 1; \ + auto char_str = support::cpp14::make_unique(size); \ + ::snprintf(char_str.get(), size, #fmt, __VA_ARGS__); \ + __logger->log(log_level, std::string(char_str.get(), char_str.get() + size - 1)); \ + } \ } while(false) #define ARM_COMPUTE_LOG_STREAM(logger_name, log_level, stream) \ -- cgit v1.2.1