fix clang-check warnings

This commit is contained in:
MihailRis 2025-01-01 16:06:44 +03:00
parent 4c23dc6adf
commit 17dcbe98ab
8 changed files with 8 additions and 12 deletions

View File

@ -92,11 +92,11 @@ glm::vec4 Attribute::asColor() const {
throw std::runtime_error("#RRGGBB or #RRGGBBAA required");
}
int a = 255;
int r = (hexchar2int(text[1]) << 4) | hexchar2int(text[2]);
int g = (hexchar2int(text[3]) << 4) | hexchar2int(text[4]);
int b = (hexchar2int(text[5]) << 4) | hexchar2int(text[6]);
int r = (std::max(0, hexchar2int(text[1])) << 4) | hexchar2int(text[2]);
int g = (std::max(0, hexchar2int(text[3])) << 4) | hexchar2int(text[4]);
int b = (std::max(0, hexchar2int(text[5])) << 4) | hexchar2int(text[6]);
if (text.length() == 9) {
a = (hexchar2int(text[7]) << 4) | hexchar2int(text[8]);
a = (std::max(0, hexchar2int(text[7])) << 4) | hexchar2int(text[8]);
}
return glm::vec4(r / 255.f, g / 255.f, b / 255.f, a / 255.f);
} else {

View File

@ -95,8 +95,8 @@ static inline FieldIncapatibilityType checkIncapatibility(
static inline integer_t clamp_value(integer_t value, FieldType type) {
auto typesize = sizeof_type(type) * CHAR_BIT;
integer_t minval = -(1 << (typesize-1));
integer_t maxval = (1 << (typesize-1))-1;
integer_t minval = -(1LL << (typesize-1));
integer_t maxval = (1LL << (typesize-1))-1;
return std::min(maxval, std::max(minval, value));
}

View File

@ -32,7 +32,6 @@ static std::unique_ptr<FontStylesScheme> build_styles(
continue;
}
if (token.start.pos > offset) {
int n = token.start.pos - offset;
styles.map.insert(styles.map.end(), token.start.pos - offset, 0);
}
offset = token.end.pos;

View File

@ -289,8 +289,6 @@ void Hud::updateWorldGenDebugVisualization() {
for (int z = 0; z < height; z++) {
for (int x = 0; x < width; x++) {
int cx = x + ox;
int cz = z + oz;
int flippedZ = height - z - 1;
int ax = x - (width - areaWidth) / 2;

View File

@ -148,7 +148,6 @@ void LevelScreen::saveWorldPreview() {
}
void LevelScreen::updateHotkeys() {
auto player = playerController->getPlayer();
auto& settings = engine.getSettings();
if (Events::jpressed(keycode::O)) {
settings.graphics.frustumCulling.toggle();

View File

@ -1,4 +1,5 @@
#include "Mesh.hpp"
#include <assert.h>
#include <GL/glew.h>
int Mesh::meshesCount = 0;
@ -9,6 +10,7 @@ inline size_t calc_vertex_size(const VertexAttribute* attrs) {
for (int i = 0; attrs[i].size; i++) {
vertexSize += attrs[i].size;
}
assert(vertexSize != 0);
return vertexSize;
}

View File

@ -479,7 +479,6 @@ void PlayerController::updateEntityInteraction(
void PlayerController::updateInteraction(float delta) {
auto indices = level.content.getIndices();
auto chunks = player.chunks.get();
const auto& selection = player.selection;
if (interactionTimer > 0.0f) {

View File

@ -382,7 +382,6 @@ int util::replaceAll(
str.replace(start_pos, from.length(), to);
offset = start_pos + to.length();
count++;
break;
}
return count;
}