Added readability-container-size-empty, readability-isolate-declaration

FIxed Windows escapes for readability-* checks


Fixed Linux DRM readability-isolate-declaration escape


Fixed typo in fix :-|


Fixed clang-format issue
This commit is contained in:
Norm Evangelista 2023-01-15 18:15:34 -08:00 committed by Lukas Dürrenberger
parent a4bca20567
commit 3745ea2336
12 changed files with 70 additions and 28 deletions

View File

@ -5,7 +5,9 @@ Checks: >
modernize-use-equals-default,
modernize-use-equals-delete,
modernize-use-nullptr,
readability-container-size-empty,
readability-identifier-naming,
readability-isolate-declaration,
-clang-analyzer-core.NonNullParamChecker,
-clang-analyzer-core.NullDereference,
-clang-analyzer-nullability.NullablePassedToNonnull,

View File

@ -43,7 +43,8 @@ int main()
return EXIT_FAILURE;
// Ask for user name and password
std::string user, password;
std::string user;
std::string password;
std::cout << "User name: ";
std::cin >> user;
std::cout << "Password: ";
@ -141,7 +142,8 @@ int main()
case 6:
{
// Rename a file
std::string source, destination;
std::string source;
std::string destination;
std::cout << "Name of the file to rename: ";
std::cin >> source;
std::cout << "New name: ";
@ -163,7 +165,8 @@ int main()
case 8:
{
// Download a file from server
std::string filename, directory;
std::string filename;
std::string directory;
std::cout << "Filename of the file to download (relative to current directory): ";
std::cin >> filename;
std::cout << "Directory to download the file to: ";
@ -175,7 +178,8 @@ int main()
case 9:
{
// Upload a file to server
std::string filename, directory;
std::string filename;
std::string directory;
std::cout << "Path of the file to upload (absolute or relative to working directory): ";
std::cin >> filename;
std::cout << "Directory to upload the file to (relative to current directory): ";

View File

@ -389,7 +389,7 @@ public:
for (VkFence fence : fences)
vkWaitForFences(device, 1, &fence, VK_TRUE, std::numeric_limits<std::uint64_t>::max());
if (commandBuffers.size())
if (!commandBuffers.empty())
vkFreeCommandBuffers(device, commandPool, static_cast<std::uint32_t>(commandBuffers.size()), commandBuffers.data());
commandBuffers.clear();

View File

@ -111,7 +111,8 @@ int main()
sf::RenderWindow sfmlView2(view2);
// Load some textures to display
sf::Texture texture1, texture2;
sf::Texture texture1;
sf::Texture texture2;
if (!texture1.loadFromFile("resources/image1.jpg") || !texture2.loadFromFile("resources/image2.jpg"))
return EXIT_FAILURE;
sf::Sprite sprite1(texture1);

View File

@ -92,7 +92,9 @@ bool SoundFileWriterOgg::open(const std::filesystem::path& filename, unsigned in
vorbis_comment_init(&comment);
// Generate the header packets
ogg_packet header, headerComm, headerCode;
ogg_packet header;
ogg_packet headerComm;
ogg_packet headerCode;
status = vorbis_analysis_headerout(&m_state, &comment, &header, &headerComm, &headerCode);
vorbis_comment_clear(&comment);
if (status < 0)

View File

@ -346,7 +346,8 @@ void SoundStream::streamData()
}
else
{
ALint size, bits;
ALint size;
ALint bits;
alCheck(alGetBufferi(buffer, AL_SIZE, &size));
alCheck(alGetBufferi(buffer, AL_BITS, &bits));

View File

@ -483,7 +483,8 @@ EGLDisplay getInitializedDisplay()
eglCheck(display = eglGetDisplay(reinterpret_cast<EGLNativeDisplayType>(gbmDevice)));
EGLint major, minor;
EGLint major;
EGLint minor;
eglCheck(eglInitialize(display, &major, &minor));
gladLoaderLoadEGL(display);

View File

@ -138,7 +138,8 @@ bool CursorImpl::loadFromPixelsMonochrome(const std::uint8_t* pixels, Vector2u s
size.y);
// Define the foreground color as white and the background as black.
XColor fg, bg;
XColor fg;
XColor bg;
fg.red = 0xFFFF;
fg.blue = 0xFFFF;
fg.green = 0xFFFF;

View File

@ -333,7 +333,15 @@ XVisualInfo GlxContext::selectBestVisual(::Display* display, unsigned int bitsPe
continue;
// Extract the components of the current visual
int red, green, blue, alpha, depth, stencil, multiSampling, samples, sRgb;
int red;
int green;
int blue;
int alpha;
int depth;
int stencil;
int multiSampling;
int samples;
int sRgb;
glXGetConfig(display, &visuals[i], GLX_RED_SIZE, &red);
glXGetConfig(display, &visuals[i], GLX_GREEN_SIZE, &green);
glXGetConfig(display, &visuals[i], GLX_BLUE_SIZE, &blue);
@ -402,7 +410,11 @@ XVisualInfo GlxContext::selectBestVisual(::Display* display, unsigned int bitsPe
void GlxContext::updateSettingsFromVisualInfo(XVisualInfo* visualInfo)
{
// Update the creation settings from the chosen format
int depth, stencil, multiSampling, samples, sRgb;
int depth;
int stencil;
int multiSampling;
int samples;
int sRgb;
glXGetConfig(m_display, visualInfo, GLX_DEPTH_SIZE, &depth);
glXGetConfig(m_display, visualInfo, GLX_STENCIL_SIZE, &stencil);

View File

@ -194,9 +194,12 @@ bool InputImpl::isMouseButtonPressed(Mouse::Button button)
Display* display = openDisplay();
// we don't care about these but they are required
::Window root, child;
int wx, wy;
int gx, gy;
::Window root;
::Window child;
int wx;
int wy;
int gx;
int gy;
unsigned int buttons = 0;
XQueryPointer(display, DefaultRootWindow(display), &root, &child, &gx, &gy, &wx, &wy, &buttons);
@ -230,8 +233,10 @@ Vector2i InputImpl::getMousePosition()
Display* display = openDisplay();
// we don't care about these but they are required
::Window root, child;
int x, y;
::Window root;
::Window child;
int x;
int y;
unsigned int buttons;
int gx = 0;
@ -255,8 +260,10 @@ Vector2i InputImpl::getMousePosition(const WindowBase& relativeTo)
Display* display = openDisplay();
// we don't care about these but they are required
::Window root, child;
int gx, gy;
::Window root;
::Window child;
int gx;
int gy;
unsigned int buttons;
int x = 0;

View File

@ -286,7 +286,8 @@ bool ewmhSupported()
// Get the parent window.
::Window getParentWindow(::Display* disp, ::Window win)
{
::Window root, parent;
::Window root;
::Window parent;
::Window* children = nullptr;
unsigned int numChildren;
@ -858,7 +859,8 @@ Vector2i WindowImplX11::getPosition() const
// go using setPosition() and XMoveWindow(). To have the two match
// as expected, we may have to subtract decorations and borders.
::Window child;
int xAbsRelToRoot, yAbsRelToRoot;
int xAbsRelToRoot;
int yAbsRelToRoot;
XTranslateCoordinates(m_display, m_window, DefaultRootWindow(m_display), 0, 0, &xAbsRelToRoot, &yAbsRelToRoot, &child);
@ -871,7 +873,8 @@ Vector2i WindowImplX11::getPosition() const
// CASE 2: most modern WMs support EWMH and can define _NET_FRAME_EXTENTS
// with the exact frame size to subtract, so if present, we prefer it and
// query it first. According to spec, this already includes any borders.
long xFrameExtent, yFrameExtent;
long xFrameExtent;
long yFrameExtent;
if (getEWMHFrameExtents(m_display, m_window, xFrameExtent, yFrameExtent))
{
@ -904,8 +907,12 @@ Vector2i WindowImplX11::getPosition() const
// Get final X/Y coordinates: take the relative position to
// the root of the furthest ancestor window.
int xRelToRoot, yRelToRoot;
unsigned int width, height, borderWidth, depth;
int xRelToRoot;
int yRelToRoot;
unsigned int width;
unsigned int height;
unsigned int borderWidth;
unsigned int depth;
XGetGeometry(m_display, ancestor, &root, &xRelToRoot, &yRelToRoot, &width, &height, &borderWidth, &depth);
@ -1331,7 +1338,8 @@ void WindowImplX11::setVideoMode(const VideoMode& mode)
return;
// Check if the XRandR extension is present
int xRandRMajor, xRandRMinor;
int xRandRMajor;
int xRandRMinor;
if (!checkXRandR(xRandRMajor, xRandRMinor))
{
// XRandR extension is not supported: we cannot use fullscreen mode
@ -1426,7 +1434,8 @@ void WindowImplX11::resetVideoMode()
{
// Try to set old configuration
// Check if the XRandR extension
int xRandRMajor, xRandRMinor;
int xRandRMajor;
int xRandRMinor;
if (checkXRandR(xRandRMajor, xRandRMinor))
{
XRRScreenResources* res = XRRGetScreenResources(m_display, DefaultRootWindow(m_display));
@ -2215,7 +2224,8 @@ Vector2i WindowImplX11::getPrimaryMonitorPosition()
}
// Get xRandr version
int xRandRMajor, xRandRMinor;
int xRandRMajor;
int xRandRMinor;
if (!checkXRandR(xRandRMajor, xRandRMinor))
xRandRMajor = xRandRMinor = 0;

View File

@ -428,7 +428,8 @@ void WindowImplWin32::setKeyRepeatEnabled(bool enabled)
void WindowImplWin32::requestFocus()
{
// Allow focus stealing only within the same process; compare PIDs of current and foreground window
DWORD thisPid, foregroundPid;
DWORD thisPid;
DWORD foregroundPid;
GetWindowThreadProcessId(m_handle, &thisPid);
GetWindowThreadProcessId(GetForegroundWindow(), &foregroundPid);