Eliminate implicit conversions

Use explicit conversions everywhere. Adding bounds check assertions when
necessary.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui
2019-03-30 09:07:21 +00:00
parent 532a90d573
commit 0037b7e5fb
35 changed files with 786 additions and 671 deletions

View File

@@ -14,20 +14,10 @@ double sum_kernel(const conv *map, int x, int y, int width, int height) {
double ret = 0;
// Compute sum of values which are "in range"
int xstart = x, xend = width + x;
if (xstart < 0) {
xstart = 0;
}
if (xend > map->w) {
xend = map->w;
}
int ystart = y, yend = height + y;
if (ystart < 0) {
ystart = 0;
}
if (yend > map->h) {
yend = map->h;
}
int xstart = normalize_i_range(x, 0, map->w),
xend = normalize_i_range(width + x, 0, map->w);
int ystart = normalize_i_range(y, 0, map->h),
yend = normalize_i_range(height + y, 0, map->h);
assert(yend >= ystart && xend >= xstart);
int d = map->w;
@@ -70,11 +60,11 @@ static double attr_const gaussian(double r, double x, double y) {
conv *gaussian_kernel(double r) {
conv *c;
int size = r * 2 + 1;
int size = (int)r * 2 + 1;
int center = size / 2;
double t;
c = cvalloc(sizeof(conv) + size * size * sizeof(double));
c = cvalloc(sizeof(conv) + (size_t)(size * size) * sizeof(double));
c->w = c->h = size;
c->rsum = NULL;
t = 0.0;