Skip to content

Coverity Unused values Issues #5763

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
7 changes: 1 addition & 6 deletions code/ai/aicode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14551,7 +14551,6 @@ int aas_1(object *objp, ai_info *aip, vec3d *safe_pos)

weapon *weaponp = &Weapons[weapon_objp->instance];
weapon_info *wip = &Weapon_info[weaponp->weapon_info_index];
object *target_ship_obj = NULL;

if (wip->shockwave.speed == 0.0f) {
aip->ai_flags.remove(AI::AI_Flags::Avoid_shockwave_weapon);
Expand All @@ -14570,16 +14569,12 @@ int aas_1(object *objp, ai_info *aip, vec3d *safe_pos)
// time in the future, this time based on max lifetime and life left.
if (wip->is_locked_homing()) {
expected_pos = weaponp->homing_pos;
if (weaponp->homing_object && weaponp->homing_object->type == OBJ_SHIP) {
target_ship_obj = weaponp->homing_object;
}
pos_set = 1;
if (IS_VEC_NULL(&weaponp->homing_pos)) {
pos_set = 0;
if (weaponp->target_num != -1) {
if (Objects[weaponp->target_num].type == OBJ_SHIP) {
target_ship_obj = &Objects[weaponp->target_num];
expected_pos = target_ship_obj->pos;
expected_pos = Objects[weaponp->target_num].pos;
pos_set = 1;
}
}
Expand Down
3 changes: 2 additions & 1 deletion code/bmpman/bmpman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2159,7 +2159,8 @@ void bm_lock_ani(int /*handle*/, bitmap_slot *bs, bitmap* /*bmp*/, int bpp, usho

// Skip a frame
if ((i < nframes - 1) && can_drop_frames) {
frame_data = anim_get_next_raw_buffer(the_anim_instance, 0, flags & BMP_AABITMAP ? 1 : 0, bm->bpp);
// we can just ignore the return since we're skipping the frame.
anim_get_next_raw_buffer(the_anim_instance, 0, flags & BMP_AABITMAP ? 1 : 0, bm->bpp);
}
}

Expand Down
2 changes: 1 addition & 1 deletion code/graphics/opengl/gropenglstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ void opengl_state::init()

glBlendFunc(GL_ONE, GL_ZERO);
blendfunc_Value.first = GL_ONE;
blendfunc_Value.first = GL_ZERO;
blendfunc_Value.second = GL_ZERO;
buffer_blendfunc_Value.fill(blendfunc_Value);

glDepthFunc(GL_LESS);
Expand Down
10 changes: 5 additions & 5 deletions code/hud/hudlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ void hud_do_lock_indicator(float frametime)
}
}

void hud_lock_acquire_current_target(object *target_objp, ship_subsys *target_subsys)
void hud_lock_acquire_current_target(object *target_objp, ship_subsys **target_subsys)
Copy link
Contributor

Choose a reason for hiding this comment

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

This will now modify the source target subsys, which is obviously the intent of the function but didn't happen before now. Have the repercussions been checked?

{
ship *target_shipp=nullptr;
int lock_in_range=0;
Expand All @@ -735,7 +735,7 @@ void hud_lock_acquire_current_target(object *target_objp, ship_subsys *target_su
weapon_info* wip = &Weapon_info[swp->secondary_bank_weapons[swp->current_secondary_bank]];

// Reset target subsys in case it isn't needed
if (target_subsys != nullptr) target_subsys = nullptr;
if (*target_subsys != nullptr) *target_subsys = nullptr;

// if a large ship, lock to pos closest to center and within range
if ( (target_shipp) && (Ship_info[target_shipp->ship_info_index].is_big_or_huge()) ) {
Expand Down Expand Up @@ -764,7 +764,7 @@ void hud_lock_acquire_current_target(object *target_objp, ship_subsys *target_su
lock_dot=vm_vec_dot(&Player_obj->orient.vec.fvec, &vec_to_lock);
if ( lock_dot > best_lock_dot ) {
best_lock_dot=lock_dot;
target_subsys = ss;
*target_subsys = ss;
}
}
ss = GET_NEXT( ss );
Expand Down Expand Up @@ -1073,7 +1073,7 @@ void hud_lock_determine_lock_target(lock_info *lock_slot, weapon_info *wip)
}
}
} else {
hud_lock_acquire_current_target(lock_slot->obj, lock_slot->subsys);
hud_lock_acquire_current_target(lock_slot->obj, &lock_slot->subsys);
}
}
} else {
Expand Down Expand Up @@ -1124,7 +1124,7 @@ void hud_lock_determine_lock_target(lock_info *lock_slot, weapon_info *wip)
}
}
} else {
hud_lock_acquire_current_target(lock_slot->obj, lock_slot->subsys);
hud_lock_acquire_current_target(lock_slot->obj, &lock_slot->subsys);
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions code/missionui/missionshipchoice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2432,7 +2432,7 @@ commit_pressed_status create_wings(bool API_Access)
ss_slot_info *ws;
wing *wp;

int shipnum, objnum, slot_index;
int shipnum, slot_index;
int cleanup_ship_index[MAX_WING_SLOTS];
int i,j,k;

Expand Down Expand Up @@ -2465,8 +2465,6 @@ commit_pressed_status create_wings(bool API_Access)
return commit_pressed_status::PLAYER_NO_WEAPONS;
}

objnum = OBJ_INDEX(Player_obj);
shipnum = Objects[objnum].instance;
} else {
// We should always update the parse object information, even if the ship is present at start,
// because the wing might have more than one wave or scripting functions might need accurate data
Expand Down
2 changes: 0 additions & 2 deletions code/parse/sexp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34313,7 +34313,6 @@ void add_block_variable(const char *text, const char *var_name, int type, int in

strcpy_s(Block_variables[index].text, text);
strcpy_s(Block_variables[index].variable_name, var_name);
Block_variables[index].type &= ~SEXP_VARIABLE_NOT_USED;
Block_variables[index].type = (type | SEXP_VARIABLE_SET);

}
Expand All @@ -34340,7 +34339,6 @@ int sexp_add_variable(const char *text, const char *var_name, int type, int inde
if (index >= 0) {
strcpy_s(Sexp_variables[index].text, text);
strcpy_s(Sexp_variables[index].variable_name, var_name);
Sexp_variables[index].type &= ~SEXP_VARIABLE_NOT_USED;
Sexp_variables[index].type = (type | SEXP_VARIABLE_SET);
}

Expand Down
3 changes: 2 additions & 1 deletion code/pilotfile/csg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ void pilotfile::csg_read_info()
Assertion ((idx < (int)ship_list.size()), "Campaign file contains an incorrect value for the last flown ship class. No data in ship_list for ship number %d.", idx);
if (idx >= (int)ship_list.size())
idx = -1;
else if (idx != -1)

if (idx != -1)
p->last_ship_flown_si_index = ship_list[idx].index;
else
p->last_ship_flown_si_index = -1;
Expand Down
2 changes: 0 additions & 2 deletions code/ship/ship.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19893,7 +19893,6 @@ float ArmorType::GetDamage(float damage_applied, int in_damage_type_idx, float d
// Nuke: idiotproof this, no segfault 4 u
if ( (storage_idx < 0) || (storage_idx >= AT_NUM_STORAGE_LOCATIONS) ) {
Warning(LOCATION, "+Value: for +Store: calculation out of range. Should be between 0 and %i. Read: %i, Skipping calculation.", AT_NUM_STORAGE_LOCATIONS, storage_idx);
storage_idx = 0;
} else {
storage[storage_idx] = damage_applied;
}
Expand All @@ -19907,7 +19906,6 @@ float ArmorType::GetDamage(float damage_applied, int in_damage_type_idx, float d
// Nuke: idiotproof this, no segfault 4 u
if ( (storage_idx < 0) || (storage_idx >= AT_NUM_STORAGE_LOCATIONS) ) {
Warning(LOCATION, "+Value: for +Load: calculation out of range. Should be between 0 and %i. Read: %i, Skipping calculation.", AT_NUM_STORAGE_LOCATIONS, storage_idx);
storage_idx = 0;
} else {
damage_applied = storage[storage_idx];
}
Expand Down
3 changes: 1 addition & 2 deletions code/starfield/starfield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1742,7 +1742,6 @@ void stars_draw_stars()

int i;
star *sp;
float dist = 0.0f;
float ratio;
vDist vDst;
vertex p1, p2;
Expand Down Expand Up @@ -1793,7 +1792,7 @@ void stars_draw_stars()
}

if ( can_draw && (Star_flags & (STAR_FLAG_TAIL|STAR_FLAG_DIM)) ) {
dist = vm_vec_dist_quick( &sp->last_star_pos, &p2.world );
float dist = vm_vec_dist_quick( &sp->last_star_pos, &p2.world );

if ( dist > Star_max_length ) {
ratio = Star_max_length / dist;
Expand Down