Skip to content

Commit 451ed7b

Browse files
committed
clang-tidy: use ifdef
Found with readability-use-concise-preprocessor-directives Signed-off-by: Rosen Penev <[email protected]>
1 parent c322cb4 commit 451ed7b

File tree

9 files changed

+20
-20
lines changed

9 files changed

+20
-20
lines changed

app/actions.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include <unistd.h> // for stat()
3030
#endif
3131

32-
#if defined(_WIN32)
32+
#ifdef _WIN32
3333
#include <fcntl.h>
3434
#include <io.h>
3535
#include <sys/utime.h>
@@ -1659,7 +1659,7 @@ std::string temporaryPath() {
16591659
static int count = 0;
16601660
auto guard = std::scoped_lock(cs);
16611661

1662-
#if defined(_WIN32)
1662+
#ifdef _WIN32
16631663
DWORD pid = ::GetCurrentProcessId();
16641664
#else
16651665
pid_t pid = ::getpid();
@@ -1843,7 +1843,7 @@ int renameFile(std::string& newPath, const tm* tm, Exiv2::ExifData& exifData) {
18431843
// is done after calling setting date/time: the value retrieved from tag might include something like %Y, which then
18441844
// should not be replaced by year
18451845
std::regex format_regex(":{1}?(Exif\\..*?):{1}?");
1846-
#if defined(_WIN32)
1846+
#ifdef _WIN32
18471847
std::string illegalChars = "\\/:*?\"<>|";
18481848
#else
18491849
std::string illegalChars = "/:";

app/exiv2.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <filesystem>
2626
namespace fs = std::filesystem;
2727

28-
#if defined(_WIN32)
28+
#ifdef _WIN32
2929
#include <fcntl.h>
3030
#include <io.h>
3131
#include <windows.h>
@@ -960,7 +960,7 @@ static size_t readFileToBuf(FILE* f, Exiv2::DataBuf& buf) {
960960
void Params::getStdin(Exiv2::DataBuf& buf) {
961961
// copy stdin to stdinBuf
962962
if (stdinBuf.empty()) {
963-
#if defined(_WIN32)
963+
#ifdef _WIN32
964964
DWORD fdwMode;
965965
_setmode(_fileno(stdin), O_BINARY);
966966
Sleep(300);

include/exiv2/basicio.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ class EXIV2API MemIo : public BasicIo {
655655
/*!
656656
@brief Provides binary IO for the data from stdin and data uri path.
657657
*/
658-
#if defined(EXV_ENABLE_FILESYSTEM)
658+
#ifdef EXV_ENABLE_FILESYSTEM
659659
class EXIV2API XPathIo : public FileIo {
660660
public:
661661
/*!

src/basicio.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class FileIo::Impl {
8585
FILE* fp_{}; //!< File stream pointer
8686
OpMode opMode_{opSeek}; //!< File open mode
8787

88-
#if defined _WIN32
88+
#ifdef _WIN32
8989
HANDLE hFile_{}; //!< Duplicated fd
9090
HANDLE hMap_{}; //!< Handle from CreateFileMapping
9191
#endif
@@ -218,7 +218,7 @@ FileIo::~FileIo() {
218218
int FileIo::munmap() {
219219
int rc = 0;
220220
if (p_->pMappedArea_) {
221-
#if defined _WIN32
221+
#ifdef _WIN32
222222
UnmapViewOfFile(p_->pMappedArea_);
223223
CloseHandle(p_->hMap_);
224224
p_->hMap_ = nullptr;
@@ -878,7 +878,7 @@ const std::string& MemIo::path() const noexcept {
878878
void MemIo::populateFakeData() {
879879
}
880880

881-
#if defined(EXV_ENABLE_FILESYSTEM)
881+
#ifdef EXV_ENABLE_FILESYSTEM
882882
XPathIo::XPathIo(const std::string& orgPath) : FileIo(XPathIo::writeDataToFile(orgPath)), tempFilePath_(path()) {
883883
}
884884

src/convert.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
// *****************************************************************************
4545
// local declarations
4646
namespace {
47-
#if defined EXV_HAVE_ICONV
47+
#ifdef EXV_HAVE_ICONV
4848
// Convert string charset with iconv.
4949
bool convertStringCharsetIconv(std::string& str, std::string_view from, std::string_view to);
5050
#elif defined _WIN32
@@ -1377,7 +1377,7 @@ void moveXmpToIptc(XmpData& xmpData, IptcData& iptcData) {
13771377
bool convertStringCharset([[maybe_unused]] std::string& str, const char* from, const char* to) {
13781378
if (0 == strcmp(from, to))
13791379
return true; // nothing to do
1380-
#if defined EXV_HAVE_ICONV
1380+
#ifdef EXV_HAVE_ICONV
13811381
return convertStringCharsetIconv(str, from, to);
13821382
#elif defined _WIN32
13831383
return convertStringCharsetWindows(str, from, to);
@@ -1395,7 +1395,7 @@ bool convertStringCharset([[maybe_unused]] std::string& str, const char* from, c
13951395
namespace {
13961396
using namespace Exiv2;
13971397

1398-
#if defined EXV_HAVE_ICONV
1398+
#ifdef EXV_HAVE_ICONV
13991399
bool convertStringCharsetIconv(std::string& str, std::string_view from, std::string_view to) {
14001400
if (from == to)
14011401
return true; // nothing to do

src/futils.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <filesystem>
2121
namespace fs = std::filesystem;
2222

23-
#if defined(_WIN32)
23+
#ifdef _WIN32
2424
// clang-format off
2525
#include <windows.h>
2626
#include <psapi.h> // For access to GetModuleFileName
@@ -39,7 +39,7 @@ namespace fs = std::filesystem;
3939
#include <mach-o/dyld.h> // for _NSGetExecutablePath()
4040
#endif
4141

42-
#if defined(__FreeBSD__)
42+
#ifdef __FreeBSD__
4343
// clang-format off
4444
#include <sys/mount.h>
4545
#include <sys/param.h>
@@ -355,7 +355,7 @@ Uri Uri::Parse(const std::string& uri) {
355355

356356
std::string getProcessPath() {
357357
#ifdef EXV_ENABLE_FILESYSTEM
358-
#if defined(__FreeBSD__)
358+
#ifdef __FreeBSD__
359359
std::string ret("unknown");
360360
unsigned int n;
361361
char buffer[PATH_MAX] = {};
@@ -375,7 +375,7 @@ std::string getProcessPath() {
375375
return ret.substr(0, idxLastSeparator);
376376
#else
377377
try {
378-
#if defined(_WIN32)
378+
#ifdef _WIN32
379379
TCHAR pathbuf[MAX_PATH];
380380
GetModuleFileName(nullptr, pathbuf, MAX_PATH);
381381
auto path = fs::path(pathbuf);

src/http.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ int Exiv2::http(Exiv2::Dictionary& request, Exiv2::Dictionary& response, std::st
124124

125125
////////////////////////////////////
126126
// Windows specific code
127-
#if defined(_WIN32)
127+
#ifdef _WIN32
128128
WSADATA wsaData;
129129
if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0)
130130
return error(errors, "could not start WinSock");

src/makernote_int.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include <filesystem>
2222
namespace fs = std::filesystem;
2323

24-
#if !defined(_WIN32)
24+
#ifndef _WIN32
2525
#include <pwd.h>
2626
#include <unistd.h>
2727
#else

src/version.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ void Exiv2::dumpLibraryInfo(std::ostream& os, const std::vector<std::regex>& key
214214
#endif
215215

216216
const char* compiler =
217-
#if defined(_MSC_VER)
217+
#ifdef _MSC_VER
218218
"MSVC";
219219

220220
#ifndef __VERSION__
@@ -266,7 +266,7 @@ void Exiv2::dumpLibraryInfo(std::ostream& os, const std::vector<std::regex>& key
266266
#endif
267267

268268
const char* platform =
269-
#if defined(__MSYS__)
269+
#ifdef __MSYS__
270270
"msys";
271271
#elif defined(__CYGWIN__)
272272
"cygwin";

0 commit comments

Comments
 (0)