fix -Wconversion for move.c

This commit is contained in:
Enno Rehling 2015-05-15 06:43:47 +02:00
parent a46d60aa97
commit fe29e29c31
4 changed files with 17 additions and 14 deletions

View File

@ -984,7 +984,7 @@ static bool is_guardian_r(const unit * guard)
return true;
}
bool is_guard(const struct unit * u, int mask)
bool is_guard(const struct unit * u, unsigned int mask)
{
return is_guardian_r(u) && (getguard(u) & mask) != 0;
}
@ -1140,7 +1140,8 @@ static const char *shortdirections[MAXDIRECTIONS] = {
static void cycle_route(order * ord, unit * u, int gereist)
{
int bytes, cm = 0;
size_t bytes;
int cm = 0;
char tail[1024], *bufp = tail;
char neworder[2048];
char token[128];
@ -1180,11 +1181,11 @@ static void cycle_route(order * ord, unit * u, int gereist)
if (!pause) {
const char *loc = LOC(lang, shortdirections[d]);
if (bufp != tail) {
bytes = (int)strlcpy(bufp, " ", size);
bytes = strlcpy(bufp, " ", size);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
}
bytes = (int)strlcpy(bufp, loc, size);
bytes = strlcpy(bufp, loc, size);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
}
@ -1193,10 +1194,10 @@ static void cycle_route(order * ord, unit * u, int gereist)
break;
else if (cm == gereist && !paused && pause) {
const char *loc = LOC(lang, parameters[P_PAUSE]);
bytes = (int)strlcpy(bufp, " ", size);
bytes = strlcpy(bufp, " ", size);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
bytes = (int)strlcpy(bufp, loc, size);
bytes = strlcpy(bufp, loc, size);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
paused = true;
@ -1565,8 +1566,9 @@ static arg_regions *var_copy_regions(const region_list * begin, int size)
if (size > 0) {
int i = 0;
assert(size>0);
arg_regions *dst =
(arg_regions *)malloc(sizeof(arg_regions) + sizeof(region *) * size);
(arg_regions *)malloc(sizeof(arg_regions) + sizeof(region *) * (size_t)size);
dst->nregions = size;
dst->regions = (region **)(dst + 1);
for (rsrc = begin; i != size; rsrc = rsrc->next) {
@ -2536,7 +2538,8 @@ static direction_t hunted_dir(attrib * at, int id)
static int hunt(unit * u, order * ord)
{
region *rc = u->region;
int bytes, moves, id, speed;
size_t bytes;
int moves, id, speed;
char command[256], *bufp = command;
size_t size = sizeof(command);
direction_t dir;
@ -2581,7 +2584,7 @@ static int hunt(unit * u, order * ord)
moves = 1;
speed = getuint();
speed = (int)getuint();
if (speed == 0) {
speed = shipspeed(u->ship, u);
}
@ -2592,10 +2595,10 @@ static int hunt(unit * u, order * ord)
}
rc = rconnect(rc, dir);
while (moves < speed && (dir = hunted_dir(rc->attribs, id)) != NODIRECTION) {
bytes = (int)strlcpy(bufp, " ", size);
bytes = strlcpy(bufp, " ", size);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
bytes = (int)strlcpy(bufp, LOC(u->faction->locale, directions[dir]), size);
bytes = strlcpy(bufp, LOC(u->faction->locale, directions[dir]), size);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
moves++;

View File

@ -60,7 +60,7 @@ extern "C" {
void movement(void);
void run_to(struct unit *u, struct region *to);
struct unit *is_guarded(struct region *r, struct unit *u, unsigned int mask);
bool is_guard(const struct unit *u, int mask);
bool is_guard(const struct unit *u, unsigned int mask);
int enoughsailors(const struct ship *sh, const struct region *r);
bool canswim(struct unit *u);
bool canfly(struct unit *u);

View File

@ -7,7 +7,7 @@
#include "bsdstring.h"
int wrptr(char **ptr, size_t * size, int bytes)
int wrptr(char **ptr, size_t * size, size_t bytes)
{
if (bytes == 0) {
return 0;

View File

@ -2,7 +2,7 @@
#define UTIL_BSDSTRING_H
#include <stddef.h>
extern int wrptr(char **ptr, size_t * size, int bytes);
extern int wrptr(char **ptr, size_t * size, size_t bytes);
#ifndef HAVE_STRLCPY
extern size_t strlcpy(char *dst, const char *src, size_t siz);