FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix clang-tidy-16 failures · drawcode/SFML@fe2ca0b · GitHub

/ SFML Public
forked from SFML/SFML

Commit fe2ca0b

Browse files
committed
Fix clang-tidy-16 failures
1 parent 33030e9 commit fe2ca0b

16 files changed

Lines changed: 220 additions & 209 deletions

‎examples/X11/X11.cpp‎

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
// Setup a perspective projection
5050
glMatrixMode(GL_PROJECTION);
5151
glLoadIdentity();
52-
float extent = std::tan(sf::degrees(45).asRadians());
52+
const float extent = std::tan(sf::degrees(45).asRadians());
5353

5454
#ifdef SFML_OPENGL_ES
5555
glFrustumf(-extent, extent, -extent, extent, 1.0f, 500.0f);
@@ -166,55 +166,55 @@ int main()
166166
return EXIT_FAILURE;
167167

168168
// Get the default screen
169-
int screen = DefaultScreen(display);
169+
const int screen = DefaultScreen(display);
170170

171171
// Let's create the main window
172172
XSetWindowAttributes attributes;
173173
attributes.background_pixel = BlackPixel(display, screen);
174174
attributes.event_mask = KeyPressMask;
175-
Window window = XCreateWindow(display,
176-
RootWindow(display, screen),
177-
0,
178-
0,
179-
650,
180-
330,
181-
0,
182-
DefaultDepth(display, screen),
183-
InputOutput,
184-
DefaultVisual(display, screen),
185-
CWBackPixel | CWEventMask,
186-
&attributes);
175+
const Window window = XCreateWindow(display,
176+
RootWindow(display, screen),
177+
0,
178+
0,
179+
650,
180+
330,
181+
0,
182+
DefaultDepth(display, screen),
183+
InputOutput,
184+
DefaultVisual(display, screen),
185+
CWBackPixel | CWEventMask,
186+
&attributes);
187187
if (!window)
188188
return EXIT_FAILURE;
189189

190190
// Set the window's name
191191
XStoreName(display, window, "SFML Window");
192192

193193
// Let's create the windows which will serve as containers for our SFML views
194-
Window view1 = XCreateWindow(display,
195-
window,
196-
10,
197-
10,
198-
310,
199-
310,
200-
0,
201-
DefaultDepth(display, screen),
202-
InputOutput,
203-
DefaultVisual(display, screen),
204-
0,
205-
nullptr);
206-
Window view2 = XCreateWindow(display,
207-
window,
208-
330,
209-
10,
210-
310,
211-
310,
212-
0,
213-
DefaultDepth(display, screen),
214-
InputOutput,
215-
DefaultVisual(display, screen),
216-
0,
217-
nullptr);
194+
const Window view1 = XCreateWindow(display,
195+
window,
196+
10,
197+
10,
198+
310,
199+
310,
200+
0,
201+
DefaultDepth(display, screen),
202+
InputOutput,
203+
DefaultVisual(display, screen),
204+
0,
205+
nullptr);
206+
const Window view2 = XCreateWindow(display,
207+
window,
208+
330,
209+
10,
210+
310,
211+
310,
212+
0,
213+
DefaultDepth(display, screen),
214+
InputOutput,
215+
DefaultVisual(display, screen),
216+
0,
217+
nullptr);
218218

219219
// Show our windows
220220
XMapWindow(display, window);
@@ -225,7 +225,7 @@ int main()
225225
sf::Window sfmlView2(view2);
226226

227227
// Create a clock for measuring elapsed time
228-
sf::Clock clock;
228+
const sf::Clock clock;
229229

230230
// Load OpenGL or OpenGL ES entry points using glad
231231
if (!sfmlView1.setActive())

‎src/SFML/Window/DRM/DRMContext.cpp‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ void cleanup()
136136

137137
void drmFbDestroyCallback(gbm_bo* bo, void* data)
138138
{
139-
int drmFd = gbm_device_get_fd(gbm_bo_get_device(bo));
140-
auto* fb = static_cast<DrmFb*>(data);
139+
const int drmFd = gbm_device_get_fd(gbm_bo_get_device(bo));
140+
auto* fb = static_cast<DrmFb*>(data);
141141

142142
if (fb->fbId)
143143
drmModeRmFB(drmFd, fb->fbId);
@@ -147,8 +147,8 @@ void drmFbDestroyCallback(gbm_bo* bo, void* data)
147147

148148
DrmFb* drmFbGetFromBo(gbm_bo& bo)
149149
{
150-
int drmFd = gbm_device_get_fd(gbm_bo_get_device(&bo));
151-
auto* fb = static_cast<DrmFb*>(gbm_bo_get_user_data(&bo));
150+
const int drmFd = gbm_device_get_fd(gbm_bo_get_device(&bo));
151+
auto* fb = static_cast<DrmFb*>(gbm_bo_get_user_data(&bo));
152152
if (fb)
153153
return fb;
154154

@@ -549,7 +549,7 @@ DRMContext::DRMContext(DRMContext* shared, const ContextSettings& settings, cons
549549
// Create EGL context
550550
createContext(shared);
551551

552-
Vector2u size = owner.getSize();
552+
const Vector2u size = owner.getSize();
553553
createSurface(size, bitsPerPixel, true);
554554
}
555555

‎src/SFML/Window/DRM/InputImplUDev.cpp‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,15 @@ bool keepFileDescriptor(int fileDesc)
117117
// This is the keyboard test used by SDL.
118118
// The first 32 bits are ESC, numbers and Q to D; If we have any of those,
119119
// consider it a keyboard device; do not test for KEY_RESERVED, though
120-
bool isKeyboard = (bitmaskKey[0] & 0xFFFFFFFE);
120+
const bool isKeyboard = (bitmaskKey[0] & 0xFFFFFFFE);
121121

122-
bool isAbs = TEST_BIT(EV_ABS, bitmaskEv) && TEST_BIT(ABS_X, bitmaskAbs) && TEST_BIT(ABS_Y, bitmaskAbs);
122+
const bool isAbs = TEST_BIT(EV_ABS, bitmaskEv) && TEST_BIT(ABS_X, bitmaskAbs) && TEST_BIT(ABS_Y, bitmaskAbs);
123123

124-
bool isRel = TEST_BIT(EV_REL, bitmaskEv) && TEST_BIT(REL_X, bitmaskRel) && TEST_BIT(REL_Y, bitmaskRel);
124+
const bool isRel = TEST_BIT(EV_REL, bitmaskEv) && TEST_BIT(REL_X, bitmaskRel) && TEST_BIT(REL_Y, bitmaskRel);
125125

126-
bool isMouse = (isAbs || isRel) && TEST_BIT(BTN_MOUSE, bitmaskKey);
126+
const bool isMouse = (isAbs || isRel) && TEST_BIT(BTN_MOUSE, bitmaskKey);
127127

128-
bool isTouch = isAbs && (TEST_BIT(BTN_TOOL_FINGER, bitmaskKey) || TEST_BIT(BTN_TOUCH, bitmaskKey));
128+
const bool isTouch = isAbs && (TEST_BIT(BTN_TOOL_FINGER, bitmaskKey) || TEST_BIT(BTN_TOUCH, bitmaskKey));
129129

130130
return isKeyboard || isMouse || isTouch;
131131
}
@@ -145,7 +145,7 @@ void initFileDescriptors()
145145
stream << i;
146146
name += stream.str();
147147

148-
int tempFD = open(name.c_str(), O_RDONLY | O_NONBLOCK);
148+
const int tempFD = open(name.c_str(), O_RDONLY | O_NONBLOCK);
149149

150150
if (tempFD < 0)
151151
{
@@ -355,7 +355,7 @@ void processSlots()
355355

356356
bool eventProcess(sf::Event& event)
357357
{
358-
std::lock_guard lock(inputMutex);
358+
const std::lock_guard lock(inputMutex);
359359

360360
// Ensure that we are initialized
361361
initFileDescriptors();
@@ -383,7 +383,7 @@ bool eventProcess(sf::Event& event)
383383
{
384384
if (inputEvent.type == EV_KEY)
385385
{
386-
sf::Mouse::Button mb = toMouseButton(inputEvent.code);
386+
const sf::Mouse::Button mb = toMouseButton(inputEvent.code);
387387
if (mb != sf::Mouse::ButtonCount)
388388
{
389389
event.type = inputEvent.value ? sf::Event::MouseButtonPressed : sf::Event::MouseButtonReleased;
@@ -396,7 +396,7 @@ bool eventProcess(sf::Event& event)
396396
}
397397
else
398398
{
399-
sf::Keyboard::Key kb = toKey(inputEvent.code);
399+
const sf::Keyboard::Key kb = toKey(inputEvent.code);
400400

401401
unsigned int special = 0;
402402
if ((kb == sf::Keyboard::Delete) || (kb == sf::Keyboard::Backspace))
@@ -571,7 +571,7 @@ namespace sf::priv
571571
////////////////////////////////////////////////////////////
572572
bool InputImpl::isKeyPressed(Keyboard::Key key)
573573
{
574-
std::lock_guard lock(inputMutex);
574+
const std::lock_guard lock(inputMutex);
575575
if ((key < 0) || (key >= static_cast<int>(keyMap.size())))
576576
return false;
577577

@@ -625,7 +625,7 @@ void InputImpl::setVirtualKeyboardVisible(bool /*visible*/)
625625
////////////////////////////////////////////////////////////
626626
bool InputImpl::isMouseButtonPressed(Mouse::Button button)
627627
{
628-
std::lock_guard lock(inputMutex);
628+
const std::lock_guard lock(inputMutex);
629629
if ((button < 0) || (button >= static_cast<int>(mouseMap.size())))
630630
return false;
631631

@@ -637,7 +637,7 @@ bool InputImpl::isMouseButtonPressed(Mouse::Button button)
637637
////////////////////////////////////////////////////////////
638638
Vector2i InputImpl::getMousePosition()
639639
{
640-
std::lock_guard lock(inputMutex);
640+
const std::lock_guard lock(inputMutex);
641641
return mousePos;
642642
}
643643

@@ -652,7 +652,7 @@ Vector2i InputImpl::getMousePosition(const WindowBase& /*relativeTo*/)
652652
////////////////////////////////////////////////////////////
653653
void InputImpl::setMousePosition(const Vector2i& position)
654654
{
655-
std::lock_guard lock(inputMutex);
655+
const std::lock_guard lock(inputMutex);
656656
mousePos = position;
657657
}
658658

@@ -696,7 +696,7 @@ Vector2i InputImpl::getTouchPosition(unsigned int finger, const WindowBase& /*re
696696
////////////////////////////////////////////////////////////
697697
bool InputImpl::checkEvent(sf::Event& event)
698698
{
699-
std::lock_guard lock(inputMutex);
699+
const std::lock_guard lock(inputMutex);
700700
if (!eventQueue.empty())
701701
{
702702
event = eventQueue.front();
@@ -730,7 +730,7 @@ bool InputImpl::checkEvent(sf::Event& event)
730730
////////////////////////////////////////////////////////////
731731
void InputImpl::setTerminalConfig()
732732
{
733-
std::lock_guard lock(inputMutex);
733+
const std::lock_guard lock(inputMutex);
734734
initFileDescriptors();
735735

736736
tcgetattr(STDIN_FILENO, &newTerminalConfig); // get current terminal config
@@ -747,7 +747,7 @@ void InputImpl::setTerminalConfig()
747747
////////////////////////////////////////////////////////////
748748
void InputImpl::restoreTerminalConfig()
749749
{
750-
std::lock_guard lock(inputMutex);
750+
const std::lock_guard lock(inputMutex);
751751
initFileDescriptors();
752752

753753
tcsetattr(STDIN_FILENO, TCSANOW, &oldTerminalConfig); // restore terminal config

‎src/SFML/Window/DRM/VideoModeImpl.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ std::vector<VideoMode> VideoModeImpl::getFullscreenModes()
3838
{
3939
std::vector<VideoMode> modes;
4040

41-
Drm& drm = sf::priv::DRMContext::getDRM();
41+
const Drm& drm = sf::priv::DRMContext::getDRM();
4242
drmModeConnectorPtr conn = drm.savedConnector;
4343

4444
if (conn)
@@ -56,7 +56,7 @@ std::vector<VideoMode> VideoModeImpl::getFullscreenModes()
5656
////////////////////////////////////////////////////////////
5757
VideoMode VideoModeImpl::getDesktopMode()
5858
{
59-
Drm& drm = sf::priv::DRMContext::getDRM();
59+
const Drm& drm = sf::priv::DRMContext::getDRM();
6060
drmModeModeInfoPtr ptr = drm.mode;
6161
if (ptr)
6262
return VideoMode({ptr->hdisplay, ptr->vdisplay});

‎src/SFML/Window/DRM/WindowImplDRM.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ WindowImplDRM::~WindowImplDRM()
6161
////////////////////////////////////////////////////////////
6262
WindowHandle WindowImplDRM::getSystemHandle() const
6363
{
64-
Drm& drm = sf::priv::DRMContext::getDRM();
64+
const Drm& drm = sf::priv::DRMContext::getDRM();
6565
return static_cast<WindowHandle>(drm.fileDescriptor);
6666
}
6767

‎src/SFML/Window/EGLCheck.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void eglCheckError(const std::filesystem::path& file, unsigned int line, std::st
4343
{
4444
// Obtain information about the success or failure of the most recent EGL
4545
// function called in the current thread
46-
EGLint errorCode = eglGetError();
46+
const EGLint errorCode = eglGetError();
4747

4848
if (errorCode != EGL_SUCCESS)
4949
{

‎src/SFML/Window/Unix/ClipboardImpl.cpp‎

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ String ClipboardImpl::getStringImpl()
138138
// if UTF-8 is not available) and written to our window property
139139
XConvertSelection(m_display, m_clipboard, (m_utf8String != None) ? m_utf8String : XA_STRING, m_targetProperty, m_window, CurrentTime);
140140

141-
Clock clock;
141+
const Clock clock;
142142

143143
// Wait for a response for up to 1000ms
144144
while (!m_requestResponded && (clock.getElapsedTime().asMilliseconds() < 1000))
@@ -204,7 +204,7 @@ void ClipboardImpl::processEvent(XEvent& windowEvent)
204204
// Notification that the current selection owner
205205
// has responded to our request
206206

207-
XSelectionEvent& selectionEvent = windowEvent.xselection;
207+
const XSelectionEvent& selectionEvent = windowEvent.xselection;
208208

209209
m_clipboardContents.clear();
210210

@@ -222,18 +222,18 @@ void ClipboardImpl::processEvent(XEvent& windowEvent)
222222

223223
// The selection owner should have wrote the selection
224224
// data to the specified window property
225-
int result = XGetWindowProperty(m_display,
226-
m_window,
227-
m_targetProperty,
228-
0,
229-
0x7fffffff,
230-
False,
231-
AnyPropertyType,
232-
&type,
233-
&format,
234-
&items,
235-
&remainingBytes,
236-
&data);
225+
const int result = XGetWindowProperty(m_display,
226+
m_window,
227+
m_targetProperty,
228+
0,
229+
0x7fffffff,
230+
False,
231+
AnyPropertyType,
232+
&type,
233+
&format,
234+
&items,
235+
&remainingBytes,
236+
&data);
237237

238238
if (result == Success)
239239
{
@@ -267,7 +267,7 @@ void ClipboardImpl::processEvent(XEvent& windowEvent)
267267
case SelectionRequest:
268268
{
269269
// Respond to a request for our clipboard contents
270-
XSelectionRequestEvent& selectionRequestEvent = windowEvent.xselectionrequest;
270+
const XSelectionRequestEvent& selectionRequestEvent = windowEvent.xselectionrequest;
271271

272272
// Our reply
273273
XSelectionEvent selectionEvent;
@@ -316,7 +316,7 @@ void ClipboardImpl::processEvent(XEvent& windowEvent)
316316
((m_utf8String == None) && (selectionRequestEvent.target == m_text)))
317317
{
318318
// Respond to a request for conversion to a Latin-1 string
319-
std::string data = m_clipboardContents.toAnsiString();
319+
const std::string data = m_clipboardContents.toAnsiString();
320320

321321
XChangeProperty(m_display,
322322
selectionRequestEvent.requestor,
@@ -343,7 +343,7 @@ void ClipboardImpl::processEvent(XEvent& windowEvent)
343343
{
344344
// Respond to a request for conversion to a UTF-8 string
345345
// or an encoding of our choosing (we always choose UTF-8)
346-
std::basic_string<std::uint8_t> data = m_clipboardContents.toUtf8();
346+
const std::basic_string<std::uint8_t> data = m_clipboardContents.toUtf8();
347347

348348
XChangeProperty(m_display,
349349
selectionRequestEvent.requestor,

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL