forked from github/server
cppcheck: scope reductions and a false positive.
This commit is contained in:
parent
398a258658
commit
b5ea102372
4 changed files with 16 additions and 17 deletions
|
@ -1190,15 +1190,13 @@ attrib_allocation(const resource_type * rtype, region * r, allocation * alist)
|
|||
assert(avail == 0 || nreq == 0);
|
||||
}
|
||||
|
||||
typedef void(*allocate_function) (const resource_type *, struct region *,
|
||||
struct allocation *);
|
||||
|
||||
static allocate_function get_allocator(const struct resource_type *rtype)
|
||||
{
|
||||
static void allocate(const resource_type *rtype, region *r, allocation *data) {
|
||||
if (rtype->raw) {
|
||||
return leveled_allocation;
|
||||
leveled_allocation(rtype, r, data);
|
||||
}
|
||||
else {
|
||||
attrib_allocation(rtype, r, data);
|
||||
}
|
||||
return attrib_allocation;
|
||||
}
|
||||
|
||||
void split_allocations(region * r)
|
||||
|
@ -1207,11 +1205,10 @@ void split_allocations(region * r)
|
|||
while (*p_alist) {
|
||||
allocation_list *alist = *p_alist;
|
||||
const resource_type *rtype = alist->type;
|
||||
allocate_function alloc = get_allocator(rtype);
|
||||
const item_type *itype = resource2item(rtype);
|
||||
allocation **p_al = &alist->data;
|
||||
|
||||
alloc(rtype, r, alist->data);
|
||||
allocate(rtype, r, alist->data);
|
||||
|
||||
while (*p_al) {
|
||||
allocation *al = *p_al;
|
||||
|
|
|
@ -304,7 +304,6 @@ void nr_spell_syntax(struct stream *out, spellbook_entry * sbe, const struct loc
|
|||
};
|
||||
starget *targetp;
|
||||
char cp = *params++;
|
||||
int i, maxparam = 0;
|
||||
const char *locp;
|
||||
const char *syntaxp = sp->syntax;
|
||||
|
||||
|
@ -359,6 +358,7 @@ void nr_spell_syntax(struct stream *out, spellbook_entry * sbe, const struct loc
|
|||
WARN_STATIC_BUFFER();
|
||||
}
|
||||
else if (cp == 'k') {
|
||||
int i, maxparam = 0;
|
||||
bool multi = false;
|
||||
if (params && *params == 'c') {
|
||||
/* skip over a potential id */
|
||||
|
|
|
@ -575,7 +575,6 @@ report_resources(const region * r, resource_report * result, int size,
|
|||
if (see_unit) {
|
||||
rawmaterial *res = r->resources;
|
||||
while (res) {
|
||||
int maxskill = 0;
|
||||
const item_type *itype = resource2item(res->rtype);
|
||||
int minskill = itype->construction->minskill;
|
||||
skill_t skill = itype->construction->skill;
|
||||
|
@ -588,6 +587,7 @@ report_resources(const region * r, resource_report * result, int size,
|
|||
}
|
||||
else {
|
||||
const unit *u;
|
||||
int maxskill = 0;
|
||||
for (u = r->units; visible != res->amount && u != NULL; u = u->next) {
|
||||
if (u->faction == viewer) {
|
||||
int s = effskill(u, skill, 0);
|
||||
|
@ -923,7 +923,7 @@ spskill(char *buffer, size_t size, const struct locale * lang,
|
|||
const struct unit * u, struct skill * sv, int *dh, int days)
|
||||
{
|
||||
char *bufp = buffer;
|
||||
int i, effsk;
|
||||
int effsk;
|
||||
|
||||
if (!u->number)
|
||||
return 0;
|
||||
|
@ -953,7 +953,7 @@ spskill(char *buffer, size_t size, const struct locale * lang,
|
|||
}
|
||||
|
||||
if (sv->id == SK_STEALTH && fval(u, UFL_STEALTH)) {
|
||||
i = u_geteffstealth(u);
|
||||
int i = u_geteffstealth(u);
|
||||
if (i >= 0) {
|
||||
if (wrptr(&bufp, &size, snprintf(bufp, size, "%d/", i)) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
|
@ -2276,7 +2276,6 @@ static void eval_trail(struct opstack **stack, const void *userdata)
|
|||
{ /* order -> string */
|
||||
const faction *report = (const faction *)userdata;
|
||||
const struct locale *lang = report ? report->locale : default_locale;
|
||||
int i, end = 0, begin = 0;
|
||||
const arg_regions *aregs = (const arg_regions *)opop(stack).v;
|
||||
char buf[512];
|
||||
size_t size = sizeof(buf) - 1;
|
||||
|
@ -2288,6 +2287,7 @@ static void eval_trail(struct opstack **stack, const void *userdata)
|
|||
#endif
|
||||
|
||||
if (aregs != NULL) {
|
||||
int i, end = 0, begin = 0;
|
||||
end = aregs->nregions;
|
||||
for (i = begin; i < end; ++i) {
|
||||
region *r = aregs->regions[i];
|
||||
|
|
|
@ -475,10 +475,10 @@ typedef enum study_rule_t {
|
|||
static double study_speedup(unit * u, skill_t s, study_rule_t rule)
|
||||
{
|
||||
#define MINTURN 16
|
||||
double learnweeks = 0;
|
||||
int i;
|
||||
if (turn > MINTURN) {
|
||||
if (rule == STUDY_FASTER) {
|
||||
double learnweeks = 0;
|
||||
int i;
|
||||
for (i = 0; i != u->skill_size; ++i) {
|
||||
skill *sv = u->skills + i;
|
||||
if (sv->id == s) {
|
||||
|
@ -491,6 +491,8 @@ static double study_speedup(unit * u, skill_t s, study_rule_t rule)
|
|||
return 2.0; /* If the skill was not found it is the first study. */
|
||||
}
|
||||
if (rule == STUDY_AUTOTEACH) {
|
||||
double learnweeks = 0;
|
||||
int i;
|
||||
for (i = 0; i != u->skill_size; ++i) {
|
||||
skill *sv = u->skills + i;
|
||||
learnweeks += (sv->level * (sv->level + 1) / 2.0);
|
||||
|
@ -547,7 +549,6 @@ int study_cmd(unit * u, order * ord)
|
|||
{
|
||||
region *r = u->region;
|
||||
int p;
|
||||
magic_t mtyp;
|
||||
int l;
|
||||
int studycost, days;
|
||||
double multi = 1.0;
|
||||
|
@ -621,6 +622,7 @@ int study_cmd(unit * u, order * ord)
|
|||
}
|
||||
|
||||
if (sk == SK_MAGIC) {
|
||||
magic_t mtyp;
|
||||
if (u->number > 1) {
|
||||
cmistake(u, ord, 106, MSG_MAGIC);
|
||||
return -1;
|
||||
|
|
Loading…
Reference in a new issue