Skip to content

Commit

Permalink
fmt string nitpicking
Browse files Browse the repository at this point in the history
  • Loading branch information
imyxh committed Jun 28, 2024
1 parent 92e8271 commit 9dd3483
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 41 deletions.
12 changes: 6 additions & 6 deletions devices/center_of_mass.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,17 @@ int center_of_mass_init(struct aylp_device *self)
// keys starting with _ are comments
} else if (!strcmp(key, "region_height")) {
data->region_height = json_object_get_uint64(val);
log_trace("region_height = %llu", data->region_height);
log_trace("region_height = %zu", data->region_height);
} else if (!strcmp(key, "region_width")) {
data->region_width = json_object_get_uint64(val);
log_trace("region_width = %llu", data->region_width);
log_trace("region_width = %zu", data->region_width);
} else if (!strcmp(key, "thread_count")) {
data->thread_count = json_object_get_uint64(val);
if (data->thread_count == 0) {
log_error("Correcting 0 threads to 1 thread");
data->thread_count = 1;
}
log_trace("thread_count = %llu", data->thread_count);
log_trace("thread_count = %zu", data->thread_count);
} else {
log_warn("Unknown parameter \"%s\"", key);
}
Expand All @@ -116,7 +116,7 @@ int center_of_mass_init(struct aylp_device *self)
return -1;
}
}
log_info("Started %llu threads", data->thread_count);
log_info("Started %zu threads", data->thread_count);
self->process = &center_of_mass_process_threaded;
self->close = &center_of_mass_close_threaded;
} else {
Expand Down Expand Up @@ -144,7 +144,7 @@ int center_of_mass_process(struct aylp_device *self, struct aylp_state *state)
size_t subap_count = y_subap_count * x_subap_count;
if (UNLIKELY(!subap_count)) {
log_error("Refusing to process zero subapertures; "
"region size is %llu by %llu but image is %llu by %llu",
"region size is %zu by %zu but image is %zu by %zu",
data->region_height, data->region_width, max_y, max_x
);
return -1;
Expand Down Expand Up @@ -216,7 +216,7 @@ int center_of_mass_process_threaded(
size_t n_tasks = y_subap_count * x_subap_count;
if (!n_tasks) {
log_error("Refusing to process zero subapertures; "
"region size is %llu by %llu but image is %llu by %llu",
"region size is %zu by %zu but image is %zu by %zu",
data->region_height, data->region_width, max_y, max_x
);
return -1;
Expand Down
4 changes: 2 additions & 2 deletions devices/delay.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ int delay_init(struct aylp_device *self)
// keys starting with _ are comments
} else if (!strcmp(key, "s")) {
ts->tv_sec = (time_t)json_object_get_uint64(val);
log_trace("s = %u", ts->tv_sec);
log_trace("s = %lu", ts->tv_sec);
} else if (!strcmp(key, "ns")) {
ts->tv_nsec = (long)json_object_get_int64(val);
log_trace("ns = %u", ts->tv_nsec);
log_trace("ns = %lu", ts->tv_nsec);
} else {
log_warn("Unknown parameter \"%s\"", key);
}
Expand Down
2 changes: 1 addition & 1 deletion devices/file_sink.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ int file_sink_process(struct aylp_device *self, struct aylp_state *state)
n += fwrite(data->bytes.data, 1, data->bytes.size, data->fp);
size_t n_expect = sizeof(struct aylp_header) + data->bytes.size;
if (n < n_expect) {
log_error("Short write: %d of %d", n, n_expect);
log_error("Short write: %zu of %zu", n, n_expect);
return -1;
}
if (needs_free) {
Expand Down
8 changes: 4 additions & 4 deletions devices/logger.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,24 @@ int logger_process(struct aylp_device *self, struct aylp_state *state)
UNUSED(self);
switch (state->header.type) {
case AYLP_T_VECTOR:
log_info("Seeing vector of size %llu:", state->vector->size);
log_info("Seeing vector of size %zu:", state->vector->size);
logn_info("");
pretty_vector(state->vector);
break;
case AYLP_T_MATRIX:
log_info("Seeing matrix of size %llux%llu:",
log_info("Seeing matrix of size %zux%zu:",
state->matrix->size1, state->matrix->size2
);
pretty_matrix(state->matrix);
break;
case AYLP_T_MATRIX_UCHAR:
log_info("Seeing matrix of size %llux%llu:",
log_info("Seeing matrix of size %zux%zu:",
state->matrix_uchar->size1, state->matrix_uchar->size2
);
pretty_matrix_uchar(state->matrix_uchar);
break;
default:
log_warn("Seeing type %hX but don't know how to print it",
log_warn("Seeing type %hhX but don't know how to print it",
state->header.type
);
if (!state->header.type)
Expand Down
2 changes: 1 addition & 1 deletion devices/pid.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ int pid_init(struct aylp_device *self)
else if (!strcmp(s, "matrix"))
data->type = AYLP_T_MATRIX;
else log_error("Unrecognized type: %s", s);
log_trace("type = %s (0x%X)", s, data->type);
log_trace("type = %s (0x%hhX)", s, data->type);
} else if (!strcmp(key, "p")) {
data->p = json_object_get_double(val);
log_trace("p = %G", data->p);
Expand Down
14 changes: 7 additions & 7 deletions devices/test_source.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,29 +38,29 @@ int test_source_init(struct aylp_device *self)
else if (!strcmp(s, "matrix_uchar"))
data->type = AYLP_T_MATRIX_UCHAR;
else log_error("Unrecognized type: %s", s);
log_trace("type = %s (0x%X)", s, data->type);
log_trace("type = %s (0x%hhX)", s, data->type);
} else if (!strcmp(key, "kind")) {
const char *s = json_object_get_string(val);
// TODO: add KIND_NOISE?
if (!strcmp(s, "constant")) data->kind = KIND_CONSTANT;
else if (!strcmp(s, "sine")) data->kind = KIND_SINE;
else log_error("Unrecognized kind: %s", s);
log_trace("kind = %s (0x%X)", s, data->kind);
log_trace("kind = %s (0x%hhX)", s, data->kind);
} else if (!strcmp(key, "size1")) {
data->size1 = json_object_get_uint64(val);
log_trace("size1 = %llu", data->size1);
log_trace("size1 = %zu", data->size1);
} else if (!strcmp(key, "size2")) {
data->size2 = json_object_get_uint64(val);
log_trace("size2 = %llu", data->size2);
log_trace("size2 = %zu", data->size2);
} else if (!strcmp(key, "frequency")) {
data->frequency = json_object_get_double(val);
log_trace("frequency = %E", data->frequency);
log_trace("frequency = %G", data->frequency);
} else if (!strcmp(key, "amplitude")) {
data->amplitude = json_object_get_double(val);
log_trace("amplitude = %E", data->amplitude);
log_trace("amplitude = %G", data->amplitude);
} else if (!strcmp(key, "offset")) {
data->offset = json_object_get_double(val);
log_trace("offset = %E", data->offset);
log_trace("offset = %G", data->offset);
} else {
log_warn("Unknown parameter \"%s\"", key);
}
Expand Down
4 changes: 2 additions & 2 deletions devices/udp_sink.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ int udp_sink_process(struct aylp_device *self, struct aylp_state *state)
data->iovecs[1].iov_len = data->bytes.size;
// write all the data in one go
size_t n = data->iovecs[0].iov_len + data->iovecs[1].iov_len;
log_trace("Writing %llu bytes to UDP", n);
log_trace("Writing %zu bytes to UDP", n);
ssize_t err = writev(data->sock, data->iovecs, 2);
if (err < 0) {
// if n > SSIZE_MAX, this will fire, so we don't need to check
Expand All @@ -102,7 +102,7 @@ int udp_sink_process(struct aylp_device *self, struct aylp_state *state)
if (err == -1) {
log_error("Couldn't send data: %s", strerror(errno));
} else {
log_error("Short write: %d of %d", err, n);
log_error("Short write: %zu of %zu", err, n);
}
}
if (needs_free) {
Expand Down
18 changes: 9 additions & 9 deletions devices/vonkarman_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static int generate_phase_screen(struct aylp_device *self)
// by the spectrum as we go.
size_t M = data->phase_screen->size1;
size_t N = data->phase_screen->size2;
log_trace("Allocated %u by %u matrix for phase screen", M, N);
log_trace("Allocated %zu by %zu matrix for phase screen", M, N);
for (size_t x=0; x<M; x++) {
for (size_t y=0; y<N; y++) {
// von Kármán spectrum amplitude
Expand Down Expand Up @@ -188,25 +188,25 @@ int vonkarman_stream_init(struct aylp_device *self)
log_trace("pitch = %G", data->pitch);
} else if (!strcmp(key, "screen_size")) {
data->screen_size = json_object_get_uint64(val);
log_trace("screen_size = %u", data->screen_size);
log_trace("screen_size = %zu", data->screen_size);
} else if (!strcmp(key, "win_height")) {
data->win_height = json_object_get_uint64(val);
log_trace("win_height = %u", data->win_height);
log_trace("win_height = %zu", data->win_height);
} else if (!strcmp(key, "win_width")) {
data->win_width = json_object_get_uint64(val);
log_trace("win_width = %u", data->win_width);
log_trace("win_width = %zu", data->win_width);
} else if (!strcmp(key, "start_y")) {
data->cur_y = json_object_get_uint64(val);
log_trace("start_y = %u", data->cur_y);
log_trace("start_y = %zu", data->cur_y);
} else if (!strcmp(key, "start_x")) {
data->cur_x = json_object_get_uint64(val);
log_trace("start_x = %u", data->cur_x);
log_trace("start_x = %zu", data->cur_x);
} else if (!strcmp(key, "step_y")) {
data->cur_step_y = json_object_get_int(val);
log_trace("step_y = %u", data->cur_step_y);
log_trace("step_y = %d", data->cur_step_y);
} else if (!strcmp(key, "step_x")) {
data->cur_step_x = json_object_get_int(val);
log_trace("step_x = %u", data->cur_step_x);
log_trace("step_x = %d", data->cur_step_x);
} else {
log_warn("Unknown parameter \"%s\"", key);
}
Expand Down Expand Up @@ -306,7 +306,7 @@ int vonkarman_stream_process(struct aylp_device *self, struct aylp_state *state)
}
data->cur_y += data->cur_step_y;
data->cur_x += data->cur_step_x;
log_trace("Window at y,x indices %lu,%lu", data->cur_y, data->cur_x);
log_trace("Window at y,x indices %zu,%zu", data->cur_y, data->cur_x);
data->sub_view = gsl_matrix_submatrix(
data->phase_screen,
data->cur_y, data->cur_x,
Expand Down
18 changes: 9 additions & 9 deletions libaylp/block.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ int get_contiguous_bytes(gsl_block_uchar *bytes, struct aylp_state *state)
case AYLP_T_BLOCK: {
bytes->size = sizeof(double) * state->block->size;
bytes->data = (unsigned char *)state->block->data;
log_trace("got block of %llu doubles", state->block->size);
log_trace("got block of %zu doubles", state->block->size);
return 0;
}
case AYLP_T_VECTOR: {
gsl_vector *v = state->vector;
bytes->size = sizeof(double) * v->size;
if (LIKELY(v->stride == 1)) {
log_trace("got contiguous vector of %llu doubles",
log_trace("got contiguous vector of %zu doubles",
state->vector->size
);
bytes->data = (unsigned char *)v->data;
Expand All @@ -41,7 +41,7 @@ int get_contiguous_bytes(gsl_block_uchar *bytes, struct aylp_state *state)
v->data[i * v->stride]
;
}
log_trace("got non-contiguous vector of %llu doubles",
log_trace("got non-contiguous vector of %zu doubles",
state->vector->size
);
return 1;
Expand All @@ -53,15 +53,15 @@ int get_contiguous_bytes(gsl_block_uchar *bytes, struct aylp_state *state)
if (LIKELY(m->tda == m->size2)) {
// rows are contiguous
bytes->data = (unsigned char *)m->data;
log_trace("got contiguous matrix of %llu by %llu "
log_trace("got contiguous matrix of %zu by %zu "
"doubles",
state->matrix->size1, state->matrix->size2
);
return 0;
} else {
// rows are not contiguous
bytes->data = xmalloc(bytes->size);
log_trace("got non-contiguous matrix of %llu by %llu "
log_trace("got non-contiguous matrix of %zu by %zu "
"doubles",
state->matrix->size1, state->matrix->size2
);
Expand All @@ -77,7 +77,7 @@ int get_contiguous_bytes(gsl_block_uchar *bytes, struct aylp_state *state)
case AYLP_T_BLOCK_UCHAR: {
bytes->size = state->block_uchar->size;
bytes->data = state->block_uchar->data;
log_trace("got block of %llu uchars", bytes->size);
log_trace("got block of %zu uchars", bytes->size);
return 0;
}
case AYLP_T_MATRIX_UCHAR: {
Expand All @@ -86,14 +86,14 @@ int get_contiguous_bytes(gsl_block_uchar *bytes, struct aylp_state *state)
if (LIKELY(m->tda == m->size2)) {
// rows are contiguous
bytes->data = m->data;
log_trace("got contiguous matrix of %llu uchars",
log_trace("got contiguous matrix of %zu uchars",
bytes->size
);
return 0;
} else {
// rows are not contiguous
bytes->data = xmalloc(bytes->size);
log_trace("got non-contiguous matrix of %llu uchars",
log_trace("got non-contiguous matrix of %zu uchars",
bytes->size
);
for (size_t i = 0; i < m->size1; i++) {
Expand All @@ -106,7 +106,7 @@ int get_contiguous_bytes(gsl_block_uchar *bytes, struct aylp_state *state)
}
}
default: {
log_fatal("Bug: unsupported type 0x%hX", state->header.type);
log_fatal("Bug: unsupported type 0x%hhX", state->header.type);
exit(EXIT_FAILURE);
return -1;
}
Expand Down

0 comments on commit 9dd3483

Please sign in to comment.