forked from github/server
Merge pull request #367 from ennorehling/coverity-scan
Coverity scan fixes, part n+1
This commit is contained in:
commit
c0af920d0d
|
@ -335,3 +335,14 @@ function test_stonegolems()
|
|||
assert_equal(1 ,u2.number, "There shoud be one Stone Golems")
|
||||
-- end test Stone Golems four stones
|
||||
end
|
||||
|
||||
|
||||
function test_birthdaycake()
|
||||
r = region.create(0,0, "plain")
|
||||
f = faction.create("cake@eressea.de", "human", "de")
|
||||
u = unit.create(f, r, 1)
|
||||
u:add_item("birthdaycake", 1)
|
||||
u:clear_orders()
|
||||
u:add_order("ZEIGE Geburtstagstorte")
|
||||
process_orders()
|
||||
end
|
||||
|
|
|
@ -193,11 +193,9 @@ static int tolua_building_create(lua_State * L)
|
|||
const char *bname = tolua_tostring(L, 2, 0);
|
||||
if (!r) {
|
||||
log_error("building.create expects a region as argument 1");
|
||||
}
|
||||
if (!bname) {
|
||||
} else if (!bname) {
|
||||
log_error("building.create expects a name as argument 2");
|
||||
}
|
||||
if (bname) {
|
||||
} else {
|
||||
const building_type *btype = bt_find(bname);
|
||||
if (btype) {
|
||||
building *b = new_building(btype, r, default_locale);
|
||||
|
|
|
@ -746,7 +746,6 @@ void cr_output_unit(stream *out, const region * r, const faction * f,
|
|||
building *b;
|
||||
const char *pzTmp;
|
||||
skill *sv;
|
||||
const attrib *a_fshidden = NULL;
|
||||
bool itemcloak = false;
|
||||
static const curse_type *itemcloak_ct = 0;
|
||||
static bool init = false;
|
||||
|
@ -834,13 +833,7 @@ void cr_output_unit(stream *out, const region * r, const faction * f,
|
|||
stream_printf(out, "\"%s\";typprefix\n", translate(prefix, LOC(f->locale,
|
||||
prefix)));
|
||||
}
|
||||
if (u->faction != f && a_fshidden
|
||||
&& a_fshidden->data.ca[0] == 1 && effskill(u, SK_STEALTH, 0) >= 6) {
|
||||
stream_printf(out, "-1;Anzahl\n");
|
||||
}
|
||||
else {
|
||||
stream_printf(out, "%d;Anzahl\n", u->number);
|
||||
}
|
||||
|
||||
pzTmp = get_racename(u->attribs);
|
||||
if (pzTmp) {
|
||||
|
@ -981,8 +974,7 @@ void cr_output_unit(stream *out, const region * r, const faction * f,
|
|||
if (f == u->faction || omniscient(f)) {
|
||||
show = u->items;
|
||||
}
|
||||
else if (!itemcloak && mode >= see_unit && !(a_fshidden
|
||||
&& a_fshidden->data.ca[1] == 1 && effskill(u, SK_STEALTH, 0) >= 3)) {
|
||||
else if (!itemcloak && mode >= see_unit) {
|
||||
int n = report_items(u->items, result, MAX_INVENTORY, u, f);
|
||||
assert(n >= 0);
|
||||
if (n > 0)
|
||||
|
|
|
@ -983,6 +983,7 @@ static void handlekey(state * st, int c)
|
|||
statusline(st->wnd_status->handle, "info-buildings true");
|
||||
else
|
||||
statusline(st->wnd_status->handle, "info-buildings false");
|
||||
break;
|
||||
case 'f':
|
||||
st->info_flags ^= IFL_FACTIONS;
|
||||
if (st->info_flags & IFL_FACTIONS)
|
||||
|
@ -1245,7 +1246,7 @@ void run_mapper(void)
|
|||
curs_set(1);
|
||||
|
||||
set_readline(curses_readline);
|
||||
|
||||
assert(stdscr);
|
||||
getbegyx(stdscr, x, y);
|
||||
width = getmaxx(stdscr);
|
||||
height = getmaxy(stdscr);
|
||||
|
|
|
@ -151,14 +151,13 @@ connection *get_borders(const region * r1, const region * r2)
|
|||
|
||||
connection *new_border(border_type * type, region * from, region * to)
|
||||
{
|
||||
connection *b = calloc(1, sizeof(struct connection));
|
||||
connection *b, **bp = get_borders_i(from, to);
|
||||
|
||||
if (from && to) {
|
||||
connection **bp = get_borders_i(from, to);
|
||||
while (*bp)
|
||||
assert(from && to);
|
||||
while (*bp) {
|
||||
bp = &(*bp)->next;
|
||||
*bp = b;
|
||||
}
|
||||
*bp = b = calloc(1, sizeof(connection));
|
||||
b->type = type;
|
||||
b->from = from;
|
||||
b->to = to;
|
||||
|
|
|
@ -1013,7 +1013,7 @@ void transfermen(unit * u, unit * dst, int n)
|
|||
sn->level = (unsigned char)level;
|
||||
sn->weeks = (unsigned char)weeks;
|
||||
assert(sn->weeks > 0 && sn->weeks <= sn->level * 2 + 1);
|
||||
assert(dst->number != 0 || (sn->level == sv->level
|
||||
assert(dst->number != 0 || (sv && sn->level == sv->level
|
||||
&& sn->weeks == sv->weeks));
|
||||
}
|
||||
else if (sn) {
|
||||
|
|
|
@ -1321,7 +1321,7 @@ static const region_list *cap_route(region * r, const region_list * route,
|
|||
region *current = r;
|
||||
int moves = speed;
|
||||
const region_list *iroute = route;
|
||||
while (iroute != route_end) {
|
||||
while (iroute && iroute != route_end) {
|
||||
region *next = iroute->data;
|
||||
direction_t reldir = reldirection(current, next);
|
||||
|
||||
|
@ -2192,7 +2192,7 @@ static void travel(unit * u, region_list ** routep)
|
|||
region_list *route_begin = NULL;
|
||||
follower *followers = NULL;
|
||||
|
||||
if (routep)
|
||||
assert(routep);
|
||||
*routep = NULL;
|
||||
|
||||
/* a few pre-checks that need not be done for each step: */
|
||||
|
|
|
@ -580,8 +580,8 @@ volcano_destruction(region * volcano, region * r, const char *damage)
|
|||
rsettrees(r, 0, 0);
|
||||
|
||||
a = a_find(r->attribs, &at_reduceproduction);
|
||||
if (!a) {
|
||||
a = make_reduceproduction(percent, time);
|
||||
if (a) {
|
||||
a = a_add(&r->attribs, make_reduceproduction(percent, time));
|
||||
}
|
||||
else {
|
||||
/* Produktion vierteln ... */
|
||||
|
|
|
@ -456,7 +456,6 @@ size_t size)
|
|||
building *b;
|
||||
bool isbattle = (bool)(mode == see_battle);
|
||||
int telepath_see = 0;
|
||||
attrib *a_fshidden = NULL;
|
||||
item *itm;
|
||||
item *show;
|
||||
faction *fv = visible_faction(f, u);
|
||||
|
@ -520,14 +519,8 @@ size_t size)
|
|||
|
||||
bufp = STRLCPY(bufp, ", ", size);
|
||||
|
||||
if (u->faction != f && a_fshidden && a_fshidden->data.ca[0] == 1
|
||||
&& effskill(u, SK_STEALTH, 0) >= 6) {
|
||||
bufp = STRLCPY(bufp, "? ", size);
|
||||
}
|
||||
else {
|
||||
if (wrptr(&bufp, &size, _snprintf(bufp, size, "%d ", u->number)))
|
||||
WARN_STATIC_BUFFER();
|
||||
}
|
||||
|
||||
pzTmp = get_racename(u->attribs);
|
||||
if (pzTmp) {
|
||||
|
@ -607,8 +600,7 @@ size_t size)
|
|||
if (f == u->faction || telepath_see || omniscient(f)) {
|
||||
show = u->items;
|
||||
}
|
||||
else if (!itemcloak && mode >= see_unit && !(a_fshidden
|
||||
&& a_fshidden->data.ca[1] == 1 && effskill(u, SK_STEALTH, 0) >= 3)) {
|
||||
else if (!itemcloak && mode >= see_unit) {
|
||||
int n = report_items(u->items, results, MAX_INVENTORY, u, f);
|
||||
assert(n >= 0);
|
||||
if (n > 0)
|
||||
|
@ -1555,14 +1547,18 @@ int write_reports(faction * f, time_t ltime)
|
|||
struct report_context ctx;
|
||||
const char *encoding = "UTF-8";
|
||||
report_type *rtype;
|
||||
const char *path = reportpath();;
|
||||
|
||||
if (noreports) {
|
||||
return false;
|
||||
}
|
||||
prepare_report(&ctx, f);
|
||||
get_addresses(&ctx);
|
||||
if (_access(reportpath(), 0) < 0) {
|
||||
_mkdir(reportpath());
|
||||
if (_access(path, 0) < 0) {
|
||||
if (_mkdir(path) != 0) {
|
||||
log_error("could not create reports directory %s: %s", path, strerror(errno));
|
||||
abort();
|
||||
}
|
||||
}
|
||||
if (errno) {
|
||||
log_warning("errno was %d before writing reports", errno);
|
||||
|
@ -1661,12 +1657,18 @@ int reports(void)
|
|||
time_t ltime = time(NULL);
|
||||
int retval = 0;
|
||||
char path[MAX_PATH];
|
||||
const char * rpath = reportpath();
|
||||
|
||||
log_info("Writing reports for turn %d:", turn);
|
||||
report_donations();
|
||||
remove_empty_units();
|
||||
|
||||
_mkdir(reportpath());
|
||||
if (_access(rpath, 0) < 0) {
|
||||
if (_mkdir(rpath) != 0) {
|
||||
log_error("could not create reports directory %s: %s", rpath, strerror(errno));
|
||||
abort();
|
||||
}
|
||||
}
|
||||
sprintf(path, "%s/reports.txt", reportpath());
|
||||
mailit = fopen(path, "w");
|
||||
if (mailit == NULL) {
|
||||
|
|
2
storage
2
storage
|
@ -1 +1 @@
|
|||
Subproject commit 1d92cb36df41c183c378aad17cbbfc0eddbb5c84
|
||||
Subproject commit 89f3c1b01e41f2675fcbfd51fd8494894dc22d44
|
Loading…
Reference in New Issue