From 23112a0d6078e7d727979cfee06ad07a189800ee Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 25 Aug 2013 11:35:05 -0400 Subject: [PATCH] cppcheck and style fizes. --- attack.c | 2 +- edit.c | 19 ++++++++----------- empire.c | 1 - map.c | 4 ++-- math.c | 2 ++ object.c | 4 +--- usermove.c | 13 ++++++------- 7 files changed, 20 insertions(+), 25 deletions(-) diff --git a/attack.c b/attack.c index 57a62e2..9071f0c 100644 --- a/attack.c +++ b/attack.c @@ -140,12 +140,12 @@ describe(piece_info_t *win_obj, piece_info_t *lose_obj, loc_t loc) { char buf[STRSIZE]; char buf2[STRSIZE]; - int diff; *buf = '\0'; *buf2 = '\0'; if (win_obj->owner != lose_obj->owner) { + int diff; if (win_obj->owner == USER) { user_score += piece_attr[lose_obj->type].build_time; ksend ("Enemy %s at %d destroyed.\n",piece_attr[lose_obj->type].name,loc_disp(loc)); //kermyt diff --git a/edit.c b/edit.c index 7e55f17..c2e9d8e 100644 --- a/edit.c +++ b/edit.c @@ -311,16 +311,13 @@ static char dirs[] = "WEDCXZAQ"; void e_stasis(loc_t loc) { - char e; - char *p; - if (!isupper (user_map[loc].contents)) huh (); /* no object here */ else if (user_map[loc].contents == 'X') huh (); else { - e = get_chx(); /* get a direction */ - p = strchr (dirs, e); + char e = get_chx(); /* get a direction */ + char *p = strchr (dirs, e); if (p == NULL) huh (); @@ -446,13 +443,13 @@ End of move to location. void e_end(loc_t *path_start, loc_t loc, int path_type) -{ - city_info_t *cityp; - - if (*path_start == -1) huh (); /* no path started? */ - else if (path_type == NOPIECE) e_set_func (*path_start, loc); +{ + if (*path_start == -1) + huh (); /* no path started? */ + else if (path_type == NOPIECE) + e_set_func (*path_start, loc); else { - cityp = find_city (*path_start); + city_info_t *cityp = find_city (*path_start); ASSERT (cityp); e_set_city_func (cityp, path_type, loc); } diff --git a/empire.c b/empire.c index 831aec2..c389e68 100644 --- a/empire.c +++ b/empire.c @@ -177,7 +177,6 @@ do_command(char orders) else huh (); /* illegal command */ break; } - e = e; /* keep lint quiet */ } /* diff --git a/map.c b/map.c index aaacb22..dca7c81 100644 --- a/map.c +++ b/map.c @@ -392,7 +392,7 @@ vmap_find_lwobj(path_map_t path_map[], view_map_t *vmap, } } -#ifdef FUNCTION_WAS_NEVER_CALLED +#ifdef __UNUSED__ /* Return the cost to reach the adjacent cell of the correct type with the lowest cost. @@ -406,7 +406,7 @@ best_adj(path_map_t *pmap, loc_t loc, int type) int best; best = INFINITY; - + FOR_ADJ (loc, new_loc, i) if (pmap[new_loc].terrain == type && pmap[new_loc].cost < best) best = pmap[new_loc].cost; diff --git a/math.c b/math.c index e59ac37..d3a90bc 100644 --- a/math.c +++ b/math.c @@ -38,6 +38,7 @@ long irand(long high) return (rand() % high); } +#ifdef __UNUSED__ int rndint(int minp, int maxp) { int size; @@ -45,6 +46,7 @@ int rndint(int minp, int maxp) size = maxp - minp + 1; return ((rand() % size) + minp); } +#endif /* Return the distance between two locations. This is simply diff --git a/object.c b/object.c index 252a202..0283c44 100644 --- a/object.c +++ b/object.c @@ -560,15 +560,13 @@ char city_char[] = {'*', 'O', 'X'}; void update(view_map_t vmap[], loc_t loc) { - piece_info_t *p; - vmap[loc].seen = date; if (map[loc].cityp) /* is there a city here? */ vmap[loc].contents = city_char[map[loc].cityp->owner]; else { - p = find_obj_at_loc (loc); + piece_info_t *p = find_obj_at_loc (loc); if (p == NULL) /* nothing here? */ vmap[loc].contents = map[loc].contents; diff --git a/usermove.c b/usermove.c index 8944368..f204239 100644 --- a/usermove.c +++ b/usermove.c @@ -295,7 +295,6 @@ move_armyload(piece_info_t *obj) { loc_t loc; piece_info_t *p; - int i; ABORT; @@ -307,6 +306,7 @@ move_armyload(piece_info_t *obj) obj->func = NOFUNC; } else { /* look for nearest non-full transport */ + int i; (void) memcpy (amap, user_map, sizeof (view_map_t) * MAP_SIZE); /* mark loading transports or cities building transports */ @@ -612,12 +612,9 @@ Print out help information. void user_help(void) { - char c; - help (help_user, user_lines); prompt ("Press any key to continue: "); - c = get_chx (); - c = c; /* keep lint happy */ + (void)get_chx (); } /* @@ -888,7 +885,8 @@ user_dir_army(piece_info_t *obj, loc_t loc) } if (obj->hits > 0) { kill_obj (obj, loc); - if (enemy_killed) scan (comp_map, loc); + if (enemy_killed) + scan (comp_map, loc); } } @@ -970,7 +968,8 @@ user_dir_ship(piece_info_t *obj, loc_t loc) } if (obj->hits > 0) { kill_obj (obj, loc); - if (enemy_killed) scan (comp_map, loc); + if (enemy_killed) + scan (comp_map, loc); } } -- 2.43.0