17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-17 03:59:19 +02:00

refactor(sonar): use std::array for local fixed-size arrays (cpp:S5945)

Arrays that are class members or part of headers are left unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jerrrrycho
2026-10-10 17:44:14 +02:00
parent 312ba58ffa
commit 43fcda05a0
12 changed files with 74 additions and 74 deletions

View File

@@ -3,7 +3,7 @@
GLenum gl::buffer::glenum_target(gl::buffer::targets target)
{
static GLenum mapping[13] =
static std::array<GLenum, 13> const mapping =
{
GL_ARRAY_BUFFER,
GL_ATOMIC_COUNTER_BUFFER,

View File

@@ -90,17 +90,17 @@ void gl::framebuffer::blit(framebuffer const *src, framebuffer const *dst, int s
int attachment_n = attachment - GL_COLOR_ATTACHMENT0;
{
GLenum outputs[8] = { GL_NONE };
std::array<GLenum, 8> outputs{ GL_NONE };
outputs[attachment_n] = src != nullptr ? attachment : GL_BACK_LEFT;
glReadBuffer(attachment);
}
{
GLenum outputs[8] = { GL_NONE };
std::array<GLenum, 8> outputs{ GL_NONE };
outputs[attachment_n] = dst != nullptr ? attachment : GL_BACK_LEFT;
glDrawBuffers(attachment_n + 1, outputs);
glDrawBuffers(attachment_n + 1, outputs.data());
}
}

View File

@@ -51,7 +51,7 @@ std::optional<int64_t> gl::query::result()
GLenum gl::query::glenum_target(targets Target) const
{
static GLenum mapping[6] =
static std::array<GLenum, 6> const mapping =
{
GL_SAMPLES_PASSED,
GL_ANY_SAMPLES_PASSED,

View File

@@ -318,11 +318,11 @@ gl::shader::shader(const std::string &filename) : name(filename)
glGetShaderiv(*this, GL_COMPILE_STATUS, &status);
if (!status)
{
GLchar info[512];
glGetShaderInfoLog(*this, 512, nullptr, info);
log_error(std::string(info));
std::array<GLchar, 512> info{};
glGetShaderInfoLog(*this, static_cast<GLsizei>(info.size()), nullptr, info.data());
log_error(std::string(info.data()));
throw shader_exception("failed to compile " + filename + ": " + std::string(info));
throw shader_exception("failed to compile " + filename + ": " + std::string(info.data()));
}
}
@@ -392,9 +392,9 @@ void gl::program::link()
glGetProgramiv(*this, GL_LINK_STATUS, &status);
if (!status)
{
GLchar info[512];
glGetProgramInfoLog(*this, 512, nullptr, info);
throw shader_exception("failed to link program: " + std::string(info));
std::array<GLchar, 512> info{};
glGetProgramInfoLog(*this, static_cast<GLsizei>(info.size()), nullptr, info.data());
throw shader_exception("failed to link program: " + std::string(info.data()));
}
init();