Skip to content

Commit

Permalink
c/ Fix more warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
MLopez-Ibanez committed Sep 6, 2024
1 parent af524b8 commit 859d464
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 13 deletions.
10 changes: 10 additions & 0 deletions DEVEL-README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

How to release
==============

1. Bump version number in `c/Makefile`, `r/DESCRIPTION` and `python/pyproject.toml`


2. Submit to CRAN.

3. Publish a release in github to automatically submit to PyPi.
2 changes: 1 addition & 1 deletion c/avl.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static void avl_rebalance(avl_tree_t *, avl_node_t *);
#define NODE_DEPTH(n) ((n) ? (n)->depth : 0)
#define L_DEPTH(n) (NODE_DEPTH((n)->left))
#define R_DEPTH(n) (NODE_DEPTH((n)->right))
#define CALC_DEPTH(n) ((L_DEPTH(n)>R_DEPTH(n)?L_DEPTH(n):R_DEPTH(n)) + 1)
#define CALC_DEPTH(n) (unsigned char)((L_DEPTH(n)>R_DEPTH(n)?L_DEPTH(n):R_DEPTH(n)) + 1)
#endif

#ifndef AVL_DEPTH
Expand Down
2 changes: 1 addition & 1 deletion c/eaf.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ eaf_store_point_help (eaf_t * eaf, int nobj,
if (eaf->size == eaf->maxsize) {
eaf_assert (eaf->size < INT_MAX / 2);
//size_t old_maxsize = eaf->maxsize;
eaf->maxsize = (size_t) (eaf->maxsize * (1.0 + 1.0 / pow(2, eaf->nreallocs / 4.0)));
eaf->maxsize = (size_t) ((double) eaf->maxsize * (1.0 + 1.0 / pow(2, eaf->nreallocs / 4.0)));
eaf->maxsize += 100; // At least we increase it by 100 points
/* fprintf(stderr,"maxsize (%d): %ld -> %ld\n", eaf->nreallocs, */
/* old_maxsize, eaf->maxsize); */
Expand Down
2 changes: 1 addition & 1 deletion c/eaf.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ static inline int eaf_totalpoints (eaf_t **eaf, int n)
{
int totalpoints = 0;
for (int k = 0; k < n; k++)
totalpoints += eaf[k]->size;
totalpoints += (int) eaf[k]->size;
return totalpoints;
}

Expand Down
2 changes: 1 addition & 1 deletion c/gcc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ WERROR=
ifdef WERROR
WERROR_FLAG:=-Werror
endif
WARN_CFLAGS = -pedantic -Wall -Wextra -Wvla $(WERROR_FLAG)
WARN_CFLAGS = -pedantic -Wall -Wextra -Wvla -pedantic -Wconversion -Wno-sign-conversion -Wstrict-prototypes $(WERROR_FLAG)
SANITIZERS= -fsanitize=undefined -fsanitize=address
ifeq ($(DEBUG), 0)
OPT_CFLAGS ?= -O3 -flto -DNDEBUG
Expand Down
3 changes: 1 addition & 2 deletions c/hv.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ typedef struct avl_node_t {
struct avl_node_t *left;
struct avl_node_t *right;
const void *item;
double domr;
#ifdef AVL_DEPTH
unsigned char depth;
#endif
Expand All @@ -135,7 +134,7 @@ static void avl_rebalance(avl_tree_t *, avl_node_t *);
#define NODE_DEPTH(n) ((n) ? (n)->depth : 0)
#define L_DEPTH(n) (NODE_DEPTH((n)->left))
#define R_DEPTH(n) (NODE_DEPTH((n)->right))
#define CALC_DEPTH(n) ((L_DEPTH(n)>R_DEPTH(n)?L_DEPTH(n):R_DEPTH(n)) + 1)
#define CALC_DEPTH(n) (unsigned char)((L_DEPTH(n)>R_DEPTH(n)?L_DEPTH(n):R_DEPTH(n)) + 1)
#endif

static int avl_check_balance(avl_node_t *avlnode) {
Expand Down
8 changes: 4 additions & 4 deletions c/igd.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,17 @@ gd_common (int dim, const signed char *minmax,
if (dist < min_dist) min_dist = dist;
}
// Here we calculate the actual Euclidean distance.
min_dist = sqrtl(min_dist);
min_dist = (double) sqrtl(min_dist);

gd += (p == 1) ? min_dist : powl (min_dist, p);
gd += (p == 1) ? min_dist : (double) powl(min_dist, p);
}

if (p == 1)
return gd / (double) size_a;
else if (psize)
return powl (gd / (double) size_a, 1.0 / p);
return (double) powl(gd / (double) size_a, 1.0 / p);
else
return powl (gd, 1.0 / p) / (double) size_a;
return (double) powl(gd, 1.0 / p) / (double) size_a;
}

static inline double
Expand Down
4 changes: 2 additions & 2 deletions c/io_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ read_objective_t_data (const char *filename, objective_t **data_p,
datasize = 0;
} else {
ntotal = nobjs * cumsizes[nsets - 1];
sizessize = ((nsets - 1) / DATA_INC + 1) * DATA_INC;
datasize = ((ntotal - 1) / DATA_INC + 1) * DATA_INC;
sizessize = (int) ((nsets - 1) / DATA_INC + 1) * DATA_INC;
datasize = (int) ((ntotal - 1) / DATA_INC + 1) * DATA_INC;
}

/* if size is equal to zero, this is equivalent to free().
Expand Down
12 changes: 12 additions & 0 deletions c/mt19937/mt19937.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,19 @@ static void init_genrand(mt19937_state *state, uint32_t s) {
* only MSBs of the array mt[].
* 2002/01/09 modified by Makoto Matsumoto
*/
/* This code triggers conversions between uint32_t and unsigned long,
which various compilers warn about. */
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wconversion"
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wimplicit-int-conversion"
#endif
mt[mti] = (1812433253UL * (mt[mti - 1] ^ (mt[mti - 1] >> 30)) + mti);
# pragma GCC diagnostic push
#if defined(__clang__)
# pragma clang diagnostic pop
#endif
/* for > 32 bit machines */
mt[mti] &= 0xffffffffUL;
}
Expand Down
2 changes: 1 addition & 1 deletion c/rng.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ rng_standard_normal(rng_state *rng)
r >>= 8;
int sign = r & 0x1;
uint64_t rabs = (r >> 1) & 0x000fffffffffffff;
double x = rabs * wi_double[idx];
double x = (double) rabs * wi_double[idx];
if (sign & 0x1)
x = -x;
if (rabs < ki_double[idx])
Expand Down

0 comments on commit 859d464

Please sign in to comment.