Skip to content

Conversation

@finger563
Copy link
Contributor

@finger563 finger563 commented May 1, 2025

Description

  • Add pool allocator component to allow reuse of romdata memory on memory constrained devices
  • Add doom component
  • Work through improvements to other components
  • Make screenshotting using std::span so that we can reuse memory more effecitvely, reducing dynamic memory requirements
  • Update resize script
  • Add doom boxarts
  • Allow box emu to deinitialize memory if desired
  • Expose palette (box-emu) as getter for easier code
  • Update memory card config in box-emu

Motivation and Context

Doom and the associated games are a lot of fun and are open-source so we should try to run them as well :)

They're also more graphically demanding and require more memory so they are a good test of the architecture and the memory management.

Note: doom, like the emulators, had to be heavily modified so that it did not declare a bunch of state variables on the stack (which would go into D/IRAM), but instead are pointers which we can allocate where we like (shared memory in D/IRAM, memory pool in romdata, or regular heap).

How has this been tested?

Build and run main on Box-Emu and Box-3-Emu. Test all the emulators and ensure they work. Test Doom and Ultimate Doom to ensure they work.

Screenshots (if appropriate, e.g. schematic, board, console logs, lab pictures):

doom_test-compressed.mp4

Doom:
image
image
image
Doom II:
image

image
image
image

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update
  • Hardware (schematic, board, system design) change
  • Software change

Checklist:

  • My change requires a change to the documentation.
  • I have added / updated the documentation related to this change via either README or WIKI

Software

  • I have added tests to cover my changes.
  • I have updated the .github/workflows/build.yml file to add my new test to the automated cloud build github action.
  • All new and existing tests passed.
  • My code follows the code style of this project.

…ors without having to (re-)allocate the romdata which can fail. update to use menu mutex and to make images spans instead of vectors for better memory performance
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new doom component along with several improvements to memory management and emulator functionality. Key changes include the addition of multiple doom-related source files, performance‐oriented adjustments to SD card/USB memory allocation parameters in BoxEmu, and an improved interface for palette handling alongside a new pool allocator component.

Reviewed Changes

Copilot reviewed 214 out of 221 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
components/doom/prboom/d_think.h New file providing thinker definitions for Doom.
components/doom/prboom/d_player.h Adds player state structures for Doom gameplay.
components/doom/prboom/d_net.h Implements networking structures and functions for Doom.
components/doom/prboom/d_main.h Adds main startup routines and event handling for Doom.
components/doom/prboom/d_items.h & d_items.c Introduces weapon info and sprite frame definitions.
components/doom/prboom/d_event.h Adds event structures to handle Doom-specific events.
components/doom/prboom/config.h Updates configuration and version information.
components/doom/prboom/am_map.h Implements the automap module for Doom.
components/doom/include/doom.hpp Exposes new API functions for Doom (init, run, video buffer).
components/box-emu/src/box-emu.cpp Updates memory allocation sizes and introduces deinitialization support.
components/box-emu/include/box-emu.hpp Adds pool allocator support and refines palette API.
components/doom/prboom/COPYING Adds the GPL license file.
Files not reviewed (7)
  • CMakeLists.txt: Language not supported
  • boxart/source/resize.bash: Language not supported
  • components/box-emu/CMakeLists.txt: Language not supported
  • components/doom/CMakeLists.txt: Language not supported
  • components/doom/linker.lf: Language not supported
  • components/doom/prboom/AUTHORS: Language not supported
  • components/doom/prboom/CMakeLists.txt: Language not supported
Comments suppressed due to low confidence (2)

components/box-emu/src/box-emu.cpp:117

  • The allocation unit size was reduced from 16 * 1024 to 2 * 1024. This change can improve performance for small file writes but may degrade overall read/write throughput for larger file operations. Please verify that this trade-off meets the desired performance requirements.
mount_config.allocation_unit_size = 2 * 1024;

components/box-emu/src/box-emu.cpp:139

  • The max_transfer_sz parameter has been reduced from 8192 to 4096, which may affect the speed of high-volume data transfers. Consider confirming that the updated value satisfies the performance expectations for the targeted workloads.
bus_cfg.max_transfer_sz = 4096;

@github-actions
Copy link

github-actions bot commented May 1, 2025

⚡ Static analysis result ⚡

🔴 cppcheck found 231 issues! Click here to see details.

esp-box-emu/main/cart.hpp

Lines 300 to 305 in 7a41159

virtual std::string get_paused_image_path() const {
namespace fs = std::filesystem;
auto save_path =
savedir_ + "/paused" +
get_screenshot_extension();
return save_path;

!Line: 300 - style: Virtual function 'get_paused_image_path' is called from constructor 'Cart(const Config&config)' at line 59. Dynamic binding is not used. [virtualCallInConstructor]

!Line: 59 - note: Calling get_paused_image_path
!Line: 300 - note: get_paused_image_path is a virtual function

printf("Num bytes allocated: %d\n", current_offset_);
// TODO: Use SIMD-accelerated memset from ESP32s3 vector instructions
memset(memory_pool_, 0, TOTAL_MEMORY_SIZE);
current_offset_ = 0;
}

!Line: 72 - portability: %d in format string (no. 1) requires 'int' but the argument type is 'size_t {aka unsigned long}'. [invalidPrintfArgType_sint]

int pool_contains(void* ptr) {
return (ptr >= memory_pool && ptr < memory_pool + memory_pool_size);
}
void* pool_alloc(size_t size) {
size = ALIGN4(size);

!Line: 31 - style: Parameter 'ptr' can be declared as pointer to const [constParameterPointer]

int16_t *audioBufferEnd = audioBuffer + AUDIO_BUFFER_LENGTH;
while (audioBuffer < audioBufferEnd) {
int totalSample = 0;
int totalSources = 0;
int sample;

!Line: 246 - style: Variable 'audioBufferEnd' can be declared as pointer to const [constVariablePointer]

return ((unsigned)D_abs(a)>>14) >= (unsigned)D_abs(b) ? ((a^b)>>31) ^ INT_MAX :
(fixed_t)(((int_64_t) a << FRACBITS) / b);
}
#endif /* I386_ASM */

!Line: 203 - error: Shifting signed 32-bit value by 31 bits is undefined behaviour [shiftTooManyBitsSigned]

if ((unsigned)D_abs(a) >> 14 < (unsigned)D_abs(b))
{
fixed_t result;
asm (
" idivl %3 ;"
: "=a" (result)

!Line: 180 - error: Shifting signed 32-bit value by 31 bits is undefined behaviour [shiftTooManyBitsSigned]

return ((a^b)>>31) ^ INT_MAX;
}
# endif /* _MSC_VER */
#else /* I386_ASM */
/* CPhipps - made __inline__ to inline, as specified in the gcc docs

!Line: 193 - error: Shifting signed 32-bit value by 31 bits is undefined behaviour [shiftTooManyBitsSigned]

_s = _t >> (8*sizeof _t-1);
return (_t^_s)-_s;
}
# endif /* I386_ASM */
#else /* _MSC_VER */
#define D_abs(x) ({fixed_t _t = (x), _s = _t >> (8*sizeof _t-1); (_t^_s)-_s;})

!Line: 73 - error: Shifting signed 32-bit value by 31 bits is undefined behaviour [shiftTooManyBitsSigned]

angle_t angle;
angle_t delta;
P_MovePsprites (player);
// fall to the ground

!Line: 255 - style: The scope of the variable 'angle' can be reduced. [variableScope]

angle_t delta;
P_MovePsprites (player);
// fall to the ground

!Line: 256 - style: The scope of the variable 'delta' can be reduced. [variableScope]

weapontype_t newweapon;
if (movement_smooth && players!=NULL && (&players[displayplayer] == player))
{
original_view_vars.viewx = player->mo->x;
original_view_vars.viewy = player->mo->y;

!Line: 312 - style: The scope of the variable 'newweapon' can be reduced. [variableScope]

ticcmd_t *cmd = &player->cmd;
mobj_t *mo = player->mo;
mo->angle += cmd->angleturn << 16;
onground = mo->z <= mo->floorz;

!Line: 197 - style: Variable 'cmd' can be declared as pointer to const [constVariablePointer]

while (runtics--) {
#ifdef HAVE_NET
if (server) CheckQueuedPackets();
#endif
if (advancedemo)
D_DoAdvanceDemo ();

!Line: 493 - style: Condition 'runtics--' is always false [knownConditionTrueFalse]

!Line: 459 - note: Assuming that condition '!runtics' is not redundant
!Line: 493 - note: Condition 'runtics--' is always false

}
if (I_GetTime() - entertime > 10) {
#ifdef HAVE_NET
if (server) {
char buf[sizeof(packet_header_t)+1];
remotesend--;

!Line: 467 - error: syntax error [syntaxError]

int M_CheckParm(const char* p) { p = NULL; return 1; }
int myargc;
char** myargv;
void NORETURN I_Error(const char *error, ...) // killough 3/20/98: add const
{

!Line: 213 - warning: Assignment of function parameter has no effect outside the function. Did you forget dereferencing it? [uselessAssignmentPtrArg]

if (verbose>2) printf("%d requests resend from %d\n", from, ptic(packet));
remoteticto[from] = ptic(packet);
}
break;
case PKT_QUIT:
{

!Line: 573 - warning: %d in format string (no. 2) requires 'int' but the argument type is 'signed long'. [invalidPrintfArgType_sint]

if (verbose) printf("%d quits at %d (%d left)\n", from, ptic(packet),curplayers);
if (ingame && !curplayers) exit(0); // All players have exited
}
}
// Fall through and broadcast it
case PKT_EXTRA:

!Line: 591 - warning: %d in format string (no. 2) requires 'int' but the argument type is 'signed long'. [invalidPrintfArgType_sint]

wadname = realloc(wadname, ++numwads * sizeof *wadname);
wadget = realloc(wadget , numwads * sizeof *wadget );
wadname[numwads-1] = strdup(optarg);
if ((p = strchr(wadname[numwads-1], ','))) {
*p++ = 0; wadget[numwads-1] = p;
} else wadget[numwads-1] = NULL;

!Line: 418 - error: Common realloc mistake: 'wadname' nulled but not freed upon failure [memleakOnRealloc]

wadget = realloc(wadget , numwads * sizeof *wadget );
wadname[numwads-1] = strdup(optarg);
if ((p = strchr(wadname[numwads-1], ','))) {
*p++ = 0; wadget[numwads-1] = p;
} else wadget[numwads-1] = NULL;
}

!Line: 419 - error: Common realloc mistake: 'wadget' nulled but not freed upon failure [memleakOnRealloc]

packet_header_t *reply;
if (badplayer(from) || playerstate[from] != pc_unused) break;
if (verbose) printf("Request for %s ", name);
for (i=0; i<numwads; i++)

!Line: 608 - style: The scope of the variable 'reply' can be reduced. [variableScope]

packet_header_t *packet = malloc(sizeof(packet_header_t));
packet_set(packet, PKT_BACKOFF, remoteticto[i]);
I_SendPacketTo(packet,sizeof *packet,remoteaddr+i);
backoffcounter[i] = 0;
if (verbose) printf("telling client %d to back off\n",i);
free(packet);

!Line: 724 - style: Local variable 'packet' shadows outer variable [shadowVariable]

!Line: 478 - note: Shadowed declaration
!Line: 724 - note: Shadow variable

long int ptic(packet_header_t* p)
{
return doom_ntohl(p->tic);
}

!Line: 311 - style: Parameter 'p' can be declared as pointer to const [constParameterPointer]

ticcmd_t *newtic = (void*)(((byte*)(packet+1))+2);
if (ptic(packet) + tics < remoteticfrom[from]) break; // Won't help
remoteticfrom[from] = ptic(packet);
while (tics--)
netcmds[from][remoteticfrom[from]++%BACKUPTICS] = *newtic++;
}

!Line: 560 - style: Variable 'newtic' can be declared as pointer to const [constVariablePointer]

if ((spot >= column->topdelta) && (spot <= column->topdelta + column->length)) return 1;
column = (const column_t*)((const byte*)column + 3 + column->length + 1);
}
return 0;
}

!Line: 136 - style: Condition 'spot>=column->topdelta' is always true [knownConditionTrueFalse]

!Line: 135 - note: Assuming condition 'spot<column->topdelta' is false
!Line: 136 - note: Condition 'spot>=column->topdelta' is always true

if (1 || patch->isNotTileable) {
const rcolumn_t *column, *prevColumn;
// copy the patch image down and to the right where there are
// holes to eliminate the black halo from bilinear filtering
for (x=0; x<patch->width; x++) {

!Line: 270 - style: Condition '1||patch->isNotTileable' is always true [knownConditionTrueFalse]

if (1 || composite_patch->isNotTileable) {
const rcolumn_t *column, *prevColumn;
// copy the patch image down and to the right where there are
// holes to eliminate the black halo from bilinear filtering
for (x=0; x<composite_patch->width; x++) {

!Line: 582 - style: Condition '1||composite_patch->isNotTileable' is always true [knownConditionTrueFalse]

int x=0, numPosts, lastColumnDelta = 0;
const column_t *column;
int cornerCount = 0;
int hasAHole = 0;
for (x=0; x<SHORT(patch->width); x++) {

!Line: 104 - style: The scope of the variable 'numPosts' can be reduced. [variableScope]

int length;
if ((post2->topdelta - post1->topdelta) < 0)
switchPosts(post1, post2);
if ((post1->topdelta + post1->length) >= post2->topdelta) {

!Line: 563 - style: The scope of the variable 'length' can be reduced. [variableScope]

rpost_t *post2 = &column->posts[i+1];
post1->topdelta = post2->topdelta;
post1->length = post2->length;
post1->slope = post2->slope;
}
column->numPosts--;

!Line: 346 - style: Variable 'post2' can be declared as pointer to const [constVariablePointer]

texpatch_t *texpatch;
int patchNum;
const patch_t *oldPatch;
const column_t *oldColumn, *oldPrevColumn, *oldNextColumn;
int i, x, y;
int oy, count;

!Line: 358 - style: Variable 'texpatch' can be declared as pointer to const [constVariablePointer]

int ret;
if (optreset || !*place) { /* update scanning pointer */
optreset = 0;
if (optind >= nargc || *(place = nargv[optind]) != '-') {
place = EMSG;

!Line: 149 - style: The scope of the variable 'ret' can be reduced. [variableScope]

extern char *__progname;
static char *place = EMSG; /* option letter processing */
char *oli; /* option letter list index */
int ret;
if (optreset || !*place) { /* update scanning pointer */

!Line: 146 - style: Local variable '__progname' shadows outer variable [shadowVariable]

!Line: 134 - note: Shadowed declaration
!Line: 146 - note: Shadow variable

int ok;
// Things that should never trigger lines
if (!thing->player)
{
// Things that should NOT trigger specials...

!Line: 1101 - style: The scope of the variable 'ok' can be reduced. [variableScope]

mobj_t *thing;
case sc_side: // killough 3/7/98: Scroll wall texture
side = sides + s->affectee;
side->textureoffset += dx;
side->rowoffset += dy;

!Line: 2613 - style: The scope of the variable 'thing' can be reduced. [variableScope]

mobj_t *thing;
msecnode_t* node;
if (compatibility || !variable_friction)
return;

!Line: 2849 - style: The scope of the variable 'thing' can be reduced. [variableScope]

angle_t pushangle;
fixed_t speed;
fixed_t sx = tmpusher->x;
fixed_t sy = tmpusher->y;
speed = (tmpusher->magnitude -

!Line: 3099 - style: The scope of the variable 'pushangle' can be reduced. [variableScope]

mobj_t *thing;
msecnode_t* node;
int xspeed,yspeed;
int xl,xh,yl,yh,bx,by;
int radius;
int ht = 0;

!Line: 3148 - style: The scope of the variable 'thing' can be reduced. [variableScope]

int xl,xh,yl,yh,bx,by;
int radius;
int ht = 0;
if (!allow_pushers)
return;

!Line: 3151 - style: The scope of the variable 'xl' can be reduced. [variableScope]

int xl,xh,yl,yh,bx,by;
int radius;
int ht = 0;
if (!allow_pushers)
return;

!Line: 3151 - style: The scope of the variable 'xh' can be reduced. [variableScope]

int xl,xh,yl,yh,bx,by;
int radius;
int ht = 0;
if (!allow_pushers)
return;

!Line: 3151 - style: The scope of the variable 'yl' can be reduced. [variableScope]

int xl,xh,yl,yh,bx,by;
int radius;
int ht = 0;
if (!allow_pushers)
return;

!Line: 3151 - style: The scope of the variable 'yh' can be reduced. [variableScope]

int xl,xh,yl,yh,bx,by;
int radius;
int ht = 0;
if (!allow_pushers)
return;

!Line: 3151 - style: The scope of the variable 'bx' can be reduced. [variableScope]

int xl,xh,yl,yh,bx,by;
int radius;
int ht = 0;
if (!allow_pushers)
return;

!Line: 3151 - style: The scope of the variable 'by' can be reduced. [variableScope]

int radius;
int ht = 0;
if (!allow_pushers)
return;

!Line: 3152 - style: The scope of the variable 'radius' can be reduced. [variableScope]

boolean PUREFUNC P_SectorActive(special_e t, const sector_t *sec)
{
if (demo_compatibility) // return whether any thinker is active
return sec->floordata != NULL || sec->ceilingdata != NULL || sec->lightingdata != NULL;
else
switch (t) // return whether thinker of same type is active

!Line: 948 - style: inconclusive: Function 'P_SectorActive' argument 2 names different: declaration 's' definition 'sec'. [funcArgNamesDifferent]

!Line: 854 - note: Function 'P_SectorActive' argument 2 names different: declaration 's' definition 'sec'.
!Line: 948 - note: Function 'P_SectorActive' argument 2 names different: declaration 's' definition 'sec'.

sector_t* sec )
{
//jff 1/26/98 check unneeded since line->backsector already
//returns NULL if the line is not two sided, and does so from
//the actual two-sidedness of the line, rather than its 2S flag

!Line: 255 - style: Parameter 'sec' can be declared as pointer to const [constParameterPointer]

sector_t* other;
fixed_t floor = sec->floorheight;
for (i=0 ;i < sec->linecount ; i++)
{
check = sec->lines[i];

!Line: 287 - style: Variable 'other' can be declared as pointer to const [constVariablePointer]

sector_t* other;
fixed_t floor = -500*FRACUNIT;
//jff 1/26/98 Fix initial value for floor to not act differently
//in sections of wad that are below -500 units
if (!comp[comp_model]) /* jff 3/12/98 avoid ovf */

!Line: 318 - style: Variable 'other' can be declared as pointer to const [constVariablePointer]

sector_t *other;
int i;
for (i=0 ;i < sec->linecount ; i++)
if ((other = getNextSector(sec->lines[i],sec)) &&
other->floorheight > currentheight)

!Line: 353 - style: Variable 'other' can be declared as pointer to const [constVariablePointer]

sector_t *other;
int i;
for (i=0 ;i < sec->linecount ; i++)
if ((other = getNextSector(sec->lines[i],sec)) &&
other->floorheight < currentheight)

!Line: 388 - style: Variable 'other' can be declared as pointer to const [constVariablePointer]

sector_t *other;
int i;
for (i=0 ;i < sec->linecount ; i++)
if ((other = getNextSector(sec->lines[i],sec)) &&
other->ceilingheight < currentheight)

!Line: 419 - style: Variable 'other' can be declared as pointer to const [constVariablePointer]

sector_t *other;
int i;
for (i=0 ;i < sec->linecount ; i++)
if ((other = getNextSector(sec->lines[i],sec)) &&
other->ceilingheight > currentheight)

!Line: 450 - style: Variable 'other' can be declared as pointer to const [constVariablePointer]

sector_t* other;
fixed_t height = INT_MAX;
/* jff 3/12/98 avoid ovf in height calculations */
if (!comp[comp_model]) height = 32000*FRACUNIT;

!Line: 482 - style: Variable 'other' can be declared as pointer to const [constVariablePointer]

sector_t* other;
fixed_t height = 0;
/* jff 1/26/98 Fix initial value for floor to not act differently
* in sections of wad that are below 0 units
* jff 3/12/98 avoid ovf in height calculations */

!Line: 516 - style: Variable 'other' can be declared as pointer to const [constVariablePointer]

side_t* side;
int i;
sector_t *sec = &sectors[secnum];
if (!comp[comp_model])
minsize = 32000<<FRACBITS; //jff 3/13/98 prevent overflow in height calcs

!Line: 553 - style: Variable 'side' can be declared as pointer to const [constVariablePointer]

sector_t *sec = &sectors[secnum];
if (!comp[comp_model])
minsize = 32000<<FRACBITS; //jff 3/13/98 prevent overflow in height calcs
for (i = 0; i < sec->linecount; i++)

!Line: 555 - style: Variable 'sec' can be declared as pointer to const [constVariablePointer]

side_t* side;
int i;
sector_t *sec = &sectors[secnum];
if (!comp[comp_model])
minsize = 32000<<FRACBITS; //jff 3/13/98 prevent overflow

!Line: 592 - style: Variable 'side' can be declared as pointer to const [constVariablePointer]

sector_t *sec = &sectors[secnum];
if (!comp[comp_model])
minsize = 32000<<FRACBITS; //jff 3/13/98 prevent overflow
// in height calcs
for (i = 0; i < sec->linecount; i++)

!Line: 594 - style: Variable 'sec' can be declared as pointer to const [constVariablePointer]

sector_t* check;
min = max;
for (i=0 ; i < sector->linecount ; i++)
{
line = sector->lines[i];

!Line: 768 - style: Variable 'check' can be declared as pointer to const [constVariablePointer]

( line_t* line,
player_t* player)
{
// does this line special distinguish between skulls and keys?
int skulliscard = (line->special & LockedNKeys)>>LockedNKeysShift;

!Line: 799 - style: Parameter 'line' can be declared as pointer to const [constParameterPointer]

int P_CheckTag(line_t *line)
{
/* tag not zero, allowed, or
* killough 11/98: compatibility option */
if (comp[comp_zerotags] || line->tag)
return 1;

!Line: 978 - style: Parameter 'line' can be declared as pointer to const [constParameterPointer]

void T_Friction(friction_t *f)
{
sector_t *sec;
mobj_t *thing;
msecnode_t* node;

!Line: 2846 - style: Parameter 'f' can be declared as pointer to const. However it seems that 'T_Friction' is a callback function, if 'f' is declared with const you might also need to cast function pointer(s). [constParameterCallback]

!Line: 2832 - note: You might need to cast the function pointer here
!Line: 2846 - note: Parameter 'f' can be declared as pointer to const

fixed_t x = D_abs(l->dx), y = D_abs(l->dy), d;
if (y > x)
d = x, x = y, y = d;
d = FixedDiv(x, finesine[(tantoangle[FixedDiv(y,x) >> DBITS] + ANG90)
>> ANGLETOFINESHIFT]);

!Line: 2711 - error: Shifting signed 32-bit value by 31 bits is undefined behaviour [shiftTooManyBitsSigned]

unsigned key = tolower(*p)-'a'; // convert to 0-31
if (key >= 32) // ignore most non-alpha cheat letters
continue;
c = (c<<5) + key; // shift key into code
m = (m<<5) + 31; // shift 1's into mask
}

!Line: 712 - style: Local variable 'key' shadows outer argument [shadowArgument]

!Line: 677 - note: Shadowed declaration
!Line: 712 - note: Shadow variable

char buf[3];
{
int musnum;
//jff 3/20/98 note: this cheat allowed in netgame/demorecord

!Line: 267 - style: Parameter 'buf' can be declared as const array. However it seems that 'cheat_mus' is a callback function, if 'buf' is declared with const you might also need to cast function pointer(s). [constParameterCallback]

!Line: 114 - note: You might need to cast the function pointer here
!Line: 267 - note: Parameter 'buf' can be declared as const array

static void cheat_clev(char buf[3])
{
int epsd, map;
if (gamemode == commercial)
{

!Line: 423 - style: Parameter 'buf' can be declared as const array. However it seems that 'cheat_clev' is a callback function, if 'buf' is declared with const you might also need to cast function pointer(s). [constParameterCallback]

!Line: 167 - note: You might need to cast the function pointer here
!Line: 423 - note: Parameter 'buf' can be declared as const array

char buf[3];
{
int w = *buf - '1';
if ((w==wp_supershotgun && gamemode!=commercial) || // killough 2/28/98
((w==wp_bfg || w==wp_plasma) && gamemode==shareware))

!Line: 606 - style: Parameter 'buf' can be declared as const array. However it seems that 'cheat_tntweapx' is a callback function, if 'buf' is declared with const you might also need to cast function pointer(s). [constParameterCallback]

!Line: 224 - note: You might need to cast the function pointer here
!Line: 606 - note: Parameter 'buf' can be declared as const array

char buf[1];
{
int a = *buf - '1';
if (*buf == 'b') // Ty 03/27/98 - strings *not* externalized
if ((plyr->backpack = !plyr->backpack))
for (plyr->message = "Backpack Added", a=0 ; a<NUMAMMO ; a++)

!Line: 636 - style: Parameter 'buf' can be declared as const array. However it seems that 'cheat_tntammox' is a callback function, if 'buf' is declared with const you might also need to cast function pointer(s). [constParameterCallback]

!Line: 249 - note: You might need to cast the function pointer here
!Line: 636 - note: Parameter 'buf' can be declared as const array

int tics;
// If the timer is enabled, calculate the time when the timer
// will expire.
if (timer->enabled)

!Line: 155 - style: The scope of the variable 'tics' can be reduced. [variableScope]

int sampval;
// FIXME???
//assert(nsamples < opl_sample_rate);
Chip__GenerateBlock2(opl_chip, nsamples, (int32_t*)mix_buffer);

!Line: 250 - style: The scope of the variable 'sampval' can be reduced. [variableScope]

unsigned int next_callback_time;
unsigned int nsamples;
// Work out the time until the next callback waiting in
// the callback queue must be invoked. We can then fill the

!Line: 286 - style: The scope of the variable 'next_callback_time' can be reduced. [variableScope]

int OPL_Init (unsigned int rate)
{
opl_sample_rate = rate;
opl_paused = 0;
pause_offset = 0;

!Line: 98 - style: inconclusive: Function 'OPL_Init' argument 1 names different: declaration 'port_base' definition 'rate'. [funcArgNamesDifferent]

!Line: 67 - note: Function 'OPL_Init' argument 1 names different: declaration 'port_base' definition 'rate'.
!Line: 98 - note: Function 'OPL_Init' argument 1 names different: declaration 'port_base' definition 'rate'.

void OPL_Render_Samples (void *dest, unsigned buffer_len)
{
unsigned int filled = 0;
short *buffer = (short *) dest;

!Line: 273 - style: inconclusive: Function 'OPL_Render_Samples' argument 2 names different: declaration 'nsamp' definition 'buffer_len'. [funcArgNamesDifferent]

!Line: 115 - note: Function 'OPL_Render_Samples' argument 2 names different: declaration 'nsamp' definition 'buffer_len'.
!Line: 273 - note: Function 'OPL_Render_Samples' argument 2 names different: declaration 'nsamp' definition 'buffer_len'.

int parent_id;
if (queue->num_entries >= MAX_OPL_QUEUE)
{
lprintf (LO_WARN, "OPL_Queue_Push: Exceeded maximum callbacks\n");
return;

!Line: 78 - style: The scope of the variable 'parent_id' can be reduced. [variableScope]

int child1, child2;
int i, next_i;
// Empty?
if (queue->num_entries <= 0)

!Line: 126 - style: The scope of the variable 'child1' can be reduced. [variableScope]

int child1, child2;
int i, next_i;
// Empty?
if (queue->num_entries <= 0)

!Line: 126 - style: The scope of the variable 'child2' can be reduced. [variableScope]

int OPL_Queue_IsEmpty(opl_callback_queue_t *queue)
{
return queue->num_entries == 0;
}
void OPL_Queue_Clear(opl_callback_queue_t *queue)

!Line: 63 - style: Parameter 'queue' can be declared as pointer to const [constParameterPointer]

opl_queue_entry_t *entry;
int child1, child2;
int i, next_i;
// Empty?

!Line: 125 - style: Variable 'entry' can be declared as pointer to const [constVariablePointer]

printf("%i\n", queue->entries[node].time);
PrintQueueNode(queue, node * 2 + 1, depth + 1);
PrintQueueNode(queue, node * 2 + 2, depth + 1);
}

!Line: 230 - warning: %i in format string (no. 1) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]

unsigned int newtime;
int i;
for (i=0; i<MAX_OPL_QUEUE; ++i)
{
time = rand() % 0x10000;

!Line: 253 - style: The scope of the variable 'newtime' can be reduced. [variableScope]

if (iwad->data)
memcpy(&header, iwad->data, sizeof(header));
else if ((fp = fopen(iwad->name, "rb")))
fread(&header, sizeof(header), 1, fp);
else
I_Error("CheckIWAD: Can't open IWAD: %s", iwad->name);

!Line: 576 - warning: Either the condition '!iwad' is redundant or there is possible null pointer dereference: iwad. [nullPointerRedundantCheck]

!Line: 573 - note: Assuming that condition '!iwad' is not redundant
!Line: 576 - note: Null pointer dereference

int i;
const char *cena="ICWEFDA",*pos; //jff 9/3/98 use this for parsing console masks // CPhipps - const char*'s
//jff 9/3/98 get mask for console output filter
if ((p = M_CheckParm ("-cout"))) {
lprintf(LO_DEBUG, "mask for console output: ");

!Line: 659 - style: The scope of the variable 'i' can be reduced. [variableScope]

const char *cena="ICWEFDA",*pos; //jff 9/3/98 use this for parsing console masks // CPhipps - const char*'s
//jff 9/3/98 get mask for console output filter
if ((p = M_CheckParm ("-cout"))) {
lprintf(LO_DEBUG, "mask for console output: ");
if (++p != myargc && *myargv[p] != '-')

!Line: 660 - style: The scope of the variable 'pos' can be reduced. [variableScope]

memcpy(fileinfo, iwad->data + header.infotableofs, sizeof(filelump_t) * length);
else if (fseek(fp, header.infotableofs, SEEK_SET) == 0)
fread(fileinfo, sizeof(filelump_t), length, fp);
else
I_Error("CheckIWAD: Can't read IWAD: %s", iwad->name);

!Line: 596 - portability: 'iwad->data' is of type 'const void *'. When using void pointers in calculations, the behaviour is undefined. [arithOperationsOnVoidPointer]

viewangleoffset = (8-viewangleoffset) * ANG45;
}
// init subsystems
G_ReloadDefaults(); // killough 3/4/98: set defaults just loaded.

!Line: 878 - error: Signed integer overflow for expression '(8-viewangleoffset)*0x20000000'. [integerOverflow]

!Line: 877 - note: Assignment 'viewangleoffset=viewangleoffset<0?0:(viewangleoffset>7?7:viewangleoffset)', assigned value is 0
!Line: 878 - note: Integer overflow

self->chan[ 0].fourMask = 0x00 | ( 1 << 0 );
self->chan[ 1].fourMask = 0x80 | ( 1 << 0 );
self->chan[ 2].fourMask = 0x00 | ( 1 << 1 );
self->chan[ 3].fourMask = 0x80 | ( 1 << 1 );
self->chan[ 4].fourMask = 0x00 | ( 1 << 2 );
self->chan[ 5].fourMask = 0x80 | ( 1 << 2 );

!Line: 1400 - style: Operator '|' with one operand equal to zero is redundant. [badBitmaskCheck]

self->chan[ 2].fourMask = 0x00 | ( 1 << 1 );
self->chan[ 3].fourMask = 0x80 | ( 1 << 1 );
self->chan[ 4].fourMask = 0x00 | ( 1 << 2 );
self->chan[ 5].fourMask = 0x80 | ( 1 << 2 );
self->chan[ 9].fourMask = 0x00 | ( 1 << 3 );

!Line: 1402 - style: Operator '|' with one operand equal to zero is redundant. [badBitmaskCheck]

self->chan[ 4].fourMask = 0x00 | ( 1 << 2 );
self->chan[ 5].fourMask = 0x80 | ( 1 << 2 );
self->chan[ 9].fourMask = 0x00 | ( 1 << 3 );
self->chan[10].fourMask = 0x80 | ( 1 << 3 );
self->chan[11].fourMask = 0x00 | ( 1 << 4 );

!Line: 1404 - style: Operator '|' with one operand equal to zero is redundant. [badBitmaskCheck]

self->chan[ 9].fourMask = 0x00 | ( 1 << 3 );
self->chan[10].fourMask = 0x80 | ( 1 << 3 );
self->chan[11].fourMask = 0x00 | ( 1 << 4 );
self->chan[12].fourMask = 0x80 | ( 1 << 4 );
self->chan[13].fourMask = 0x00 | ( 1 << 5 );
self->chan[14].fourMask = 0x80 | ( 1 << 5 );

!Line: 1407 - style: Operator '|' with one operand equal to zero is redundant. [badBitmaskCheck]

self->chan[11].fourMask = 0x00 | ( 1 << 4 );
self->chan[12].fourMask = 0x80 | ( 1 << 4 );
self->chan[13].fourMask = 0x00 | ( 1 << 5 );
self->chan[14].fourMask = 0x80 | ( 1 << 5 );
//mark the percussion channels

!Line: 1409 - style: Operator '|' with one operand equal to zero is redundant. [badBitmaskCheck]

self->chan[13].fourMask = 0x00 | ( 1 << 5 );
self->chan[14].fourMask = 0x80 | ( 1 << 5 );
//mark the percussion channels
self->chan[ 6].fourMask = 0x40;
self->chan[ 7].fourMask = 0x40;

!Line: 1411 - style: Operator '|' with one operand equal to zero is redundant. [badBitmaskCheck]

Bit8u synth;
Bit8u change = val ^ self->regC0;
if ( !change )
return;
self->regC0 = val;
self->feedback = ( val >> 1 ) & 7;

!Line: 783 - style: The scope of the variable 'synth' can be reduced. [variableScope]

Bit32s original, guessAdd, bestAdd, bestDiff;
Bit32u passes;
EnvelopeSelect( (Bit8u) i, &index, &shift );
//Original amount of samples the attack would take
original = (Bit32u)( (AttackSamplesTable[ index ] << shift) / scale);

!Line: 1345 - style: Local variable 'original' shadows outer variable [shadowVariable]

!Line: 1304 - note: Shadowed declaration
!Line: 1345 - note: Shadow variable

static inline int Operator__Silent(Operator *self) {
if ( !ENV_SILENT( self->totalLevel + self->volume ) )
return FALSE;
if ( !(self->rateZero & ( 1 << self->state ) ) )
return FALSE;
return TRUE;

!Line: 583 - style: Parameter 'self' can be declared as pointer to const [constParameterPointer]

Channel* chan0, *chan1;
//Check if it's the 2nd channel in a 4-op
if ( !(self->fourMask & 0x80 ) ) {
chan0 = self;
chan1 = self + 1;
} else {

!Line: 799 - style: Variable 'chan1' can be declared as pointer to const [constVariablePointer]

Bit32u Chip__WriteAddr(Chip *self, Bit32u port, Bit8u val ) {
switch ( port & 3 ) {
case 0:
return val;
case 2:
if ( self->opl3Active || (val == 0x05) )

!Line: 1256 - style: Parameter 'self' can be declared as pointer to const [constParameterPointer]

int EV_StopPlat(line_t* line)
{
platlist_t *pl;
for (pl=activeplats; pl; pl=pl->next) // search the active plats
{
plat_t *plat = pl->plat; // for one with the tag not in stasis

!Line: 368 - style: Parameter 'line' can be declared as pointer to const [constParameterPointer]

void P_AddActiveCeiling(ceiling_t* ceiling)
{
ceilinglist_t *list = Z_Malloc(sizeof(*list), PU_STATIC, 0);
list->ceiling = ceiling;
ceiling->list = list;
if ((list->next = activeceilings))

!Line: 428 - style: inconclusive: Function 'P_AddActiveCeiling' argument 1 names different: declaration 'c' definition 'ceiling'. [funcArgNamesDifferent]

!Line: 1134 - note: Function 'P_AddActiveCeiling' argument 1 names different: declaration 'c' definition 'ceiling'.
!Line: 428 - note: Function 'P_AddActiveCeiling' argument 1 names different: declaration 'c' definition 'ceiling'.

int P_ActivateInStasisCeiling(line_t *line)
{
ceilinglist_t *cl;
int rtn=0;
for (cl=activeceilings; cl; cl=cl->next)

!Line: 374 - style: Parameter 'line' can be declared as pointer to const [constParameterPointer]

int EV_CeilingCrushStop(line_t* line)
{
int rtn=0;
ceilinglist_t *cl;
for (cl=activeceilings; cl; cl=cl->next)

!Line: 401 - style: Parameter 'line' can be declared as pointer to const [constParameterPointer]

void P_SetupPsprites(player_t *player)
{
int i;
// remove all psprites
for (i=0; i<NUMPSPRITES; i++)

!Line: 796 - style: inconclusive: Function 'P_SetupPsprites' argument 1 names different: declaration 'curplayer' definition 'player'. [funcArgNamesDifferent]

!Line: 91 - note: Function 'P_SetupPsprites' argument 1 names different: declaration 'curplayer' definition 'player'.
!Line: 796 - note: Function 'P_SetupPsprites' argument 1 names different: declaration 'curplayer' definition 'player'.

void P_MovePsprites(player_t *player)
{
pspdef_t *psp = player->psprites;
int i;
// a null state means not active

!Line: 814 - style: inconclusive: Function 'P_MovePsprites' argument 1 names different: declaration 'curplayer' definition 'player'. [funcArgNamesDifferent]

!Line: 92 - note: Function 'P_MovePsprites' argument 1 names different: declaration 'curplayer' definition 'player'.
!Line: 814 - note: Function 'P_MovePsprites' argument 1 names different: declaration 'curplayer' definition 'player'.

int P_SwitchWeapon(player_t *player)
{
int currentweapon = player->readyweapon;
int newweapon = currentweapon;
for (int i = 0; i < NUMWEAPONS+1 && newweapon == currentweapon; ++i)

!Line: 156 - style: Parameter 'player' can be declared as pointer to const [constParameterPointer]

void A_FireCGun(player_t *player, pspdef_t *psp)
{
if (player->ammo[weaponinfo[player->readyweapon].ammo] || comp[comp_sound])
S_StartSound(player->mo, sfx_pistol);
if (!player->ammo[weaponinfo[player->readyweapon].ammo])

!Line: 714 - style: Parameter 'psp' can be declared as pointer to const [constParameterPointer]

if (angle - player->mo->angle < -ANG90/20)
player->mo->angle = angle + ANG90/21;
else
player->mo->angle -= ANG90/20;
} else {
if (angle - player->mo->angle > ANG90/20)

!Line: 553 - error: Signed integer overflow for expression '-0x40000000/20'. [integerOverflow]

sscanf(strparm+2, "%x", &parm);
} else {
sscanf(strparm, "%i", &parm);
}
for (i = 0 ; i < numdefaults ; i++)

!Line: 742 - warning: %x in format string (no. 1) requires 'unsigned int *' but the argument type is 'signed int *'. [invalidScanfArgType_int]

if (fscanf (f, "%79s %[^\n]\n", def, strparm) != 2)
continue;
if (!isalnum(def[0]))
continue;

!Line: 730 - warning: fscanf() without field width limits can crash with huge input data. [invalidscanf]

int i = M_CheckParm ("-config");
if (i && i < myargc-1)
configfile = myargv[i+1];
else {
const char *exedir = I_DoomExeDir();
configfile = strcat(strcpy(malloc(strlen(exedir) + 32), exedir), "/prboom.cfg");

!Line: 708 - style: inconclusive: Statements following 'return' will never be executed. [unreachableCode]

boolean M_WriteFile(char const *name, void *source, int length)
{
FILE *fp;
errno = 0;

!Line: 79 - style: Parameter 'source' can be declared as pointer to const [constParameterPointer]

void lprintf(OutputLevels lvl, const char *s, ...)
{
if (lvl & cons_output_mask)
{
va_list arg;
va_start(arg, s);

!Line: 52 - style: inconclusive: Function 'lprintf' argument 1 names different: declaration 'pri' definition 'lvl'. [funcArgNamesDifferent]

!Line: 48 - note: Function 'lprintf' argument 1 names different: declaration 'pri' definition 'lvl'.
!Line: 52 - note: Function 'lprintf' argument 1 names different: declaration 'pri' definition 'lvl'.

void lprintf(OutputLevels lvl, const char *s, ...)
{
if (lvl & cons_output_mask)
{
va_list arg;
va_start(arg, s);

!Line: 52 - style: inconclusive: Function 'lprintf' argument 2 names different: declaration 'fmt' definition 's'. [funcArgNamesDifferent]

!Line: 48 - note: Function 'lprintf' argument 2 names different: declaration 'fmt' definition 's'.
!Line: 52 - note: Function 'lprintf' argument 2 names different: declaration 'fmt' definition 's'.

elevator_e elevtype )
{
int secnum;
int rtn;
sector_t* sec;
elevator_t* elevator;

!Line: 968 - style: inconclusive: Function 'EV_DoElevator' argument 2 names different: declaration 'type' definition 'elevtype'. [funcArgNamesDifferent]

!Line: 960 - note: Function 'EV_DoElevator' argument 2 names different: declaration 'type' definition 'elevtype'.
!Line: 968 - note: Function 'EV_DoElevator' argument 2 names different: declaration 'type' definition 'elevtype'.

side_t* side;
/* jff 3/13/98 no ovf */
if (!comp[comp_model]) minsize = 32000<<FRACBITS;
floor->direction = 1;
floor->sector = sec;

!Line: 568 - style: Variable 'side' can be declared as pointer to const [constVariablePointer]

sector_t* secm;
secnum = -1;
rtn = 0;
// change all sectors with the same tag as the linedef
while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0)

!Line: 655 - style: Variable 'secm' can be declared as pointer to const [constVariablePointer]

(line_t* l, int start, int min)
{
/* Emulate original Doom's linear lower-bounded P_FindSectorFromLineTag
* as needed */
do {
start = P_FindSectorFromLineTag(l,start);

!Line: 714 - style: Parameter 'l' can be declared as pointer to const [constParameterPointer]

int EV_DoDonut(line_t* line)
{
sector_t* s1;
sector_t* s2;
sector_t* s3;
int secnum;

!Line: 879 - style: Parameter 'line' can be declared as pointer to const [constParameterPointer]

sector_t* s3;
int secnum;
int rtn;
int i;
floormove_t* floor;

!Line: 883 - style: Variable 's3' can be declared as pointer to const [constVariablePointer]

lastpos = sector->ceilingheight;
sector->ceilingheight += speed;
flag = P_CheckSector(sector,crush); //jff 3/19/98 use faster chk
}
break;
}

!Line: 211 - style: Variable 'lastpos' is assigned a value that is never used. [unreadVariable]

flag = P_CheckSector(sector,crush); //jff 3/19/98 use faster chk
}
break;
}
break;
}

!Line: 213 - style: Variable 'flag' is assigned a value that is never used. [unreadVariable]

int i;
if (!movement_smooth)
return;
if (didInterp)

!Line: 320 - style: The scope of the variable 'i' can be reduced. [variableScope]

static void R_StopInterpolation(interpolation_type_e type, void *posptr)
{
int i;
if (!movement_smooth)
return;

!Line: 258 - style: Parameter 'posptr' can be declared as pointer to const [constParameterPointer]

memcpy(dest, wad->data + offset, size);
return size;
}
else if (wad->handle)
{
fseek(wad->handle, offset, SEEK_SET);

!Line: 402 - portability: 'wad->data' is of type 'const void *'. When using void pointers in calculations, the behaviour is undefined. [arithOperationsOnVoidPointer]

return l->wadfile->data + l->position;
W_ReadLump(Z_Malloc(W_LumpLength(lump), PU_STATIC, &l->ptr), lump);
l->locks = 0;
}
if (++l->locks == 1)

!Line: 457 - portability: 'l->wadfile->data' is of type 'const void *'. When using void pointers in calculations, the behaviour is undefined. [arithOperationsOnVoidPointer]

targheight<<=FRACBITS;
break;
case Cby24:
targheight = ceiling->sector->ceilingheight +
ceiling->direction * 24*FRACUNIT;
break;

!Line: 375 - portability: Shifting a negative value is technically undefined behaviour [shiftNegativeLHS]

sector_t *sec;
//jff 5/23/98 find model with ceiling at target height if target
//is a ceiling type
sec = (Targ==FtoLnC || Targ==FtoC)?
P_FindModelCeilingSector(floor->floordestheight,secnum) :

!Line: 189 - style: Local variable 'sec' shadows outer variable [shadowVariable]

!Line: 66 - note: Shadowed declaration
!Line: 189 - note: Shadow variable

sector_t *sec;
//jff 5/23/98 find model with floor at target height if target
//is a floor type
sec = (Targ==CtoHnF || Targ==CtoF)?
P_FindModelFloorSector(targheight,secnum) :

!Line: 396 - style: Local variable 'sec' shadows outer variable [shadowVariable]

!Line: 269 - note: Shadowed declaration
!Line: 396 - note: Shadow variable

sector_t *sec;
//jff 5/23/98 find model with ceiling at target height if target
//is a ceiling type
sec = (Targ==FtoLnC || Targ==FtoC)?
P_FindModelCeilingSector(floor->floordestheight,secnum) :

!Line: 189 - style: Variable 'sec' can be declared as pointer to const [constVariablePointer]

sector_t *sec;
//jff 5/23/98 find model with floor at target height if target
//is a floor type
sec = (Targ==CtoHnF || Targ==CtoF)?
P_FindModelFloorSector(targheight,secnum) :

!Line: 396 - style: Variable 'sec' can be declared as pointer to const [constVariablePointer]

dcvars.translation = translationtables - 256 +
((vis->mobjflags & MF_TRANSLATION) >> (MF_TRANSSHIFT-8) );
}
else
if (vis->mobjflags & MF_TRANSLUCENT && general_translucency) // phares
{

!Line: 408 - portability: Undefined behaviour, pointer arithmetic 'translationtables-256' is out of bounds. [pointerOutOfBounds]

int topscreen;
int bottomscreen;
fixed_t basetexturemid = dcvars->texturemid;
dcvars->texheight = patch->height; // killough 11/98
for (i=0; i<column->numPosts; i++) {

!Line: 329 - style: The scope of the variable 'topscreen' can be reduced. [variableScope]

int bottomscreen;
fixed_t basetexturemid = dcvars->texturemid;
dcvars->texheight = patch->height; // killough 11/98
for (i=0; i<column->numPosts; i++) {
const rpost_t *post = &column->posts[i];

!Line: 330 - style: The scope of the variable 'bottomscreen' can be reduced. [variableScope]

int texturecolumn;
fixed_t frac;
const rpatch_t *patch = R_CachePatchNum(vis->patch+firstspritelump);
R_DrawColumn_f colfunc;
draw_column_vars_t dcvars;
enum draw_filter_type_e filter;

!Line: 377 - style: The scope of the variable 'texturecolumn' can be reduced. [variableScope]

register lumpinfo_t *lump = lumpinfo + j + firstspritelump;
// Fast portable comparison -- killough
// (using int pointer cast is nonportable):
if (!((lump->name[0] ^ spritename[0]) |

!Line: 194 - style: Variable 'lump' can be declared as pointer to const [constVariablePointer]

static void R_DrawVisSprite(vissprite_t *vis, int x1, int x2)
{
int texturecolumn;
fixed_t frac;
const rpatch_t *patch = R_CachePatchNum(vis->patch+firstspritelump);
R_DrawColumn_f colfunc;

!Line: 375 - style: Parameter 'vis' can be declared as pointer to const [constParameterPointer]

if (D_abs(tx)>(tz<<2))
return;
// decide which patch to use for sprite relative to player
#ifdef RANGECHECK
if ((unsigned) thing->sprite >= (unsigned)numsprites)

!Line: 504 - error: Shifting signed 32-bit value by 31 bits is undefined behaviour [shiftTooManyBitsSigned]

if (side > 0) {
for (i = (SCREENHEIGHT - ST_SCALED_HEIGHT); i < SCREENHEIGHT; i++)
{
R_VideoErase (0, i, side);
R_VideoErase (ST_SCALED_WIDTH+side, i, side);
}

!Line: 1110 - style: Condition 'side>0' is always false [knownConditionTrueFalse]

!Line: 1108 - note: Assignment 'side=(SCREENWIDTH-SCREENWIDTH)/2', assigned value is 0
!Line: 1110 - note: Condition 'side>0' is always false

static void R_DRAWSPAN_FUNCNAME(draw_span_vars_t *dsvars)
{
#if (R_DRAWSPAN_PIPELINE & (RDC_ROUNDED|RDC_BILINEAR))
// drop back to point filtering if we're minifying
// 49152 = FRACUNIT * 0.75
if ((D_abs(dsvars->xstep) > drawvars.mag_threshold)

!Line: 79 - style: Parameter 'dsvars' can be declared as pointer to const. However it seems that 'R_DrawSpan8_PointUV_PointZ' is a callback function, if 'dsvars' is declared with const you might also need to cast function pointer(s). [constParameterCallback]

!Line: 889 - note: You might need to cast the function pointer here
!Line: 79 - note: Parameter 'dsvars' can be declared as pointer to const

if ((D_abs(dsvars->xstep) > drawvars.mag_threshold)
|| (D_abs(dsvars->ystep) > drawvars.mag_threshold))
{
R_GetDrawSpanFunc(RDRAW_FILTER_POINT,
drawvars.filterz)(dsvars);
return;

!Line: 84 - error: Shifting signed 32-bit value by 31 bits is undefined behaviour [shiftTooManyBitsSigned]

|| (D_abs(dsvars->ystep) > drawvars.mag_threshold))
{
R_GetDrawSpanFunc(RDRAW_FILTER_POINT,
drawvars.filterz)(dsvars);
return;
}

!Line: 85 - error: Shifting signed 32-bit value by 31 bits is undefined behaviour [shiftTooManyBitsSigned]

source = &TEMPBUF[temp_x + (yl << 2)];
dest = drawvars.TOPLEFT + yl*drawvars.PITCH + startx + temp_x;
count = tempyh[temp_x] - yl + 1;
while(--count >= 0)
{

!Line: 108 - style: Variable 'source' is assigned a value that is never used. [unreadVariable]

source += 4;
dest += drawvars.PITCH;
}
}
}

!Line: 127 - style: Variable 'source' is assigned a value that is never used. [unreadVariable]

source = &TEMPBUF[colnum + (yl << 2)];
dest = drawvars.TOPLEFT + yl*drawvars.PITCH + startx + colnum;
count = commontop - yl;
while(--count >= 0)
{

!Line: 155 - style: Variable 'source' is assigned a value that is never used. [unreadVariable]

source += 4;
dest += drawvars.PITCH;
}
}
// flush column tail

!Line: 175 - style: Variable 'source' is assigned a value that is never used. [unreadVariable]

source = &TEMPBUF[colnum + ((commonbot + 1) << 2)];
dest = drawvars.TOPLEFT + (commonbot + 1)*drawvars.PITCH + startx + colnum;
count = yh - commonbot;
while(--count >= 0)
{

!Line: 183 - style: Variable 'source' is assigned a value that is never used. [unreadVariable]

source += 4;
dest += drawvars.PITCH;
}
}
++colnum;
}

!Line: 203 - style: Variable 'source' is assigned a value that is never used. [unreadVariable]

SCREENTYPE *source = &TEMPBUF[commontop << 2];
SCREENTYPE *dest = drawvars.TOPLEFT + commontop*drawvars.PITCH + startx;
int count;
#if (R_DRAWCOLUMN_PIPELINE & RDC_FUZZ)
int fuzz1, fuzz2, fuzz3, fuzz4;

!Line: 213 - style: Variable 'source' is assigned a value that is never used. [unreadVariable]

source += 4 * sizeof(byte);
dest += drawvars.PITCH * sizeof(byte);
}
#else
#if (R_DRAWCOLUMN_PIPELINE_BITS == 8)
if ((sizeof(int) == 4) && (((int)source % 4) == 0) && (((int)dest % 4) == 0)) {

!Line: 248 - style: Variable 'source' is assigned a value that is never used. [unreadVariable]

const lighttable_t *colormap = dcvars->colormap;
const byte *translation = dcvars->translation;
#if (R_DRAWCOLUMN_PIPELINE & (RDC_BILINEAR|RDC_ROUNDED|RDC_DITHERZ))
int y = dcvars->yl;
const int x = dcvars->x;
#endif

!Line: 252 - style: Variable 'colormap' is assigned a value that is never used. [unreadVariable]

const byte *translation = dcvars->translation;
#if (R_DRAWCOLUMN_PIPELINE & (RDC_BILINEAR|RDC_ROUNDED|RDC_DITHERZ))
int y = dcvars->yl;
const int x = dcvars->x;
#endif
#if (R_DRAWCOLUMN_PIPELINE & RDC_DITHERZ)

!Line: 253 - style: Variable 'translation' is assigned a value that is never used. [unreadVariable]

fixed_t nextfrac = 0;
heightmask++;
heightmask <<= FRACBITS;
if (frac < 0)

!Line: 320 - style: Variable 'nextfrac' is assigned a value that is never used. [unreadVariable]

INCY(y);
} else {
fixed_t nextfrac = 0;
heightmask++;
heightmask <<= FRACBITS;

!Line: 318 - style: Variable 'y' is assigned a value that is never used. [unreadVariable]

const byte *source = dcvars->source;
const lighttable_t *colormap = dcvars->colormap;
const byte *translation = dcvars->translation;
#if (R_DRAWCOLUMN_PIPELINE & (RDC_BILINEAR|RDC_ROUNDED|RDC_DITHERZ))
int y = dcvars->yl;
const int x = dcvars->x;

!Line: 251 - style: Variable 'source' is assigned a value that is never used. [unreadVariable]

const int x = dcvars->x;
#endif
#if (R_DRAWCOLUMN_PIPELINE & RDC_DITHERZ)
const int fracz = (dcvars->z >> 6) & 255;
const byte *dither_colormaps[2] = { dcvars->colormap, dcvars->nextcolormap };
#endif

!Line: 256 - style: Variable 'x' is assigned a value that is never used. [unreadVariable]

frac = dcvars->texturemid + (dcvars->yl-centery)*fracstep;
#endif
if (dcvars->drawingmasked && dcvars->edgetype == RDRAW_MASKEDCOLUMNEDGE_SLOPED) {
// slope the top and bottom column edge based on the fractional u coordinate
// and dcvars->edgeslope, which were set in R_DrawMaskedColumn

!Line: 171 - style: Variable 'frac' is assigned a value that is never used. [unreadVariable]

frac += 0xffff-(slope_texu & 0xffff);
}
else if (dcvars->edgeslope & RDRAW_EDGESLOPE_TOP_DOWN) {
// [#\]
int shift = ((slope_texu & 0xffff)/dcvars->iscale);
dcvars->yl += shift;

!Line: 184 - style: Variable 'frac' is assigned a value that is never used. [unreadVariable]

frac += slope_texu & 0xffff;
}
}
if (dcvars->yh != viewheight-1) {
if (dcvars->edgeslope & RDRAW_EDGESLOPE_BOT_UP) {
// [#/]

!Line: 191 - style: Variable 'frac' is assigned a value that is never used. [unreadVariable]

dest = &TEMPBUF[dcvars->yl << 2];
} else {
tempyl[temp_x] = dcvars->yl;
tempyh[temp_x] = dcvars->yh;
if(dcvars->yl > commontop)

!Line: 233 - style: Variable 'dest' is assigned a value that is never used. [unreadVariable]

dest = &TEMPBUF[(dcvars->yl << 2) + temp_x];
}
temp_x += 1;
}
// do nothing else when drawin fuzz columns

!Line: 243 - style: Variable 'dest' is assigned a value that is never used. [unreadVariable]

frac = dcvars->texturemid - (FRACUNIT>>1) + (dcvars->yl-centery)*fracstep;
#else
frac = dcvars->texturemid + (dcvars->yl-centery)*fracstep;
#endif
if (dcvars->drawingmasked && dcvars->edgetype == RDRAW_MASKEDCOLUMNEDGE_SLOPED) {

!Line: 169 - style: Variable 'frac' is assigned a value that is never used. [unreadVariable]

const byte *colormap = dsvars->colormap;
SCREENTYPE *dest = drawvars.TOPLEFT + dsvars->y*drawvars.PITCH + dsvars->x1;
#if (R_DRAWSPAN_PIPELINE & (RDC_DITHERZ|RDC_BILINEAR))
const int y = dsvars->y;
int x1 = dsvars->x1;
#endif

!Line: 99 - style: Variable 'colormap' is assigned a value that is never used. [unreadVariable]

int i=0;
// Handle resize,
// e.g. smaller view windows
// with border and/or status bar.
viewwindowx = (SCREENWIDTH-width) >> 1;

!Line: 1011 - style: Variable 'i' is assigned a value that is never used. [unreadVariable]

sector_t* sec;
secnum = -1;
// start lights strobing in all sectors tagged same as line
while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0)
{

!Line: 305 - style: The scope of the variable 'sec' can be reduced. [variableScope]

int j, tbright = bright; //jff 5/17/98 search for maximum PER sector
// bright = 0 means to search for highest light level surrounding sector
if (!bright)
for (j = 0;j < sector->linecount; j++)

!Line: 373 - style: The scope of the variable 'j' can be reduced. [variableScope]

int EV_StartLightStrobing(line_t* line)
{
int secnum;
sector_t* sec;
secnum = -1;

!Line: 302 - style: Parameter 'line' can be declared as pointer to const [constParameterPointer]

int EV_TurnTagLightsOff(line_t* line)
{
int j;
// search sectors for those with same tag as activating line

!Line: 331 - style: Parameter 'line' can be declared as pointer to const [constParameterPointer]

sector_t *sector = sectors + j, *tsec;
int i, min = sector->lightlevel;
// find min neighbor light level
for (i = 0;i < sector->linecount; i++)
if ((tsec = getNextSector(sector->lines[i], sector)) &&
tsec->lightlevel < min)

!Line: 340 - style: Variable 'tsec' can be declared as pointer to const [constVariablePointer]

int EV_LightTurnOn(line_t *line, int bright)
{
int i;
// search all sectors for ones with same tag as activating line

!Line: 363 - style: Parameter 'line' can be declared as pointer to const [constParameterPointer]

sector_t *temp, *sector = sectors+i;
int j, tbright = bright; //jff 5/17/98 search for maximum PER sector
// bright = 0 means to search for highest light level surrounding sector
if (!bright)

!Line: 372 - style: Variable 'temp' can be declared as pointer to const [constVariablePointer]

int EV_LightTurnOnPartway(line_t *line, fixed_t level)
{
int i;
if (level < 0) // clip at extremes
level = 0;

!Line: 405 - style: Parameter 'line' can be declared as pointer to const [constParameterPointer]

sector_t *temp, *sector = sectors+i;
int j, bright = 0, min = sector->lightlevel;
for (j = 0; j < sector->linecount; j++)
if ((temp = getNextSector(sector->lines[j],sector)))
{

!Line: 417 - style: Variable 'temp' can be declared as pointer to const [constVariablePointer]

mo->player = &player;
player.health = 100;
junk.special = (short)mo->state->misc1;
if (!junk.special)
return;
junk.tag = (short)mo->state->misc2;

!Line: 2592 - error: Address of local auto-variable assigned to a function parameter. [autoVariables]

P_LookForMonsters(actor, allaround) || P_LookForPlayers (actor, allaround):
P_LookForPlayers (actor, allaround) || P_LookForMonsters(actor, allaround);
}
//
// P_HelpFriend

!Line: 962 - style: Same expression in both branches of ternary operator. [duplicateExpressionTernary]

!((targ = actor->subsector->sector->soundtarget) &&
targ->flags & MF_SHOOTABLE &&
(P_SetTarget(&actor->target, targ),
!(actor->flags & MF_AMBUSH) || P_CheckSight(actor, targ))) &&
(actor->flags & MF_FRIEND || !P_LookForTargets(actor, false)))
return;

!Line: 1055 - style: Redundant initialization for 'targ'. The initialized value is overwritten before it is read. [redundantInitialization]

!Line: 1044 - note: targ is initialized
!Line: 1055 - note: targ is overwritten

int l;
// Short-circuit: it's on a lift which is active.
if (sec->floordata && ((thinker_t *) sec->floordata)->function==T_PlatRaise)
return true;

!Line: 257 - style: The scope of the variable 'l' can be reduced. [variableScope]

const ceiling_t *cl; // Crushing ceiling
int dir = 0;
for (seclist=actor->touching_sectorlist; seclist; seclist=seclist->m_tnext)
if ((cl = seclist->m_sector->ceilingdata) &&
cl->thinker.function == T_MoveCeiling)
dir |= cl->direction;

!Line: 293 - style: The scope of the variable 'cl' can be reduced. [variableScope]

int xl, xh;
int yl, yh;
int bx, by;
if (actor->movedir != DI_NODIR)
{

!Line: 1638 - style: The scope of the variable 'xl' can be reduced. [variableScope]

int xl, xh;
int yl, yh;
int bx, by;
if (actor->movedir != DI_NODIR)
{

!Line: 1638 - style: The scope of the variable 'xh' can be reduced. [variableScope]

int yl, yh;
int bx, by;
if (actor->movedir != DI_NODIR)
{
// check for corpses to raise

!Line: 1639 - style: The scope of the variable 'yl' can be reduced. [variableScope]

int yl, yh;
int bx, by;
if (actor->movedir != DI_NODIR)
{
// check for corpses to raise

!Line: 1639 - style: The scope of the variable 'yh' can be reduced. [variableScope]

int bx, by;
if (actor->movedir != DI_NODIR)
{
// check for corpses to raise
viletryx =

!Line: 1640 - style: The scope of the variable 'bx' can be reduced. [variableScope]

int bx, by;
if (actor->movedir != DI_NODIR)
{
// check for corpses to raise
viletryx =

!Line: 1640 - style: The scope of the variable 'by' can be reduced. [variableScope]

void P_NoiseAlert(mobj_t *target, mobj_t *emitter)
{
validcount++;
P_RecursiveSound(emitter->subsector->sector, 0, target);
}

!Line: 126 - style: inconclusive: Function 'P_NoiseAlert' argument 2 names different: declaration 'emmiter' definition 'emitter'. [funcArgNamesDifferent]

!Line: 41 - note: Function 'P_NoiseAlert' argument 2 names different: declaration 'emmiter' definition 'emitter'.
!Line: 126 - note: Function 'P_NoiseAlert' argument 2 names different: declaration 'emmiter' definition 'emitter'.

thinker_t *cap = &thinkerclasscap[mo->flags & MF_FRIEND ?
th_friends : th_enemies];
(mo->thinker.cprev->cnext = mo->thinker.cnext)->cprev = mo->thinker.cprev;
(mo->thinker.cprev = cap->cprev)->cnext = &mo->thinker;
(mo->thinker.cnext = cap)->cprev = &mo->thinker;
}

!Line: 761 - style: Clarify calculation precedence for '&' and '?'. [clarifyCalculation]

cap = &thinkerclasscap[actor->flags & MF_FRIEND ? th_enemies : th_friends];
// Search for new enemy
if (cap->cnext != cap) // Empty list? bail out early
{

!Line: 897 - style: Clarify calculation precedence for '&' and '?'. [clarifyCalculation]

return actor->flags & MF_FRIEND ?
P_LookForMonsters(actor, allaround) || P_LookForPlayers (actor, allaround):
P_LookForPlayers (actor, allaround) || P_LookForMonsters(actor, allaround);
}
//

!Line: 961 - style: Clarify calculation precedence for '&' and '?'. [clarifyCalculation]

cap = &thinkerclasscap[actor->flags & MF_FRIEND ? th_friends : th_enemies];
for (th = cap->cnext; th != cap; th = th->cnext)
if (((mobj_t *) th)->health*2 >= ((mobj_t *) th)->info->spawnhealth)
{
if (P_Random(pr_helpfriend) < 180)

!Line: 984 - style: Clarify calculation precedence for '&' and '?'. [clarifyCalculation]

static int P_IsUnderDamage(mobj_t *actor)
{
const struct msecnode_s *seclist;
const ceiling_t *cl; // Crushing ceiling
int dir = 0;
for (seclist=actor->touching_sectorlist; seclist; seclist=seclist->m_tnext)

!Line: 290 - style: Parameter 'actor' can be declared as pointer to const [constParameterPointer]

static fixed_t P_AvoidDropoff(mobj_t *actor)
{
int yh=((tmbbox[BOXTOP] = actor->y+actor->radius)-bmaporgy)>>MAPBLOCKSHIFT;
int yl=((tmbbox[BOXBOTTOM]= actor->y-actor->radius)-bmaporgy)>>MAPBLOCKSHIFT;
int xh=((tmbbox[BOXRIGHT] = actor->x+actor->radius)-bmaporgx)>>MAPBLOCKSHIFT;
int xl=((tmbbox[BOXLEFT] = actor->x-actor->radius)-bmaporgx)>>MAPBLOCKSHIFT;

!Line: 609 - style: Parameter 'actor' can be declared as pointer to const [constParameterPointer]

mobj_t *target = actor->target;
fixed_t deltax = target->x - actor->x;
fixed_t deltay = target->y - actor->y;
// killough 8/8/98: sometimes move away from target, keeping distance
//

!Line: 639 - style: Variable 'target' can be declared as pointer to const [constVariablePointer]

mobj_t *mo2 = (mobj_t *) th;
if (mo2 != mo && mo2->type == mo->type && mo2->health > 0)
return; // other Keen not dead
}
junk.tag = 666;

!Line: 1023 - style: Variable 'mo2' can be declared as pointer to const [constVariablePointer]

mobj_t *dest;
mobj_t *th;
/* killough 1/18/98: this is why some missiles do not have smoke
* and some do. Also, internal demos start at random gametics, thus
* the bug in which revenants cause internal demos to go out of sync.

!Line: 1464 - style: Variable 'dest' can be declared as pointer to const [constVariablePointer]

mobjinfo_t *info;
// got one!
mobj_t* temp = actor->target;
actor->target = corpsehit;
A_FaceTarget(actor);

!Line: 1665 - style: Variable 'info' can be declared as pointer to const [constVariablePointer]

mobj_t *dest;
angle_t an;
int dist;
if (!actor->target)
return;

!Line: 1911 - style: Variable 'dest' can be declared as pointer to const [constVariablePointer]

void A_BossDeath(mobj_t *mo)
{
thinker_t *th;
line_t junk;
int i;

!Line: 2105 - style: Parameter 'mo' can be declared as pointer to const [constParameterPointer]

mobj_t *mo2 = (mobj_t *) th;
if (mo2 != mo && mo2->type == mo->type && mo2->health > 0)
return; // other boss not dead
}
// victory!

!Line: 2208 - style: Variable 'mo2' can be declared as pointer to const [constVariablePointer]

void A_BrainScream(mobj_t *mo)
{
int x;
for (x=mo->x - 196*FRACUNIT ; x< mo->x + 320*FRACUNIT ; x+= FRACUNIT*8)
{
int y = mo->y - 320*FRACUNIT;

!Line: 2345 - style: Parameter 'mo' can be declared as pointer to const [constParameterPointer]

void A_BrainExplode(mobj_t *mo)
{ // killough 5/5/98: remove dependence on order of evaluation:
int t = P_Random(pr_brainexp);
int x = mo->x + (t - P_Random(pr_brainexp))*2048;
int y = mo->y;
int z = 128 + P_Random(pr_brainexp)*2*FRACUNIT;

!Line: 2362 - style: Parameter 'mo' can be declared as pointer to const [constParameterPointer]

void A_BrainDie(mobj_t *mo)
{
G_ExitLevel();
}
void A_BrainSpit(mobj_t *mo)

!Line: 2376 - style: Parameter 'mo' can be declared as pointer to const [constParameterPointer]

mobj_t *targ;
int r;
mobjtype_t type;
if (--mo->reactiontime)
return; // still flying

!Line: 2421 - style: Variable 'targ' can be declared as pointer to const [constVariablePointer]

void A_Spawn(mobj_t *mo)
{
if (mo->state->misc1)
{
/* mobj_t *newmobj = */
P_SpawnMobj(mo->x, mo->y, (mo->state->misc2 << FRACBITS) + mo->z,

!Line: 2540 - style: Parameter 'mo' can be declared as pointer to const [constParameterPointer]

if (P_Random(pr_newchase) > 200 || D_abs(deltay)>D_abs(deltax))
tdir = xdir, xdir = ydir, ydir = tdir;
if ((xdir == turnaround ? xdir = DI_NODIR : xdir) != DI_NODIR &&
(actor->movedir = xdir, P_TryWalk(actor)))
return; // either moved forward or attacked

!Line: 529 - error: Shifting signed 32-bit value by 31 bits is undefined behaviour [shiftTooManyBitsSigned]

if (D_abs(thing->x-viletryx) > maxdist || D_abs(thing->y-viletryy) > maxdist)
return true; // not actually touching
// Check to see if the radius and height are zero. If they are // phares
// then this is a crushed monster that has been turned into a // |
// gib. One of the options may be to ignore this guy. // V

!Line: 1588 - error: Shifting signed 32-bit value by 31 bits is undefined behaviour [shiftTooManyBitsSigned]

demo_p++; // forceOldBsp
}
else /* defaults for versions <= 2.02 */
{
/* G_Compatibility will set these */
}

!Line: 2443 - warning: Assignment of function parameter has no effect outside the function. Did you forget dereferencing it? [uselessAssignmentPtrArg]

ya = finesine[an];
if (compatibility_level <= finaldoom_compatibility || compatibility_level == prboom_4_compatibility)
switch (an) {
case -4096: xa = finetangent[2048]; // finecosine[-4096]
ya = finetangent[0]; // finesine[-4096]

!Line: 1063 - warning: Either the switch case 'case -1024' is redundant or the array 'finesine[10240]' is accessed at index -1024, which is out of bounds. [negativeIndex]

!Line: 1076 - note: case -1024: an is -1024 here.
!Line: 1063 - note: Negative array index

ammo = plr->ammo[weaponinfo[w].ammo];
fullammo = plr->maxammo[weaponinfo[w].ammo];
ammopct=0;
// skip weapons not currently posessed
if (!plr->weaponowned[w])

!Line: 995 - warning: Either the condition 'weaponinfo[w].ammo==am_noammo' is redundant or the array 'plr->ammo[4]' is accessed at index 5, which is out of bounds. [arrayIndexOutOfBoundsCond]

!Line: 1007 - note: Assuming that condition 'weaponinfo[w].ammo==am_noammo' is not redundant
!Line: 995 - note: Array index out of bounds

fullammo = plr->maxammo[weaponinfo[w].ammo];
ammopct=0;
// skip weapons not currently posessed
if (!plr->weaponowned[w])
continue;

!Line: 996 - warning: Either the condition 'weaponinfo[w].ammo==am_noammo' is redundant or the array 'plr->maxammo[4]' is accessed at index 5, which is out of bounds. [arrayIndexOutOfBoundsCond]

!Line: 1007 - note: Assuming that condition 'weaponinfo[w].ammo==am_noammo' is not redundant
!Line: 996 - note: Array index out of bounds

if (!((demover >= 0 && demover <= 4) ||
(demover >= 104 && demover <= 111) ||
(demover >= 200 && demover <= 214)))
{
I_Error("G_ReadDemoHeader: Unknown demo format %d.", demover);
}

!Line: 2642 - style: Condition 'demover>=0' is always true [knownConditionTrueFalse]

!Line: 2634 - note: Assignment 'demover=*demo_p++', assigned value is greater than -1
!Line: 2642 - note: Condition 'demover>=0' is always true

special_event = BT_SPECIAL | (BTS_RESTARTLEVEL & BT_SPECIALMASK);
}
//
// G_DoLoadLevel
//

!Line: 478 - style: Same expression on both sides of '&' because 'BTS_RESTARTLEVEL' and 'BT_SPECIALMASK' represent the same value. [duplicateExpression]

char ammostr[80]; //jff 3/8/98 allow plenty room for dehacked mods
char healthstr[80];//jff
char armorstr[80]; //jff
int i,doit;
plr = &players[displayplayer]; // killough 3/7/98

!Line: 737 - style: The scope of the variable 'ammostr' can be reduced. [variableScope]

char healthstr[80];//jff
char armorstr[80]; //jff
int i,doit;
plr = &players[displayplayer]; // killough 3/7/98
// draw the automap widgets if automap is displayed

!Line: 738 - style: The scope of the variable 'healthstr' can be reduced. [variableScope]

char armorstr[80]; //jff
int i,doit;
plr = &players[displayplayer]; // killough 3/7/98
// draw the automap widgets if automap is displayed
if (automapmode & am_active)

!Line: 739 - style: The scope of the variable 'armorstr' can be reduced. [variableScope]

int i,doit;
plr = &players[displayplayer]; // killough 3/7/98
// draw the automap widgets if automap is displayed
if (automapmode & am_active)
{

!Line: 740 - style: The scope of the variable 'i' can be reduced. [variableScope]

int i,doit;
plr = &players[displayplayer]; // killough 3/7/98
// draw the automap widgets if automap is displayed
if (automapmode & am_active)
{

!Line: 740 - style: The scope of the variable 'doit' can be reduced. [variableScope]

int i, rc;
char c;
// tick down message counter if message is up
if (message_counter && !--message_counter)
{

!Line: 1308 - style: The scope of the variable 'i' can be reduced. [variableScope]

int i, rc;
char c;
// tick down message counter if message is up
if (message_counter && !--message_counter)
{

!Line: 1308 - style: The scope of the variable 'rc' can be reduced. [variableScope]

char c;
// tick down message counter if message is up
if (message_counter && !--message_counter)
{
message_on = false;

!Line: 1309 - style: The scope of the variable 'c' can be reduced. [variableScope]

player_t *plr;
char ammostr[80]; //jff 3/8/98 allow plenty room for dehacked mods
char healthstr[80];//jff
char armorstr[80]; //jff
int i,doit;

!Line: 736 - style: Local variable 'plr' shadows outer variable [shadowVariable]

!Line: 162 - note: Shadowed declaration
!Line: 736 - note: Shadow variable

HU_COORDX_Y,
hu_font,
HU_FONTSTART,
hudcolor_xyco
);
HUlib_initTextLine

!Line: 575 - style: Argument '1+0*hu_font['A'-'!'].height' to function HUlib_initTextLine is always 1. Constant literal calculation disable/hide variable expression 'hu_font['A'-'!'].height'. [knownArgumentHiddenVariableExpression]

char name[9];
int episode, map;
if (!computed) {
computed = true;
if (gamemode == commercial)

!Line: 1406 - style: The scope of the variable 'name' can be reduced. [variableScope]

int episode, map;
if (!computed) {
computed = true;
if (gamemode == commercial)
for (map = haswolflevels ? 32 : 30; map; map--)

!Line: 1407 - style: The scope of the variable 'episode' can be reduced. [variableScope]

int episode, map;
if (!computed) {
computed = true;
if (gamemode == commercial)
for (map = haswolflevels ? 32 : 30; map; map--)

!Line: 1407 - style: The scope of the variable 'map' can be reduced. [variableScope]

int i;
if (fast != fast_pending) { /* only change if necessary */
if ((fast = fast_pending))
{
for (i=S_SARG_RUN1; i<=S_SARG_PAIN2; i++)
if (states[i].tics != 1 || demo_compatibility) // killough 4/10/98

!Line: 2066 - style: The scope of the variable 'i' can be reduced. [variableScope]

unsigned char at = 0; // e6y: tasdoom stuff
if (*demo_p == DEMOMARKER)
G_CheckDemoStatus(); // end of demo data stream
else if (demoplayback && demo_p + (longtics?5:4) > demobuffer + demolength)
{

!Line: 2160 - style: The scope of the variable 'at' can be reduced. [variableScope]

char *s;
player_t *plr;
char ammostr[80]; //jff 3/8/98 allow plenty room for dehacked mods
char healthstr[80];//jff
char armorstr[80]; //jff
int i,doit;

!Line: 735 - style: Variable 's' can be declared as pointer to const [constVariablePointer]

boolean HU_Responder(event_t *ev)
{
static char lastmessage[HU_MAXLINELENGTH+1];
const char* macromessage; // CPhipps - const char*
boolean eatkey = false;

!Line: 1448 - style: Parameter 'ev' can be declared as pointer to const [constParameterPointer]

int lev;
int i = M_CheckParm("-complevel");
if (i && (i+1 < myargc))
{
lev = atoi(myargv[i+1]);
if (lev>=0)

!Line: 2585 - style: The scope of the variable 'lev' can be reduced. [variableScope]

void G_LoadGame(int slot, boolean command)
{
lprintf(LO_INFO, "G_LoadGame: slot %d, command %d\n", slot, command);
if (!demoplayback && !command) {
// CPhipps - handle savegame filename in G_DoLoadGame
// - Delay load so it can be communicated in net game

!Line: 1437 - style: inconclusive: Function 'G_LoadGame' argument 2 names different: declaration 'is_command' definition 'command'. [funcArgNamesDifferent]

!Line: 56 - note: Function 'G_LoadGame' argument 2 names different: declaration 'is_command' definition 'command'.
!Line: 1437 - note: Function 'G_LoadGame' argument 2 names different: declaration 'is_command' definition 'command'.

void G_DeferedPlayDemo (const char* name)
{
defdemoname = name;
gameaction = ga_playdemo;
}

!Line: 2574 - style: inconclusive: Function 'G_DeferedPlayDemo' argument 1 names different: declaration 'demo' definition 'name'. [funcArgNamesDifferent]

!Line: 55 - note: Function 'G_DeferedPlayDemo' argument 1 names different: declaration 'demo' definition 'name'.
!Line: 2574 - note: Function 'G_DeferedPlayDemo' argument 1 names different: declaration 'demo' definition 'name'.

size_t i;
for (i = 0; i<numwadfiles; i++)
{
const char *const w = wadfiles[i].name;
size_t l = strlen(w);
CheckSaveGame(l+2);

!Line: 1761 - style: Local variable 'i' shadows outer variable [shadowVariable]

!Line: 1716 - note: Shadowed declaration
!Line: 1761 - note: Shadow variable

byte *demo_p = demostart;
longtics = 0;
/* cph - 3 demo record formats supported: MBF+, BOOM, and Doom v1.9 */
if (mbf_features) {
{ /* Write version code into demo */

!Line: 2458 - style: Local variable 'demo_p' shadows outer variable [shadowVariable]

!Line: 97 - note: Shadowed declaration
!Line: 2458 - note: Shadow variable

static boolean G_CheckSpot(int playernum, mapthing_t *mthing)
{
fixed_t x,y;
subsector_t *ss;
int i;

!Line: 997 - style: Parameter 'mthing' can be declared as pointer to const [constParameterPointer]


!Maximum character count per GitHub comment has been reached! Not all warnings/errors has been parsed!

finger563 added 5 commits May 1, 2025 09:21
…d; update to have menu / game perform better (doom) by adding appropriate sleeps in the main loop and audio task; update pool to be able to query if pointer is in pool or not
@finger563 finger563 merged commit ee3115e into main May 1, 2025
2 of 3 checks passed
@finger563 finger563 deleted the feat/doom branch May 1, 2025 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants