From 15a6d9217b61472e876c151d3058e51680c547af Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 2 Dec 2018 11:13:58 +0100 Subject: [PATCH] cppcheck style --- src/attributes/key.c | 4 ++-- src/attributes/seenspell.c | 3 +-- src/automate.c | 4 ++-- src/bind_unit.c | 1 - 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/attributes/key.c b/src/attributes/key.c index cd369de66..66af66b89 100644 --- a/src/attributes/key.c +++ b/src/attributes/key.c @@ -121,7 +121,7 @@ static int read_keyval_orig(gamedata *data, int *keys, int n) { #endif static int a_readkeys(variant *var, void *owner, gamedata *data) { - int i, n, ksn, *keys; + int n, ksn, *keys; READ_INT(data->store, &n); assert(n < 4096 && n >= 0); @@ -155,7 +155,7 @@ static int a_readkeys(variant *var, void *owner, gamedata *data) { } keys[0] = n; if (data->version < SORTKEYS_VERSION) { - int e = 1; + int i, e = 1; for (i = 1; i != n; ++i) { int k = keys[i * 2 + 1]; int v = keys[i * 2 + 2]; diff --git a/src/attributes/seenspell.c b/src/attributes/seenspell.c index ae46980c3..082eecc6b 100644 --- a/src/attributes/seenspell.c +++ b/src/attributes/seenspell.c @@ -48,13 +48,12 @@ static int read_seenspells(variant *var, void *owner, struct gamedata *data) { selist *ql = NULL; storage *store = data->store; - spell *sp = 0; char token[32]; UNUSED_ARG(owner); READ_TOK(store, token, sizeof(token)); while (token[0]) { - sp = find_spell(token); + spell *sp = find_spell(token); if (!sp) { log_info("read_seenspells: could not find spell '%s'\n", token); return AT_READ_FAIL; diff --git a/src/automate.c b/src/automate.c index 4332dc8e8..b47121183 100644 --- a/src/automate.c +++ b/src/automate.c @@ -82,7 +82,7 @@ void autostudy_run(scholar scholars[], int nscholars) int ti = 0; while (ti != nscholars) { skill_t sk = scholars[ti].sk; - int t, s, se, ts = 0, tt = 0, si = ti; + int t, se, ts = 0, tt = 0, si = ti; for (se = ti; se != nscholars && scholars[se].sk == sk; ++se) { int mint; ts += scholars[se].u->number; /* count total scholars */ @@ -108,7 +108,7 @@ void autostudy_run(scholar scholars[], int nscholars) } else { /* invariant: unit ti can still teach i students */ - int i = scholars[ti].u->number * STUDENTS_PER_TEACHER; + int s, i = scholars[ti].u->number * STUDENTS_PER_TEACHER; /* invariant: unit si has n students that can still be taught */ int n = scholars[si].u->number; for (t = ti, s = si; t != si && s != se; ) { diff --git a/src/bind_unit.c b/src/bind_unit.c index 5303c4562..d2bec0f3e 100644 --- a/src/bind_unit.c +++ b/src/bind_unit.c @@ -22,7 +22,6 @@ #include "kernel/skills.h" #include "kernel/types.h" #include -#include #include #include "kernel/equipment.h" #include