Skip to content

Commit

Permalink
Integral Type Police
Browse files Browse the repository at this point in the history
clear some int/unsigned/size_t confusions
  • Loading branch information
matteo-frigo committed Jun 5, 2016
1 parent 29cee6c commit d9a3f48
Show file tree
Hide file tree
Showing 19 changed files with 58 additions and 57 deletions.
6 changes: 3 additions & 3 deletions api/apiplan.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void X(set_planner_hooks)(planner_hook_t before, planner_hook_t after)
}

static plan *mkplan0(planner *plnr, unsigned flags,
const problem *prb, int hash_info,
const problem *prb, unsigned hash_info,
wisdom_state_t wisdom_state)
{
/* map API flags into FFTW flags */
Expand All @@ -49,7 +49,7 @@ static unsigned force_estimator(unsigned flags)
}

static plan *mkplan(planner *plnr, unsigned flags,
const problem *prb, int hash_info)
const problem *prb, unsigned hash_info)
{
plan *pln;

Expand Down Expand Up @@ -121,7 +121,7 @@ apiplan *X(mkapiplan)(int sign, unsigned flags, problem *prb)
for (pln = 0, flags_used_for_planning = 0; pat <= pat_max; ++pat) {
plan *pln1;
unsigned tmpflags = flags | pats[pat];
pln1 = mkplan(plnr, tmpflags, prb, 0);
pln1 = mkplan(plnr, tmpflags, prb, 0u);

if (!pln1) {
/* don't bother continuing if planner failed or timed out */
Expand Down
6 changes: 3 additions & 3 deletions api/f77api.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static int *reverse_n(int rnk, const int *n)
int *nrev;
int i;
A(FINITE_RNK(rnk));
nrev = (int *) MALLOC(sizeof(int) * rnk, PROBLEMS);
nrev = (int *) MALLOC(sizeof(int) * (unsigned)rnk, PROBLEMS);
for (i = 0; i < rnk; ++i)
nrev[rnk - i - 1] = n[i];
return nrev;
Expand All @@ -52,7 +52,7 @@ static X(iodim) *make_dims(int rnk, const int *n,
X(iodim) *dims;
int i;
A(FINITE_RNK(rnk));
dims = (X(iodim) *) MALLOC(sizeof(X(iodim)) * rnk, PROBLEMS);
dims = (X(iodim) *) MALLOC(sizeof(X(iodim)) * (unsigned)rnk, PROBLEMS);
for (i = 0; i < rnk; ++i) {
dims[i].n = n[i];
dims[i].is = is[i];
Expand Down Expand Up @@ -93,7 +93,7 @@ static X(r2r_kind) *ints2kinds(int rnk, const int *ik)
int i;
X(r2r_kind) *k;

k = (X(r2r_kind) *) MALLOC(sizeof(X(r2r_kind)) * rnk, PROBLEMS);
k = (X(r2r_kind) *) MALLOC(sizeof(X(r2r_kind)) * (unsigned)rnk, PROBLEMS);
/* reverse order for Fortran -> C */
for (i = 0; i < rnk; ++i)
k[i] = (X(r2r_kind)) ik[rnk - 1 - i];
Expand Down
2 changes: 1 addition & 1 deletion api/map-r2r-kind.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ rdft_kind *X(map_r2r_kind)(int rank, const X(r2r_kind) * kind)
rdft_kind *k;

A(FINITE_RNK(rank));
k = (rdft_kind *) MALLOC(rank * sizeof(rdft_kind), PROBLEMS);
k = (rdft_kind *) MALLOC((unsigned)rank * sizeof(rdft_kind), PROBLEMS);
for (i = 0; i < rank; ++i) {
rdft_kind m;
switch (kind[i]) {
Expand Down
4 changes: 2 additions & 2 deletions api/mapflags.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ typedef struct {
#define NEQV(a, b) IMPLIES(YES(a), NO(b)), IMPLIES(NO(a), YES(b))

static void map_flags(unsigned *iflags, unsigned *oflags,
const flagop flagmap[], int nmap)
const flagop flagmap[], size_t nmap)
{
int i;
size_t i;
for (i = 0; i < nmap; ++i)
if (FLAGP(*iflags, flagmap[i].flag))
*oflags = OP(*oflags, flagmap[i].op);
Expand Down
6 changes: 3 additions & 3 deletions kernel/ifftw.h
Original file line number Diff line number Diff line change
Expand Up @@ -674,9 +674,9 @@ enum {

/* hashtable information */
enum {
BLESSING = 0x1, /* save this entry */
H_VALID = 0x2, /* valid hastable entry */
H_LIVE = 0x4 /* entry is nonempty, implies H_VALID */
BLESSING = 0x1u, /* save this entry */
H_VALID = 0x2u, /* valid hastable entry */
H_LIVE = 0x4u /* entry is nonempty, implies H_VALID */
};

#define PLNR_L(plnr) ((plnr)->flags.l)
Expand Down
8 changes: 4 additions & 4 deletions kernel/planner.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ static void register_solver(planner *ego, solver *s)

kind = s->adt->problem_kind;
n->next_for_same_problem_kind = ego->slvdescs_for_problem_kind[kind];
ego->slvdescs_for_problem_kind[kind] = ego->nslvdesc;
ego->slvdescs_for_problem_kind[kind] = (int)/*from unsigned*/ego->nslvdesc;

ego->nslvdesc++;
}
Expand All @@ -127,7 +127,7 @@ static unsigned slookup(planner *ego, char *nam, int id)
UNUSED(s);
if (sp->reg_id == id && sp->nam_hash == h
&& !strcmp(sp->reg_nam, nam))
return sp - ego->slvdescs;
return (unsigned)/*from ptrdiff_t*/(sp - ego->slvdescs);
});
return INFEASIBLE_SLVNDX;
}
Expand Down Expand Up @@ -552,13 +552,13 @@ static plan *search0(planner *ego, const problem *p, unsigned *slvndx,
if (pln->pcost < best->pcost) {
X(plan_destroy_internal)(best);
best = pln;
*slvndx = sp - ego->slvdescs;
*slvndx = (unsigned)/*from ptrdiff_t*/(sp - ego->slvdescs);
} else {
X(plan_destroy_internal)(pln);
}
} else {
best = pln;
*slvndx = sp - ego->slvdescs;
*slvndx = (unsigned)/*from ptrdiff_t*/(sp - ego->slvdescs);
}

if (ALLOW_PRUNINGP(ego) && could_prune_now_p)
Expand Down
8 changes: 4 additions & 4 deletions kernel/print.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static void putint(printer *p, INT i)
} while (f != buf);
}

static void putulong(printer *p, unsigned long i, int base, int width)
static void putulong(printer *p, unsigned long i, unsigned base, int width)
{
char buf[BSZ];
char *f = buf;
Expand Down Expand Up @@ -98,7 +98,7 @@ static void vprint(printer *p, const char *format, va_list ap)
/* md5 value */
md5uint x = va_arg(ap, md5uint);
putulong(p, (unsigned long)(0xffffffffUL & x),
16, 8);
16u, 8);
break;
}
case 'c': {
Expand Down Expand Up @@ -148,12 +148,12 @@ static void vprint(printer *p, const char *format, va_list ap)
}
case 'u': {
unsigned x = va_arg(ap, unsigned);
putulong(p, (unsigned long)x, 10, 0);
putulong(p, (unsigned long)x, 10u, 0);
break;
}
case 'x': {
unsigned x = va_arg(ap, unsigned);
putulong(p, (unsigned long)x, 16, 0);
putulong(p, (unsigned long)x, 16u, 0);
break;
}
case '(': {
Expand Down
4 changes: 2 additions & 2 deletions kernel/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static void eat_blanks(scanner *sc)
UNGETCHR(sc, ch);
}

static void mygets(scanner *sc, char *s, size_t maxlen)
static void mygets(scanner *sc, char *s, int maxlen)
{
char *s0 = s;
int ch;
Expand Down Expand Up @@ -124,7 +124,7 @@ static int vscan(scanner *sc, const char *format, va_list ap)
const char *s = format;
char c;
int ch = 0;
size_t fmt_len;
int fmt_len;

while ((c = *s++)) {
fmt_len = 0;
Expand Down
6 changes: 3 additions & 3 deletions kernel/tensor.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ tensor *X(mktensor)(int rnk)

#if defined(STRUCT_HACK_KR)
if (FINITE_RNK(rnk) && rnk > 1)
x = (tensor *)MALLOC(sizeof(tensor) + (rnk - 1) * sizeof(iodim),
x = (tensor *)MALLOC(sizeof(tensor) + (unsigned)(rnk - 1) * sizeof(iodim),
TENSORS);
else
x = (tensor *)MALLOC(sizeof(tensor), TENSORS);
#elif defined(STRUCT_HACK_C99)
if (FINITE_RNK(rnk))
x = (tensor *)MALLOC(sizeof(tensor) + rnk * sizeof(iodim),
x = (tensor *)MALLOC(sizeof(tensor) + (unsigned)rnk * sizeof(iodim),
TENSORS);
else
x = (tensor *)MALLOC(sizeof(tensor), TENSORS);
#else
x = (tensor *)MALLOC(sizeof(tensor), TENSORS);
if (FINITE_RNK(rnk) && rnk > 0)
x->dims = (iodim *)MALLOC(sizeof(iodim) * rnk, TENSORS);
x->dims = (iodim *)MALLOC(sizeof(iodim) * (unsigned)rnk, TENSORS);
else
x->dims = 0;
#endif
Expand Down
4 changes: 2 additions & 2 deletions kernel/tensor7.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ int X(dimcmp)(const iodim *a, const iodim *b)
static void canonicalize(tensor *x)
{
if (x->rnk > 1) {
qsort(x->dims, (size_t)x->rnk, sizeof(iodim),
qsort(x->dims, (unsigned)x->rnk, sizeof(iodim),
(int (*)(const void *, const void *))X(dimcmp));
}
}
Expand Down Expand Up @@ -137,7 +137,7 @@ tensor *X(tensor_compress_contiguous)(const tensor *sz)

/* sort in descending order of |istride|, so that compressible
dimensions appear contigously */
qsort(sz2->dims, (size_t)sz2->rnk, sizeof(iodim),
qsort(sz2->dims, (unsigned)sz2->rnk, sizeof(iodim),
(int (*)(const void *, const void *))compare_by_istride);

/* compute what the rank will be after compression */
Expand Down
5 changes: 3 additions & 2 deletions libbench2/bench-user.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ extern "C" {

/* benchmark program definitions for user code */
#include "config.h"
#include <limits.h>

#if HAVE_STDDEF_H
#include <stddef.h>
Expand Down Expand Up @@ -105,8 +106,8 @@ void tensor_obounds(bench_tensor *t, int *lbp, int *ubp);
A tensor of rank -infinity has size 0.
*/
#define RNK_MINFTY ((int)(((unsigned) -1) >> 1))
#define FINITE_RNK(rnk) ((rnk) != RNK_MINFTY)
#define BENCH_RNK_MINFTY INT_MAX
#define BENCH_FINITE_RNK(rnk) ((rnk) != BENCH_RNK_MINFTY)

typedef struct {
problem_kind_t kind;
Expand Down
2 changes: 1 addition & 1 deletion libbench2/dotens2.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static void recur(int rnk, const bench_iodim *dims0, const bench_iodim *dims1,
void bench_dotens2(const bench_tensor *sz0, const bench_tensor *sz1, dotens2_closure *k)
{
BENCH_ASSERT(sz0->rnk == sz1->rnk);
if (sz0->rnk == RNK_MINFTY)
if (sz0->rnk == BENCH_RNK_MINFTY)
return;
recur(sz0->rnk, sz0->dims, sz1->dims, k, 0, 0, 0, 0);
}
4 changes: 2 additions & 2 deletions libbench2/problem.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static bench_tensor *dwim(bench_tensor *t, bench_iodim **last_iodim,
int i;
bench_iodim *d, *d1;

if (!FINITE_RNK(t->rnk) || t->rnk < 1)
if (!BENCH_FINITE_RNK(t->rnk) || t->rnk < 1)
return t;

i = t->rnk;
Expand All @@ -72,7 +72,7 @@ static bench_tensor *dwim(bench_tensor *t, bench_iodim **last_iodim,

static void transpose_tensor(bench_tensor *t)
{
if (!FINITE_RNK(t->rnk) || t->rnk < 2)
if (!BENCH_FINITE_RNK(t->rnk) || t->rnk < 2)
return;

t->dims[0].os = t->dims[1].os;
Expand Down
24 changes: 12 additions & 12 deletions libbench2/tensor.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ bench_tensor *mktensor(int rnk)
BENCH_ASSERT(rnk >= 0);

x = (bench_tensor *)bench_malloc(sizeof(bench_tensor));
if (FINITE_RNK(rnk) && rnk > 0)
if (BENCH_FINITE_RNK(rnk) && rnk > 0)
x->dims = (bench_iodim *)bench_malloc(sizeof(bench_iodim) * rnk);
else
x->dims = 0;
Expand All @@ -47,7 +47,7 @@ int tensor_sz(const bench_tensor *sz)
{
int i, n = 1;

if (!FINITE_RNK(sz->rnk))
if (!BENCH_FINITE_RNK(sz->rnk))
return 0;

for (i = 0; i < sz->rnk; ++i)
Expand All @@ -71,7 +71,7 @@ bench_tensor *tensor_compress(const bench_tensor *sz)
int i, rnk;
bench_tensor *x;

BENCH_ASSERT(FINITE_RNK(sz->rnk));
BENCH_ASSERT(BENCH_FINITE_RNK(sz->rnk));
for (i = rnk = 0; i < sz->rnk; ++i) {
BENCH_ASSERT(sz->dims[i].n > 0);
if (sz->dims[i].n != 1)
Expand All @@ -95,7 +95,7 @@ bench_tensor *tensor_compress(const bench_tensor *sz)

int tensor_unitstridep(bench_tensor *t)
{
BENCH_ASSERT(FINITE_RNK(t->rnk));
BENCH_ASSERT(BENCH_FINITE_RNK(t->rnk));
return (t->rnk == 0 ||
(t->dims[t->rnk - 1].is == 1 && t->dims[t->rnk - 1].os == 1));
}
Expand All @@ -105,7 +105,7 @@ int tensor_real_rowmajorp(bench_tensor *t, int sign, int in_place)
{
int i;

BENCH_ASSERT(FINITE_RNK(t->rnk));
BENCH_ASSERT(BENCH_FINITE_RNK(t->rnk));

i = t->rnk - 1;

Expand Down Expand Up @@ -139,7 +139,7 @@ int tensor_rowmajorp(bench_tensor *t)
{
int i;

BENCH_ASSERT(FINITE_RNK(t->rnk));
BENCH_ASSERT(BENCH_FINITE_RNK(t->rnk));

i = t->rnk - 1;
while (--i >= 0) {
Expand All @@ -155,15 +155,15 @@ int tensor_rowmajorp(bench_tensor *t)
static void dimcpy(bench_iodim *dst, const bench_iodim *src, int rnk)
{
int i;
if (FINITE_RNK(rnk))
if (BENCH_FINITE_RNK(rnk))
for (i = 0; i < rnk; ++i)
dst[i] = src[i];
}

bench_tensor *tensor_append(const bench_tensor *a, const bench_tensor *b)
{
if (!FINITE_RNK(a->rnk) || !FINITE_RNK(b->rnk)) {
return mktensor(RNK_MINFTY);
if (!BENCH_FINITE_RNK(a->rnk) || !BENCH_FINITE_RNK(b->rnk)) {
return mktensor(BENCH_RNK_MINFTY);
} else {
bench_tensor *x = mktensor(a->rnk + b->rnk);
dimcpy(x->dims, a->dims, a->rnk);
Expand All @@ -189,7 +189,7 @@ void name(bench_tensor *t, int *lbp, int *ubp) \
int ub = 1; \
int i; \
\
BENCH_ASSERT(FINITE_RNK(t->rnk)); \
BENCH_ASSERT(BENCH_FINITE_RNK(t->rnk)); \
\
for (i = 0; i < t->rnk; ++i) { \
bench_iodim *d = t->dims + i; \
Expand Down Expand Up @@ -218,7 +218,7 @@ bench_tensor *tensor_copy_sub(const bench_tensor *sz, int start_dim, int rnk)
{
bench_tensor *x;

BENCH_ASSERT(FINITE_RNK(sz->rnk) && start_dim + rnk <= sz->rnk);
BENCH_ASSERT(BENCH_FINITE_RNK(sz->rnk) && start_dim + rnk <= sz->rnk);
x = mktensor(rnk);
dimcpy(x->dims, sz->dims + start_dim, rnk);
return x;
Expand All @@ -228,7 +228,7 @@ bench_tensor *tensor_copy_swapio(const bench_tensor *sz)
{
bench_tensor *x = tensor_copy(sz);
int i;
if (FINITE_RNK(x->rnk))
if (BENCH_FINITE_RNK(x->rnk))
for (i = 0; i < x->rnk; ++i) {
int s;
s = x->dims[i].is;
Expand Down
2 changes: 1 addition & 1 deletion libbench2/verify-lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ void preserves_input(dofft_closure *k, aconstrain constrain,
bench_tensor *verify_pack(const bench_tensor *sz, int s)
{
bench_tensor *x = tensor_copy(sz);
if (FINITE_RNK(x->rnk) && x->rnk > 0) {
if (BENCH_FINITE_RNK(x->rnk) && x->rnk > 0) {
int i;
x->dims[x->rnk - 1].is = s;
x->dims[x->rnk - 1].os = s;
Expand Down
Loading

0 comments on commit d9a3f48

Please sign in to comment.