Use [[maybe_unused]]

This commit is contained in:
Luis Díaz Más 2022-03-07 19:12:01 +01:00
parent 5508e6f466
commit 2834fa5f05
10 changed files with 10 additions and 36 deletions

View File

@ -22,7 +22,6 @@
// g++ geotag.cpp -o geotag -lexiv2 -lexpat
#include <exiv2/exiv2.hpp>
#include "unused.h"
#include <filesystem>
#include <iostream>

View File

@ -21,7 +21,6 @@
// Sample/test for high level XMP classes. See also addmoddel.cpp
#include <exiv2/exiv2.hpp>
#include "unused.h"
#include <string>
#include <iostream>
@ -77,26 +76,22 @@ try {
assert(xmpData["Xmp.dc.one"].toInt64() == -1);
assert(xmpData["Xmp.dc.one"].value().ok());
const Exiv2::Value &getv1 = xmpData["Xmp.dc.one"].value();
UNUSED(getv1);
[[maybe_unused]] const Exiv2::Value &getv1 = xmpData["Xmp.dc.one"].value();
assert(isEqual(getv1.toFloat(), -1));
assert(getv1.ok());
assert(getv1.toRational() == Exiv2::Rational(-1, 1));
assert(getv1.ok());
const Exiv2::Value &getv2 = xmpData["Xmp.dc.two"].value();
UNUSED(getv2);
[[maybe_unused]] const Exiv2::Value &getv2 = xmpData["Xmp.dc.two"].value();
assert(isEqual(getv2.toFloat(), 3.1415f));
assert(getv2.ok());
assert(getv2.toInt64() == 3);
assert(getv2.ok());
Exiv2::Rational R = getv2.toRational();
UNUSED(R);
[[maybe_unused]] Exiv2::Rational R = getv2.toRational();
assert(getv2.ok());
assert(isEqual(static_cast<float>(R.first) / R.second, 3.1415f ));
const Exiv2::Value &getv3 = xmpData["Xmp.dc.three"].value();
UNUSED(getv3);
[[maybe_unused]] const Exiv2::Value &getv3 = xmpData["Xmp.dc.three"].value();
assert(isEqual(getv3.toFloat(), 5.0f/7.0f));
assert(getv3.ok());
assert(getv3.toInt64() == 0); // long(5.0 / 7.0)
@ -104,10 +99,9 @@ try {
assert(getv3.toRational() == Exiv2::Rational(5, 7));
assert(getv3.ok());
const Exiv2::Value &getv6 = xmpData["Xmp.dc.six"].value();
UNUSED(getv6);
[[maybe_unused]] const Exiv2::Value &getv6 = xmpData["Xmp.dc.six"].value();
assert(getv6.toInt64() == 0);
assert(getv6.ok());
assert(getv6.ok()^);
assert(getv6.toFloat() == 0.0f);
assert(getv6.ok());
assert(getv6.toRational() == Exiv2::Rational(0, 1));
@ -117,8 +111,7 @@ try {
getv7.toInt64(); // this should fail
assert(!getv7.ok());
const Exiv2::Value &getv8 = xmpData["Xmp.dc.eight"].value();
UNUSED(getv8);
[[maybe_unused]] const Exiv2::Value &getv8 = xmpData["Xmp.dc.eight"].value();
assert(getv8.toInt64() == 1);
assert(getv8.ok());
assert(getv8.toFloat() == 1.0f);

View File

@ -34,7 +34,6 @@ add_library( exiv2lib_int OBJECT
tiffimage_int.cpp tiffimage_int.hpp
tiffvisitor_int.cpp tiffvisitor_int.hpp
tifffwd_int.hpp
unused.h
utils.hpp utils.cpp
)

View File

@ -14,7 +14,6 @@
#include "tiffimage.hpp"
#include "tiffimage_int.hpp"
#include "types.hpp"
#include "unused.h"
// + standard includes
#include <cassert>

View File

@ -16,7 +16,6 @@
#include "xmp_exiv2.hpp"
#include "futils.hpp"
#include "convert.hpp"
#include "unused.h"
// + standard includes
#include <algorithm>

View File

@ -3,7 +3,6 @@
#include "crwimage_int.hpp"
#include "canonmn_int.hpp"
#include "i18n.h" // NLS support.
#include "unused.h"
#include "error.hpp"
#include "enforce.hpp"
@ -592,8 +591,7 @@ namespace Exiv2::Internal {
{
CrwDirs crwDirs;
CrwMap::loadStack(crwDirs, crwDir);
uint16_t rootDirectory = crwDirs.top().crwDir_;
UNUSED(rootDirectory);
[[maybe_unused]] uint16_t rootDirectory = crwDirs.top().crwDir_;
assert(rootDirectory == 0x0000);
crwDirs.pop();
if (!pRootDir_) {
@ -671,8 +669,7 @@ namespace Exiv2::Internal {
if (pRootDir_) {
CrwDirs crwDirs;
CrwMap::loadStack(crwDirs, crwDir);
uint16_t rootDirectory = crwDirs.top().crwDir_;
UNUSED(rootDirectory);
[[maybe_unused]] uint16_t rootDirectory = crwDirs.top().crwDir_;
assert(rootDirectory == 0x0000);
crwDirs.pop();
pRootDir_->remove(crwDirs, crwTagId);

View File

@ -18,7 +18,6 @@
#include "jpgimage.hpp"
#include "tiffimage.hpp"
#include "tiffimage_int.hpp"
#include "unused.h"
// *****************************************************************************
namespace {

View File

@ -6,7 +6,6 @@
#include "futils.hpp"
#include "i18n.h" // for _exvGettext
#include "safe_op.hpp"
#include "unused.h"
// + standard includes
#include <string>

View File

@ -1,8 +0,0 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#ifndef UNUSED_H
#define UNUSED_H
#define UNUSED(x) (void)(x)
#endif // UNUSED_H

View File

@ -6,7 +6,6 @@
#include "enforce.hpp"
#include "error.hpp"
#include "convert.hpp"
#include "unused.h"
// + standard includes
#include <ctype.h>
@ -451,8 +450,7 @@ namespace Exiv2 {
std::string c = value_;
if (charsetId() == unicode) {
c = value_.substr(8);
const size_t sz = c.size();
UNUSED(sz);
[[maybe_unused]] const size_t sz = c.size();
if (byteOrder_ == littleEndian && byteOrder == bigEndian) {
convertStringCharset(c, "UCS-2LE", "UCS-2BE");
assert(c.size() == sz);