commit 976f5e7b4682dc7f1735b9fd11dd4d7c56f5c8df
parent ef73ac2bc8dbde3b9fbf91821c925670b0cfea75
Author: Louis Burda <quent.burda@gmail.com>
Date: Sat, 25 Mar 2023 01:49:28 +0100
Fix -Wsign-compare errors
Diffstat:
5 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/06/main.c b/06/main.c
@@ -27,7 +27,7 @@ planets_get(const char *name)
key.p = name;
link = hmap_get(&planets, key);
- return link ? link->value.p : NULL;
+ return link ? link->value._p : NULL;
}
struct planet *
@@ -92,7 +92,7 @@ planets_deinit()
for (HMAP_ITER(&planets, &iter)) {
free(iter.link->key._p);
- p = iter.link->value.p;
+ p = iter.link->value._p;
dvec_deinit(&p->children);
free(p->name);
free(p);
@@ -105,7 +105,7 @@ void
part1(void)
{
struct hmap_iter iter;
- struct planet *p;
+ const struct planet *p;
int orbits;
planets_init();
diff --git a/07/main.c b/07/main.c
@@ -34,7 +34,7 @@ run_amp(struct icc *icc, int phase, int input, int *out)
void
bf_phase(struct icc *icc, struct dvec *inst, size_t *state,
- size_t max_depth, int depth, int in, int *max, size_t *maxstate)
+ size_t max_depth, size_t depth, int in, int *max, size_t *maxstate)
{
size_t i, k;
int out;
@@ -115,7 +115,7 @@ run_phase_loop(struct icc *iccs, struct dvec *inst, size_t *state, size_t n)
}
void
-bf_phase_loop(size_t *state, size_t max_depth, int depth,
+bf_phase_loop(size_t *state, size_t max_depth, size_t depth,
struct icc *iccs, void *inst, int *max, size_t *maxstate)
{
size_t i, k;
diff --git a/08/main.c b/08/main.c
@@ -30,7 +30,7 @@ part1(void)
memset(count, 0, sizeof(count));
for (k = 0; k < width * height; k++)
count[aoc.input[i+k] - '0'] += 1;
- if (minz == -1 || minz > count[0]) {
+ if (minz == -1 || minz > (int) count[0]) {
minz = (int) count[0];
res = (int) (count[1] * count[2]);
}
diff --git a/10/main.c b/10/main.c
@@ -121,10 +121,10 @@ reduce_frac(struct dir *d)
}
void
-get_vis(struct hmap *hm, struct asteroid *a1)
+get_vis(struct hmap *hm, const struct asteroid *a1)
{
struct hmap_link *link;
- struct asteroid *a2, *tmp;
+ const struct asteroid *a2, *tmp;
struct dir dir, odir;
void *key;
int rc;
@@ -153,7 +153,7 @@ get_vis(struct hmap *hm, struct asteroid *a1)
}
float
-angle(struct asteroid *a, struct asteroid *base)
+angle(const struct asteroid *a, const struct asteroid *base)
{
if (a->x == base->x)
return a->y > base->y ? 0 : -(float)M_PI;
@@ -162,7 +162,7 @@ angle(struct asteroid *a, struct asteroid *base)
}
void
-find_base(struct asteroid **a_out, int *vis_out)
+find_base(const struct asteroid **a_out, int *vis_out)
{
struct asteroid *a1, *cand;
struct hmap_iter iter;
@@ -203,7 +203,7 @@ find_base(struct asteroid **a_out, int *vis_out)
void
part1(void)
{
- struct asteroid *a;
+ const struct asteroid *a;
int vis;
asteroids_init();
@@ -219,9 +219,9 @@ part1(void)
void
part2(void)
{
- struct asteroid *base, *tmp;
+ const struct asteroid *base, *tmp;
struct hmap_iter iter;
- struct asteroid **list;
+ const struct asteroid **list;
struct hmap dirmap;
int i, k, len;
float prev;
diff --git a/common/icc.c b/common/icc.c
@@ -127,7 +127,7 @@ icc_debug_op_main(struct icc *icc, const char *opstr, size_t n)
fprintf(stderr, "%s ", opstr);
icc->line_terminated = false;
- for (i = 1; i <= n; i++) {
+ for (i = 1; i <= (int) n; i++) {
if (i > 1) fprintf(stderr, ", ");
rc = icc_get_inst(icc, icc->rip + i, &val);
assert(!rc);
@@ -136,7 +136,7 @@ icc_debug_op_main(struct icc *icc, const char *opstr, size_t n)
fprintf(stderr, "%i", val);
break;
case ICC_PARAM_POS:
- rc = icc_get_inst(icc, (size_t) val, &val2);
+ rc = icc_get_inst(icc, val, &val2);
if (!rc) fprintf(stderr, "[%i]=%i", val, val2);
else fprintf(stderr, "[%i]=?", val);
break;
@@ -159,7 +159,7 @@ icc_debug_op_post(struct icc *icc, int dst)
fprintf(stderr, " -> ");
- rc = icc_get_inst(icc, (size_t) dst, &val);
+ rc = icc_get_inst(icc, dst, &val);
if (!rc) fprintf(stderr, "[%i]=%i", dst, val);
else fprintf(stderr, "[%i]=?", dst);
@@ -458,7 +458,7 @@ icc_set_inst(struct icc *icc, int addr, int val)
{
int *slot;
- if (addr >= icc->instructions.len) {
+ if ((size_t) addr >= icc->instructions.len) {
icc->write_addr = addr;
assert(icc->abort_on_err);
return ICC_OOB_WRITE;
@@ -473,7 +473,7 @@ icc_set_inst(struct icc *icc, int addr, int val)
int
icc_get_inst(struct icc *icc, int addr, int *out)
{
- if (addr >= icc->instructions.len) {
+ if ((size_t) addr >= icc->instructions.len) {
icc->read_addr = addr;
assert(icc->abort_on_err);
return ICC_OOB_READ;