Skip to content

Commit

Permalink
Remove cppcheck-suppress comments
Browse files Browse the repository at this point in the history
cppcheck takes a million years to run on the current codebase,
most of these were farly harmless and/or are no longer flagged by the
current defaults, so this is just annoying and useless noise.
  • Loading branch information
NiLuJe committed May 5, 2024
1 parent d1b5d19 commit e1fb286
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 31 deletions.
2 changes: 0 additions & 2 deletions cutef8/utf8.c
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,6 @@ size_t
size_t cnt;
bool needfree = false;
size_t sz = 512;
// cppcheck-suppress allocaCalled
char* buf = (char*) alloca(sz);
int ret = vsnprintf(buf, sz, fmt, ap);
if (ret < 0) {
Expand All @@ -720,7 +719,6 @@ size_t
needfree = true;
vsnprintf(buf, cnt + 1U, fmt, ap);
}
// cppcheck-suppress allocaCalled
uint32_t* wcs = (uint32_t*) alloca((cnt + 1U) * sizeof(uint32_t));
size_t nc = u8_toucs(wcs, cnt + 1U, buf, cnt);
wcs[nc] = 0;
Expand Down
19 changes: 0 additions & 19 deletions fbink.c
Original file line number Diff line number Diff line change
Expand Up @@ -10395,7 +10395,6 @@ static unsigned char*
temp = NULL;
}

// cppcheck-suppress nullPointerArithmetic ; imgdata can't be NULL
size_t nread = fread(imgdata + used, 1U, CHUNK, stdin);
if (nread == 0U) {
break;
Expand Down Expand Up @@ -10812,7 +10811,6 @@ static int
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wcast-align"
// First, we gobble the full image pixel (all 2 bytes)
// cppcheck-suppress unreadVariable ; false-positive (union)
img_px.p = *((const uint16_t*) (data + img_scanline_offset) + i);
# pragma GCC diagnostic pop

Expand Down Expand Up @@ -10964,7 +10962,6 @@ static int
// 32bpp
FBInkPixel fb_px;
// This is essentially a constant in our case... (c.f., put_pixel_RGB32)
// cppcheck-suppress unreadVariable ; false-positive (union)
fb_px.bgra.color.a = 0xFFu;
for (unsigned short int j = img_y_off; j < max_height; j++) {
for (unsigned short int i = img_x_off; i < max_width; i++) {
Expand All @@ -10976,15 +10973,13 @@ static int
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wcast-align"
// First, we gobble the full image pixel (all 4 bytes)
// cppcheck-suppress unreadVariable ; false-positive (union)
img_px.p = *((const uint32_t*) (data + img_scanline_offset) + i);
# pragma GCC diagnostic pop

// Take a shortcut for the most common alpha values (none & full)
if (img_px.color.a == 0xFFu) {
// Fully opaque, we can blit the image (almost) directly.
// We do need to handle BGR and honor inversion ;).
// cppcheck-suppress unreadVariable ; false-positive (union)
img_px.p ^= invert_32b;
// And software dithering... Not a fan of the extra branching,
// but that's probably the best we can do.
Expand Down Expand Up @@ -11045,7 +11040,6 @@ static int
# pragma GCC diagnostic pop

// Don't forget to honor inversion
// cppcheck-suppress unreadVariable ; false-positive (union)
img_px.p ^= invert_32b;
// Blend it, honoring pixel order (BGR vs. RGB) in the process ;).
if (likely(deviceQuirks.pixelFormat == FBINK_PXFMT_BGRA) ||
Expand Down Expand Up @@ -11111,14 +11105,12 @@ static int
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wcast-align"
// First, we gobble the full image pixel (all 4 bytes)
// cppcheck-suppress unreadVariable ; false-positive (union)
img_px.p = *((const uint32_t*) (data + img_scanline_offset) + i);
# pragma GCC diagnostic pop

// Take a shortcut for the most common alpha values (none & full)
if (img_px.color.a == 0xFFu) {
// Fully opaque, we can blit the image (almost) directly.
// cppcheck-suppress unreadVariable ; false-positive (union)
img_px.p ^= invert_32b;
// We do need to handle BGR and honor inversion ;).
if (likely(deviceQuirks.pixelFormat == FBINK_PXFMT_BGR24)) {
Expand Down Expand Up @@ -11169,7 +11161,6 @@ static int
bg_px.rgb24 = *((uint24_t*) (fbPtr + fb_pix_offset));

// Don't forget to honor inversion
// cppcheck-suppress unreadVariable ; false-positive (union)
img_px.p ^= invert_32b;
// Blend it, we get our BGR swap in the process ;).
if (likely(deviceQuirks.pixelFormat == FBINK_PXFMT_BGR24)) {
Expand Down Expand Up @@ -11228,7 +11219,6 @@ static int
// 32bpp
FBInkPixel fb_px;
// This is essentially a constant in our case...
// cppcheck-suppress unreadVariable ; false-positive (union)
fb_px.bgra.color.a = 0xFFu;
for (unsigned short int j = img_y_off; j < max_height; j++) {
for (unsigned short int i = img_x_off; i < max_width; i++) {
Expand All @@ -11247,18 +11237,12 @@ static int
if (likely(deviceQuirks.pixelFormat == FBINK_PXFMT_BGRA) ||
likely(deviceQuirks.pixelFormat == FBINK_PXFMT_BGR32)) {
if (fbink_cfg->sw_dithering) {
// cppcheck-suppress unreadVariable ; false-positive (union)
fb_px.bgra.color.r = dither_o8x8(i, j, img_px.color.r);
// cppcheck-suppress unreadVariable ; false-positive (union)
fb_px.bgra.color.g = dither_o8x8(i, j, img_px.color.g);
// cppcheck-suppress unreadVariable ; false-positive (union)
fb_px.bgra.color.b = dither_o8x8(i, j, img_px.color.b);
} else {
// cppcheck-suppress unreadVariable ; false-positive (union)
fb_px.bgra.color.r = img_px.color.r;
// cppcheck-suppress unreadVariable ; false-positive (union)
fb_px.bgra.color.g = img_px.color.g;
// cppcheck-suppress unreadVariable ; false-positive (union)
fb_px.bgra.color.b = img_px.color.b;
}
// NOTE: The RGB -> BGR dance precludes us from simply doing a 3 bytes memcpy,
Expand All @@ -11267,11 +11251,8 @@ static int
// fb_px.p = 0xFF<<24U | img_px.color.r<<16U | img_px.color.g<<8U | img_px.color.b;
} else {
if (fbink_cfg->sw_dithering) {
// cppcheck-suppress unreadVariable ; false-positive (union)
fb_px.rgba.color.r = dither_o8x8(i, j, img_px.color.r);
// cppcheck-suppress unreadVariable ; false-positive (union)
fb_px.rgba.color.g = dither_o8x8(i, j, img_px.color.g);
// cppcheck-suppress unreadVariable ; false-positive (union)
fb_px.rgba.color.b = dither_o8x8(i, j, img_px.color.b);
} else {
// Same pixel order
Expand Down
1 change: 0 additions & 1 deletion fbink_device_id.c
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,6 @@ static void

// We'll read the full payload, whose size varies depending on the exact kernel being used...
// Since it's only a couple dozen bytes, do that on the stack to make our life easier.
// cppcheck-suppress allocaCalled
payload = alloca(config.len); // lgtm [cpp/uncontrolled-allocation-size]
if (fread(payload, sizeof(*payload), config.len, fp) < config.len || ferror(fp) != 0) {
WARN("Error reading NTX HWConfig payload (unexpected length)");
Expand Down
4 changes: 0 additions & 4 deletions utils/doom.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,11 +520,8 @@ static void
const size_t dst = offset - random + 1U;
const unsigned int pal_idx = find_palette_id_32(px.bgra.color.r, px.bgra.color.g, px.bgra.color.b);
const size_t idx = pal_idx - (random & 1U);
// cppcheck-suppress unreadVariable ; false-positive (union)
px.bgra.color.r = fire_colors[idx][0U];
// cppcheck-suppress unreadVariable ; false-positive (union)
px.bgra.color.g = fire_colors[idx][1U];
// cppcheck-suppress unreadVariable ; false-positive (union)
px.bgra.color.b = fire_colors[idx][2U];
*((uint32_t*) (fbPtr + dst - fInfo.line_length)) = px.p;
}
Expand Down Expand Up @@ -790,7 +787,6 @@ int
#ifndef FBINK_FOR_LINUX
# ifndef FBINK_FOR_KINDLE
// If the automagic Portrait rotation was requested, compute it
// cppcheck-suppress knownConditionTrueFalse ; true, kept to mirror fbdepth
if (req_rota == -1) {
// NOTE: For *most* devices, Nickel's Portrait orientation should *always* match BootRota + 1
// Thankfully, the Libra appears to be ushering in a new era filled with puppies and rainbows,
Expand Down
5 changes: 0 additions & 5 deletions utils/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ int

// Restore, this time with a negative L + T crop
fprintf(stdout, "[06b-] RESTORE w/ (-) L+T CROP\n");
// cppcheck-suppress redundantAssignment ; true, but the previous clear is kept for clarity
dump.clip = dump.area;
dump.clip.left = (unsigned short int) MAX(0, dump.clip.left - 25);
//dump.clip.width -= 25; // Not strictly necessary, will be computed when building the intersection rectangle
Expand All @@ -207,7 +206,6 @@ int
dump.clip = (const FBInkRect){ 0U };

// Restore, this time with a positive R + B crop
// cppcheck-suppress redundantAssignment ; ditto
dump.clip = dump.area;
dump.clip.width = (unsigned short int) MAX(0, dump.clip.width - 25);
dump.clip.height = (unsigned short int) MAX(0, dump.clip.height - 30);
Expand All @@ -224,7 +222,6 @@ int
dump.clip = (const FBInkRect){ 0U };

// Restore, this time with a negative R + B crop (i.e., the overlap will match the full dump area)
// cppcheck-suppress redundantAssignment ; ditto
dump.clip = dump.area;
dump.clip.width = (unsigned short int) MIN(dump.clip.width + 25U, fbink_state.screen_width);
dump.clip.height = (unsigned short int) MIN(dump.clip.height + 30U, fbink_state.screen_height);
Expand All @@ -241,7 +238,6 @@ int
dump.clip = (const FBInkRect){ 0U };

// Restore, this time with a crop on all sides
// cppcheck-suppress redundantAssignment ; ditto
dump.clip = dump.area;
dump.clip.left = (unsigned short int) MIN(dump.clip.left + 15U, fbink_state.screen_width);
dump.clip.width = (unsigned short int) MAX(0, dump.clip.width - 15);
Expand All @@ -262,7 +258,6 @@ int
dump.clip = (const FBInkRect){ 0U };

// This should fail to restore (no overlap)
// cppcheck-suppress redundantAssignment ; ditto
dump.clip = dump.area;
dump.clip.left =
(unsigned short int) MIN((unsigned short int) (dump.clip.left + dump.area.width), fbink_state.screen_width);
Expand Down

0 comments on commit e1fb286

Please sign in to comment.