Skip to content

Commit

Permalink
Merge pull request #866 from edge-classic/unreachable-fixes
Browse files Browse the repository at this point in the history
Unreachable fixes
  • Loading branch information
dashodanger authored Jan 28, 2025
2 parents b763ee0 + b092204 commit 6fad0ff
Show file tree
Hide file tree
Showing 34 changed files with 9 additions and 88 deletions.
19 changes: 1 addition & 18 deletions source_files/coal/c_compile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void RealVM::LexNewLine()
// Aborts the current function parse.
// The given message should have a trailing \n
//
void RealVM::CompileError(const char *error, ...)
[[noreturn]] void RealVM::CompileError(const char *error, ...)
{
va_list argptr;
char buffer[1024];
Expand Down Expand Up @@ -958,11 +958,9 @@ Definition *RealVM::EXPTerm()
}

CompileError("type mismatch for %s\n", op->name);
break;
}

CompileError("expected value, got %s\n", comp_.token_buf);
return nullptr; /* NOT REACHED */
}

Definition *RealVM::EXPShortCircuit(Definition *e, int n)
Expand Down Expand Up @@ -1041,7 +1039,6 @@ Definition *RealVM::EXPFieldQuery(Definition *e, bool lvalue)
}

CompileError("type mismatch with . operator\n");
return nullptr; // NOT REACHED
}

Definition *RealVM::EXPExpression(int priority, bool *lvalue)
Expand Down Expand Up @@ -1277,13 +1274,11 @@ void RealVM::STATStatement(bool allow_def)
if (allow_def && LexCheck("function"))
{
CompileError("functions must be global\n");
return;
}

if (allow_def && LexCheck("constant"))
{
CompileError("constants must be global\n");
return;
}

if (LexCheck("{"))
Expand Down Expand Up @@ -1818,8 +1813,6 @@ double RealVM::GetFloat(const char *mod_name, const char *var_name)
return COAL_G_FLOAT(var->ofs);

RunError("GetFloat failed: Could not find variable %s\n", var_name);

return 0; // Not reached
}

const char *RealVM::GetString(const char *mod_name, const char *var_name)
Expand Down Expand Up @@ -1848,8 +1841,6 @@ const char *RealVM::GetString(const char *mod_name, const char *var_name)
}

RunError("GetString failed: Could not find variable %s\n", var_name);

return 0; // Not reached
}

double *RealVM::GetVector(const char *mod_name, const char *var_name)
Expand Down Expand Up @@ -1878,8 +1869,6 @@ double *RealVM::GetVector(const char *mod_name, const char *var_name)
}

RunError("GetVector failed: Could not find variable %s\n", var_name);

return 0; // Not reached
}

double RealVM::GetVectorX(const char *mod_name, const char *var_name)
Expand Down Expand Up @@ -1908,8 +1897,6 @@ double RealVM::GetVectorX(const char *mod_name, const char *var_name)
}

RunError("GetVectorX failed: Could not find variable %s\n", var_name);

return 0; // Not reached
}

double RealVM::GetVectorY(const char *mod_name, const char *var_name)
Expand Down Expand Up @@ -1938,8 +1925,6 @@ double RealVM::GetVectorY(const char *mod_name, const char *var_name)
}

RunError("GetVectorY failed: Could not find variable %s\n", var_name);

return 0; // Not reached
}

double RealVM::GetVectorZ(const char *mod_name, const char *var_name)
Expand Down Expand Up @@ -1968,8 +1953,6 @@ double RealVM::GetVectorZ(const char *mod_name, const char *var_name)
}

RunError("GetVectorZ failed: Could not find variable %s\n", var_name);

return 0; // Not reached
}

void RealVM::SetFloat(const char *mod_name, const char *var_name, double value)
Expand Down
3 changes: 1 addition & 2 deletions source_files/coal/c_execute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ void RealVM::ReturnString(const char *s, int len)
//
// Aborts the currently executing functions
//
void RealVM::RunError(const char *error, ...)
[[noreturn]] void RealVM::RunError(const char *error, ...)
{
va_list argptr;
char buffer[1024];
Expand Down Expand Up @@ -420,7 +420,6 @@ void RealVM::DoExecute(int fnum)

case OP_ERROR:
RunError("Assertion failed @ %s:%d\n", COAL_REF_STRING(st->a), st->b);
break; /* NOT REACHED */

default:
RunError("Bad opcode %i", st->op);
Expand Down
4 changes: 2 additions & 2 deletions source_files/coal/c_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ class RealVM : public VM
void LexName();
void LexPunctuation();

void CompileError(const char *error, ...);
[[noreturn]] void CompileError(const char *error, ...);

// c_execute.cc
private:
Expand All @@ -512,7 +512,7 @@ class RealVM : public VM
int StringConcatFloat(const char *s, double f);
int StringConcatVector(const char *s, double *v);

void RunError(const char *error, ...);
[[noreturn]] void RunError(const char *error, ...);

void StackTrace();
void PrintStatement(Function *f, int s);
Expand Down
1 change: 0 additions & 1 deletion source_files/ddf/ddf_image.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ static ImageNamespace GetImageNamespace(const char *prefix)
return kImageNamespacePatch;

DDFError("Invalid image prefix '%s' (use: gfx,tex,flat,spr)\n", prefix);
return kImageNamespaceFlat; /* NOT REACHED */
}

//
Expand Down
4 changes: 2 additions & 2 deletions source_files/ddf/ddf_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,12 @@ extern std::string cur_ddf_entryname;
extern std::string cur_ddf_linedata;

#ifdef __GNUC__
void DDFError(const char *err, ...) __attribute__((format(printf, 1, 2)));
[[noreturn]] void DDFError(const char *err, ...) __attribute__((format(printf, 1, 2)));
void DDFDebug(const char *err, ...) __attribute__((format(printf, 1, 2)));
void DDFWarning(const char *err, ...) __attribute__((format(printf, 1, 2)));
void DDFWarnError(const char *err, ...) __attribute__((format(printf, 1, 2)));
#else
void DDFError(const char *err, ...);
[[noreturn]] void DDFError(const char *err, ...);
void DDFDebug(const char *err, ...);
void DDFWarning(const char *err, ...);
void DDFWarnError(const char *err, ...);
Expand Down
2 changes: 1 addition & 1 deletion source_files/ddf/ddf_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ std::string cur_ddf_filename;
std::string cur_ddf_entryname;
std::string cur_ddf_linedata;

void DDFError(const char *err, ...)
[[noreturn]] void DDFError(const char *err, ...)
{
va_list argptr;
char buffer[2048];
Expand Down
2 changes: 0 additions & 2 deletions source_files/ddf/ddf_thing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2760,7 +2760,6 @@ const MapObjectDefinition *MapObjectDefinitionContainer::Lookup(const char *refn
return default_mobjtype;

DDFError("Unknown thing type: %s\n", refname);
return nullptr; /* NOT REACHED */
}

const MapObjectDefinition *MapObjectDefinitionContainer::Lookup(int id)
Expand Down Expand Up @@ -2873,7 +2872,6 @@ const MapObjectDefinition *MapObjectDefinitionContainer::LookupPlayer(int player
}

FatalError("Missing DDF entry for player number %d\n", playernum);
return nullptr; /* NOT REACHED */
}

const MapObjectDefinition *MapObjectDefinitionContainer::LookupDoorKey(int theKey)
Expand Down
1 change: 0 additions & 1 deletion source_files/dehacked/deh_ammo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ const char *ammo::GetAmmo(int type)
}

FatalError("Dehacked: Internal Error - Bad ammo type %d\n", type);
return nullptr;
}

void ammo::AlterAmmo(int new_val)
Expand Down
2 changes: 0 additions & 2 deletions source_files/dehacked/deh_frames.cc
Original file line number Diff line number Diff line change
Expand Up @@ -933,8 +933,6 @@ const char *frames::GroupToName(char group)
default:
FatalError("Dehacked: Error - GroupToName: BAD GROUP '%c'\n", group);
}

return nullptr;
}

const char *frames::RedirectorName(int next_st)
Expand Down
2 changes: 0 additions & 2 deletions source_files/dehacked/deh_patch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,6 @@ const char *ObjectName(int o_kind)
default:
FatalError("Dehacked: Error - Illegal object kind: %d\n", o_kind);
}

return nullptr; // not reached
}

void MarkObject(int o_kind, int o_num)
Expand Down
2 changes: 0 additions & 2 deletions source_files/edge/e_player.cc
Original file line number Diff line number Diff line change
Expand Up @@ -544,8 +544,6 @@ static SpawnPoint *GameFindHubPlayer(int player_number_, int tag)
FatalError("Missing hub starts with tag %d\n", tag);
else
FatalError("No usable hub start for player %d (tag %d)\n", player_number_ + 1, tag);

return nullptr; /* NOT REACHED */
}

void GameHubSpawnPlayer(Player *p, int tag)
Expand Down
2 changes: 0 additions & 2 deletions source_files/edge/f_finale.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ static bool HasFinale(const FinaleDefinition *F, FinaleStage cur)
default:
FatalError("Bad parameter passed to HasFinale().\n");
}

return false; /* NOT REACHED */
}

// returns kFinaleStageDone if nothing found
Expand Down
2 changes: 1 addition & 1 deletion source_files/edge/g_game.cc
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ static bool GameSaveGameToFile(const std::string &filename, const char *descript
if (!SaveFileOpenWrite(filename, 0xEC))
{
LogPrint("Unable to create savegame file: %s\n", filename.c_str());
return false; /* NOT REACHED */
return false;
}

SaveGlobals *globs = SaveGlobalsNew();
Expand Down
3 changes: 0 additions & 3 deletions source_files/edge/hu_font.cc
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,6 @@ void Font::Load()

default:
FatalError("Coding error, unknown font type %d\n", definition_->type_);
break; /* NOT REACHED */
}
}

Expand All @@ -521,7 +520,6 @@ float Font::NominalWidth() const
return truetype_character_width_[current_font_size] + spacing_;

FatalError("font_c::NominalWidth : unknown FONT type %d\n", definition_->type_);
return 1; /* NOT REACHED */
}

float Font::NominalHeight() const
Expand All @@ -536,7 +534,6 @@ float Font::NominalHeight() const
return truetype_character_height_[current_font_size];

FatalError("font_c::NominalHeight : unknown FONT type %d\n", definition_->type_);
return 1; /* NOT REACHED */
}

const Image *Font::CharImage(char ch) const
Expand Down
2 changes: 0 additions & 2 deletions source_files/edge/p_action.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4008,7 +4008,6 @@ void A_Become(MapObject *mo)
if (!mo->state_ || !mo->state_->action_par)
{
FatalError("BECOME action used in [%s] without arguments!\n", mo->info_->name_.c_str());
return; /* NOT REACHED */
}

BecomeActionInfo *become = (BecomeActionInfo *)mo->state_->action_par;
Expand Down Expand Up @@ -4170,7 +4169,6 @@ void A_Morph(MapObject *mo)
if (!mo->state_ || !mo->state_->action_par)
{
FatalError("MORPH action used in [%s] without arguments!\n", mo->info_->name_.c_str());
return; /* NOT REACHED */
}

MorphActionInfo *morph = (MorphActionInfo *)mo->state_->action_par;
Expand Down
2 changes: 0 additions & 2 deletions source_files/edge/p_plane.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@ static float GetSecHeightReference(TriggerHeightReference ref, Sector *sec, Sect
default:
FatalError("GetSecHeightReference: undefined reference %d\n", ref);
}

return 0;
}

static constexpr uint8_t kReloopTics = 6;
Expand Down
1 change: 0 additions & 1 deletion source_files/edge/p_weapon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2034,7 +2034,6 @@ void A_WeaponBecome(MapObject *mo)
if (!psp->state || !psp->state->action_par)
{
FatalError("BECOME used in weapon [%s] without a label !\n", oldWep->name_.c_str());
return; /* NOT REACHED */
}

WeaponBecomeActionInfo *become = (WeaponBecomeActionInfo *)psp->state->action_par;
Expand Down
3 changes: 0 additions & 3 deletions source_files/edge/r_doomtex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,6 @@ static ImageData *ReadUserAsEpiBlock(Image *rim)
default:
FatalError("ReadUserAsEpiBlock: Coding error, unknown type %d\n", def->type_);
}

return nullptr; /* NOT REACHED */
}

//
Expand Down Expand Up @@ -580,7 +578,6 @@ ImageData *ReadAsEpiBlock(Image *rim)

default:
FatalError("ReadAsBlock: unknown source_type %d !\n", rim->source_type_);
return nullptr;
}
}

Expand Down
1 change: 0 additions & 1 deletion source_files/edge/r_image.cc
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,6 @@ static Image *AddImageUser(ImageDefinition *def)

default:
FatalError("AddImageUser: Coding error, unknown type %d\n", def->type_);
return nullptr; /* NOT REACHED */
}

Image *rim = NewImage(width, height, solid ? kOpacitySolid : kOpacityUnknown);
Expand Down
1 change: 0 additions & 1 deletion source_files/edge/r_modes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,6 @@ bool ChangeResolution(DisplayMode *mode)

// This ain't good - current and previous resolutions do not work.
FatalError("Switch back to old resolution failed!\n");
return false; /* NOT REACHED */
}

//--- editor settings ---
Expand Down
1 change: 0 additions & 1 deletion source_files/edge/r_render.cc
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,6 @@ static void DrawSlidingDoor(DrawFloor *dfloor, float c, float f, float tex_top_h

default:
FatalError("INTERNAL ERROR: unknown slidemove type!\n");
return; /* NOT REACHED */
}

// limit sliding door coordinates to current seg
Expand Down
1 change: 0 additions & 1 deletion source_files/edge/r_texgl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ int MakeValidTextureSize(int value)
return 4096;

FatalError("Texture size (%d) too large !\n", value);
return -1; /* NOT REACHED */
}

ImageData *RGBFromPalettised(ImageData *src, const uint8_t *palette, int opacity)
Expand Down
7 changes: 1 addition & 6 deletions source_files/edge/rad_pars.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static char *this_map = nullptr;
static int pending_wait_tics = 0;
static char *pending_label = nullptr;

void ScriptError(const char *err, ...)
[[noreturn]] static void ScriptError(const char *err, ...)
{
va_list argptr;
char buffer[2048];
Expand Down Expand Up @@ -287,7 +287,6 @@ static ArmourType ScriptCheckForArmourType(const char *info)

// this never returns
ScriptError("Unknown armour type: %s\n", info);
return kArmourTypeGreen;
}

static ScriptChangeTexturetureType ScriptCheckForChangetexType(const char *info)
Expand All @@ -313,7 +312,6 @@ static ScriptChangeTexturetureType ScriptCheckForChangetexType(const char *info)

// this never returns
ScriptError("Unknown ChangeTex type '%s'\n", info);
return kChangeTextureRightUpper;
}

//
Expand Down Expand Up @@ -2408,9 +2406,6 @@ void ScriptParseLine()
ScriptError("RTS command '%s' used in wrong place "
"(found in %s, should be in %s).\n",
pars[0], rad_level_names[current_script_level], rad_level_names[cur->level]);

// NOT REACHED
return;
}
}

Expand Down
1 change: 0 additions & 1 deletion source_files/edge/rad_trig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@ RADScript *FindScriptByName(const char *map_name, const char *name)
}

FatalError("RTS: No such script `%s' on map %s.\n", name, map_name);
return nullptr;
}

RADScriptTrigger *FindScriptTriggerByName(const char *name)
Expand Down
Loading

0 comments on commit 6fad0ff

Please sign in to comment.