Skip to content

Commit 7a826ac

Browse files
committed
clang-tidy: add parentheses to macros
Signed-off-by: Rosen Penev <[email protected]>
1 parent cacb54e commit 7a826ac

File tree

5 files changed

+9
-16
lines changed

5 files changed

+9
-16
lines changed

samples/geotag.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919

2020
using namespace std;
2121

22-
#ifndef lengthof
23-
#define lengthof(x) (sizeof(*x) / sizeof(x))
24-
#endif
25-
2622
#if defined(_MSC_VER) || defined(__MINGW__)
2723
#include <windows.h>
2824
char* realpath(const char* file, char* path);

samples/getopt-test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#endif
3232
#include <iostream>
3333

34-
#define Safe(x) (x ? x : "unknown")
34+
#define Safe(x) ((x) ? (x) : "unknown")
3535
const char* optstring = ":hVvqfbuktTFa:Y:O:D:r:p:P:d:e:i:c:m:M:l:S:g:K:n:Q:";
3636

3737
// *****************************************************************************

src/http.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
#define WINAPI
3838
using DWORD = unsigned long;
3939

40-
#define SOCKET_ERROR -1
40+
#define SOCKET_ERROR (-1)
4141
#define WSAEWOULDBLOCK EINPROGRESS
4242
#define WSAENOTCONN EAGAIN
4343

@@ -56,10 +56,10 @@ static constexpr auto httpTemplate =
5656
"%s" // $header
5757
"\r\n";
5858

59-
#define white(c) ((c == ' ') || (c == '\t'))
59+
#define white(c) (((c) == ' ') || ((c) == '\t'))
6060

61-
#define FINISH -999
62-
#define OK(s) (200 <= s && s < 300)
61+
#define FINISH (-999)
62+
#define OK(s) (200 <= (s) && (s) < 300)
6363

6464
static constexpr std::array<const char*, 2> blankLines{
6565
"\r\n\r\n", // this is the standard

src/tiffimage_int.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
#include <iostream>
1313

1414
// Shortcuts for the newTiffBinaryArray templates.
15-
#define EXV_BINARY_ARRAY(arrayCfg, arrayDef) (newTiffBinaryArray0<&arrayCfg, std::size(arrayDef), arrayDef>)
16-
#define EXV_SIMPLE_BINARY_ARRAY(arrayCfg) (newTiffBinaryArray1<&arrayCfg>)
15+
#define EXV_BINARY_ARRAY(arrayCfg, arrayDef) (newTiffBinaryArray0<&(arrayCfg), std::size(arrayDef), arrayDef>)
16+
#define EXV_SIMPLE_BINARY_ARRAY(arrayCfg) (newTiffBinaryArray1<&(arrayCfg)>)
1717
#define EXV_COMPLEX_BINARY_ARRAY(arraySet, cfgSelFct) (newTiffBinaryArray2<arraySet, std::size(arraySet), cfgSelFct>)
1818

1919
namespace Exiv2::Internal {

src/version.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
#include <unistd.h>
2828
#endif
2929

30-
#ifndef lengthof
31-
#define lengthof(x) sizeof(x) / sizeof(x[0])
32-
#endif
3330
#ifndef _MAX_PATH
3431
#define _MAX_PATH 512
3532
#endif
@@ -126,10 +123,10 @@ static std::vector<std::string> getLoadedLibraries() {
126123
// enumerate loaded libraries and determine path to executable
127124
HMODULE handles[200];
128125
DWORD cbNeeded;
129-
if (EnumProcessModules(GetCurrentProcess(), handles, lengthof(handles), &cbNeeded)) {
126+
if (EnumProcessModules(GetCurrentProcess(), handles, std::size(handles), &cbNeeded)) {
130127
char szFilename[_MAX_PATH];
131128
for (DWORD h = 0; h < cbNeeded / sizeof(handles[0]); h++) {
132-
GetModuleFileNameA(handles[h], szFilename, lengthof(szFilename));
129+
GetModuleFileNameA(handles[h], szFilename, std::size(szFilename));
133130
std::string path(szFilename);
134131
pushPath(path, libs, paths);
135132
}

0 commit comments

Comments
 (0)