Switch esc_tag and path formatting to a contiguous thread-local circular pool to eliminate stack bloat
Some checks failed
Build / build-mac (push) Has been cancelled
Build / build-linux (push) Has been cancelled
Build / build-win (push) Has been cancelled
CodeQL Advanced / Analyze (c-cpp) (push) Has been cancelled
CodeQL Advanced / Analyze (actions) (push) Has been cancelled

This commit is contained in:
Andrea Mazzoleni 2026-05-29 11:01:44 +02:00
parent aee71ad2d6
commit 96e20b3912
21 changed files with 283 additions and 260 deletions

View file

@ -31,8 +31,6 @@ static void dry_data_reader(struct snapraid_worker* worker, struct snapraid_task
block_off_t blockcur = task->position;
unsigned char* buffer = task->buffer;
int ret;
char esc_buffer[ESC_MAX];
/* if the disk position is not used */
if (!disk) {
/* use an empty block */
@ -64,7 +62,7 @@ static void dry_data_reader(struct snapraid_worker* worker, struct snapraid_task
/* LCOV_EXCL_START */
/* This one is really an unexpected error, because we are only reading */
/* and closing a descriptor should never fail */
log_tag("%s:%u:%s:%s: Close error. %s.\n", es(errno), blockcur, disk->name, esc_tag(report->sub, esc_buffer), strerror(errno));
log_tag("%s:%u:%s:%s: Close error. %s.\n", es(errno), blockcur, disk->name, esc_tag(report->sub), strerror(errno));
log_fatal_errno(errno, disk->name);
log_fatal(errno, "Stopping at block %u\n", blockcur);
@ -80,7 +78,7 @@ static void dry_data_reader(struct snapraid_worker* worker, struct snapraid_task
ret = handle_open(handle, task->file, state->file_mode, log_error, 0); /* for missing file don't output a message */
if (ret == -1) {
log_tag("%s:%u:%s:%s: Open error. %s.\n", es(errno), blockcur, disk->name, esc_tag(task->file->sub, esc_buffer), strerror(errno));
log_tag("%s:%u:%s:%s: Open error. %s.\n", es(errno), blockcur, disk->name, esc_tag(task->file->sub), strerror(errno));
if (is_hw(errno)) {
/* LCOV_EXCL_START */
log_fatal_errno(errno, disk->name);
@ -96,7 +94,7 @@ static void dry_data_reader(struct snapraid_worker* worker, struct snapraid_task
task->read_size = handle_read(handle, task->file_pos, buffer, state->block_size, log_error, 0);
if (task->read_size == -1) {
log_tag("%s:%u:%s:%s: Read error at position %u. %s.\n", es(errno), blockcur, disk->name, esc_tag(task->file->sub, esc_buffer), task->file_pos, strerror(errno));
log_tag("%s:%u:%s:%s: Read error at position %u. %s.\n", es(errno), blockcur, disk->name, esc_tag(task->file->sub), task->file_pos, strerror(errno));
if (is_hw(errno)) {
/* LCOV_EXCL_START */
log_error_errno(errno, disk->name);
@ -161,8 +159,6 @@ static int state_dry_process(struct snapraid_state* state, struct snapraid_parit
unsigned l;
unsigned* waiting_map;
unsigned waiting_mac;
char esc_buffer[ESC_MAX];
handle = handle_mapping(state, &diskmax);
/* we need 1 * data + 2 * parity */
@ -370,7 +366,7 @@ bail:
ret = handle_close(&handle[j]);
if (ret == -1) {
/* LCOV_EXCL_START */
log_tag("%s:%u:%s:%s: Close error. %s.\n", es(errno), blockcur, disk->name, esc_tag(file->sub, esc_buffer), strerror(errno));
log_tag("%s:%u:%s:%s: Close error. %s.\n", es(errno), blockcur, disk->name, esc_tag(file->sub), strerror(errno));
log_fatal_errno(errno, disk->name);
if (is_hw(errno)) {