Remove unnecessary log argument

This commit is contained in:
Andrea Mazzoleni 2026-06-03 20:49:36 +02:00
parent cc99a22929
commit 5cfebba19e
8 changed files with 36 additions and 36 deletions

View file

@ -702,7 +702,7 @@ static int file_post(struct snapraid_state* state, int fix, unsigned i, struct s
/* reopen it as readonly, as to set the mtime readonly access it's enough */
/* we know that the file exists because it has the FILE_IS_FIXED tag */
ret = handle_open(&handle[j], file, state->file_mode, log_error, log_error); /* output a message for missing files */
ret = handle_open(&handle[j], file, state->file_mode, 0);
if (ret != 0) {
/* LCOV_EXCL_START */
log_tag("%s:%u:%s:%s: Open error. %s.\n", es(errno), i, disk->name, esc_tag(file->sub), strerror(errno));
@ -1088,7 +1088,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
} else {
/* open the file only for reading */
if (!file_flag_has(file, FILE_IS_MISSING)) {
ret = handle_open(&handle[j], file, state->file_mode, log_error, state->opt.expected_missing ? log_expected : 0);
ret = handle_open(&handle[j], file, state->file_mode, state->opt.expected_missing ? log_expected : 0);
} else {
errno = ENOENT;
ret = -1; /* if the file is missing, we cannot open it */
@ -1176,7 +1176,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
errno = ENOENT;
read_size = -1;
} else {
read_size = handle_read(&handle[j], file_pos, buffer[j], state->block_size, log_error, state->opt.expected_missing ? log_expected : 0);
read_size = handle_read(&handle[j], file_pos, buffer[j], state->block_size, state->opt.expected_missing ? log_expected : 0);
}
if (read_size == -1) {
/* save the failed block for the check/fix */
@ -1288,7 +1288,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
/* read the parity */
for (l = 0; l < state->level; ++l) {
if (parity[l]) {
ret = parity_read(parity[l], i, buffer_recov[l], state->block_size, log_error);
ret = parity_read(parity[l], i, buffer_recov[l], state->block_size);
if (ret == -1) {
log_tag("parity_%s:%u:%s: Read error. %s.\n", es(errno), i, lev_config_name(l), strerror(errno));

View file

@ -76,7 +76,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 */
ret = handle_open(handle, task->file, state->file_mode, 0);
if (ret == -1) {
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)) {
@ -92,7 +92,7 @@ static void dry_data_reader(struct snapraid_worker* worker, struct snapraid_task
return;
}
task->read_size = handle_read(handle, task->file_pos, buffer, state->block_size, log_error, 0);
task->read_size = handle_read(handle, task->file_pos, buffer, state->block_size, 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), task->file_pos, strerror(errno));
if (is_hw(errno)) {
@ -124,7 +124,7 @@ static void dry_parity_reader(struct snapraid_worker* worker, struct snapraid_ta
int ret;
/* read the parity */
ret = parity_read(parity_handle, blockcur, buffer, state->block_size, log_error);
ret = parity_read(parity_handle, blockcur, buffer, state->block_size);
if (ret == -1) {
log_tag("parity_%s:%u:%s: Read error. %s.\n", es(errno), blockcur, lev_config_name(level), strerror(errno));
if (is_hw(errno)) {

View file

@ -125,13 +125,13 @@ int handle_truncate(struct snapraid_handle* handle, struct snapraid_file* file)
return 0;
}
int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, int mode, log_ptr* out, log_ptr* out_missing)
int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, int mode, log_ptr* out_missing)
{
int ret;
int flags;
if (!out_missing)
out_missing = out;
out_missing = log_error;
/* if already opened, nothing to do */
if (handle->file == file && handle->file != 0 && handle->f != -1) {
@ -155,9 +155,9 @@ int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, int
if (errno == ENOENT)
out_missing(errno, "Missing file '%s'.\n", handle->path);
else if (errno == EACCES)
out(errno, "Permission denied for file '%s'.\n", handle->path);
log_error(errno, "Permission denied for file '%s'.\n", handle->path);
else
out(errno, "Error opening file '%s'. %s.\n", handle->path, strerror(errno));
log_error(errno, "Error opening file '%s'. %s.\n", handle->path, strerror(errno));
handle_close(handle);
return -1;
}
@ -169,7 +169,7 @@ int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, int
ret = fstat(handle->f, &handle->st);
if (ret != 0) {
/* LCOV_EXCL_START */
out(errno, "Error accessing file '%s'. %s.\n", handle->path, strerror(errno));
log_error(errno, "Error accessing file '%s'. %s.\n", handle->path, strerror(errno));
handle_close(handle);
return -1;
/* LCOV_EXCL_STOP */
@ -181,7 +181,7 @@ int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, int
ret = advise_open(&handle->advise, handle->f);
if (ret != 0) {
/* LCOV_EXCL_START */
out(errno, "Error advising file '%s'. %s.\n", handle->path, strerror(errno));
log_error(errno, "Error advising file '%s'. %s.\n", handle->path, strerror(errno));
handle_close(handle);
return -1;
/* LCOV_EXCL_STOP */
@ -220,7 +220,7 @@ int handle_close(struct snapraid_handle* handle)
return 0;
}
int handle_read(struct snapraid_handle* handle, block_off_t file_pos, unsigned char* block_buffer, unsigned block_size, log_ptr* out, log_ptr* out_missing)
int handle_read(struct snapraid_handle* handle, block_off_t file_pos, unsigned char* block_buffer, unsigned block_size, log_ptr* out_missing)
{
ssize_t read_ret;
data_off_t offset;
@ -231,7 +231,7 @@ int handle_read(struct snapraid_handle* handle, block_off_t file_pos, unsigned c
offset = file_pos * (data_off_t)block_size;
if (!out_missing)
out_missing = out;
out_missing = log_error;
/* check if we are going to read only not initialized data */
if (offset >= handle->valid_size) {
@ -245,7 +245,7 @@ int handle_read(struct snapraid_handle* handle, block_off_t file_pos, unsigned c
}
} else {
errno = ENXIO;
out(errno, "Reading over the end from file '%s' at offset %" PRIu64 ".\n", handle->path, offset);
log_error(errno, "Reading over the end from file '%s' at offset %" PRIu64 ".\n", handle->path, offset);
}
return -1;
}
@ -260,7 +260,7 @@ int handle_read(struct snapraid_handle* handle, block_off_t file_pos, unsigned c
read_ret = pread(handle->f, block_buffer + count, block_size - count, offset + count);
if (read_ret == -1) {
/* LCOV_EXCL_START */
out(errno, "Error reading file '%s' at offset %" PRIu64 " for size %u. %s.\n", handle->path, offset + count, block_size - count, strerror(errno));
log_error(errno, "Error reading file '%s' at offset %" PRIu64 " for size %u. %s.\n", handle->path, offset + count, block_size - count, strerror(errno));
return -1;
/* LCOV_EXCL_STOP */
}
@ -268,7 +268,7 @@ int handle_read(struct snapraid_handle* handle, block_off_t file_pos, unsigned c
/* LCOV_EXCL_START */
if (errno == 0)
errno = ENXIO;
out(errno, "Unexpected end of file '%s' at offset %" PRIu64 ". %s.\n", handle->path, offset, strerror(errno));
log_error(errno, "Unexpected end of file '%s' at offset %" PRIu64 ". %s.\n", handle->path, offset, strerror(errno));
return -1;
/* LCOV_EXCL_STOP */
}
@ -284,7 +284,7 @@ int handle_read(struct snapraid_handle* handle, block_off_t file_pos, unsigned c
ret = advise_read(&handle->advise, handle->f, offset, block_size);
if (ret != 0) {
/* LCOV_EXCL_START */
out(errno, "Error advising file '%s'. %s.\n", handle->path, strerror(errno));
log_error(errno, "Error advising file '%s'. %s.\n", handle->path, strerror(errno));
return -1;
/* LCOV_EXCL_STOP */
}

View file

@ -42,7 +42,7 @@ int handle_truncate(struct snapraid_handle* handle, struct snapraid_file* file);
* Open a file.
* The file is opened for reading.
*/
int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, int mode, log_ptr* out, log_ptr* out_missing);
int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, int mode, log_ptr* out_missing);
/**
* Close a file.
@ -53,7 +53,7 @@ int handle_close(struct snapraid_handle* handle);
* Read a block from a file.
* If the read block is shorter, it's padded with 0.
*/
int handle_read(struct snapraid_handle* handle, block_off_t file_pos, unsigned char* block_buffer, unsigned block_size, log_ptr* out, log_ptr* out_missing);
int handle_read(struct snapraid_handle* handle, block_off_t file_pos, unsigned char* block_buffer, unsigned block_size, log_ptr* out_missing);
/**
* Write a block to a file.

View file

@ -862,7 +862,7 @@ int parity_write(struct snapraid_parity_handle* handle, block_off_t pos, unsigne
return 0;
}
int parity_read(struct snapraid_parity_handle* handle, block_off_t pos, unsigned char* block_buffer, unsigned block_size, log_ptr* out)
int parity_read(struct snapraid_parity_handle* handle, block_off_t pos, unsigned char* block_buffer, unsigned block_size)
{
ssize_t read_ret;
data_off_t offset;
@ -876,7 +876,7 @@ int parity_read(struct snapraid_parity_handle* handle, block_off_t pos, unsigned
if (!split) {
/* LCOV_EXCL_START */
errno = ENXIO;
out(errno, "Reading parity data outside range at extra offset %" PRIu64 ".\n", offset);
log_error(errno, "Reading parity data outside range at extra offset %" PRIu64 ".\n", offset);
return -1;
/* LCOV_EXCL_STOP */
}
@ -885,7 +885,7 @@ int parity_read(struct snapraid_parity_handle* handle, block_off_t pos, unsigned
if (offset >= split->valid_size) {
/* LCOV_EXCL_START */
errno = ENXIO;
out(errno, "Reading over the end from parity file '%s' at offset %" PRIu64 " for size %u.\n", split->path, offset, block_size);
log_error(errno, "Reading over the end from parity file '%s' at offset %" PRIu64 " for size %u.\n", split->path, offset, block_size);
return -1;
/* LCOV_EXCL_STOP */
}
@ -898,7 +898,7 @@ int parity_read(struct snapraid_parity_handle* handle, block_off_t pos, unsigned
read_ret = pread(split->f, block_buffer + count, block_size - count, offset + count);
if (read_ret == -1) {
/* LCOV_EXCL_START */
out(errno, "Error reading parity file '%s' at offset %" PRIu64 " for size %u. %s.\n", split->path, offset + count, block_size - count, strerror(errno));
log_error(errno, "Error reading parity file '%s' at offset %" PRIu64 " for size %u. %s.\n", split->path, offset + count, block_size - count, strerror(errno));
return -1;
/* LCOV_EXCL_STOP */
}
@ -906,7 +906,7 @@ int parity_read(struct snapraid_parity_handle* handle, block_off_t pos, unsigned
/* LCOV_EXCL_START */
if (errno == 0)
errno = ENXIO;
out(errno, "Unexpected end of parity file '%s' at offset %" PRIu64 ". %s.\n", split->path, offset, strerror(errno));
log_error(errno, "Unexpected end of parity file '%s' at offset %" PRIu64 ". %s.\n", split->path, offset, strerror(errno));
return -1;
/* LCOV_EXCL_STOP */
}
@ -917,7 +917,7 @@ int parity_read(struct snapraid_parity_handle* handle, block_off_t pos, unsigned
ret = advise_read(&split->advise, split->f, offset, block_size);
if (ret != 0) {
/* LCOV_EXCL_START */
out(errno, "Error advising parity file '%s'. %s.\n", split->path, strerror(errno));
log_error(errno, "Error advising parity file '%s'. %s.\n", split->path, strerror(errno));
return -1;
/* LCOV_EXCL_STOP */
}

View file

@ -117,7 +117,7 @@ int parity_close(struct snapraid_parity_handle* handle);
/**
* Read a block from the parity file.
*/
int parity_read(struct snapraid_parity_handle* handle, block_off_t pos, unsigned char* block_buffer, unsigned block_size, log_ptr* out);
int parity_read(struct snapraid_parity_handle* handle, block_off_t pos, unsigned char* block_buffer, unsigned block_size);
/**
* Write a block in the parity file.

View file

@ -148,7 +148,7 @@ static void scrub_data_reader(struct snapraid_worker* worker, struct snapraid_ta
}
}
ret = handle_open(handle, task->file, state->file_mode, log_error, 0); /* for missing file don't output a message */
ret = handle_open(handle, task->file, state->file_mode, 0);
if (ret == -1) {
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)) {
@ -179,7 +179,7 @@ static void scrub_data_reader(struct snapraid_worker* worker, struct snapraid_ta
/* from the last sync, as we are expected to return errors if running */
/* in an unsynced array. This is just like the check command. */
task->read_size = handle_read(handle, task->file_pos, buffer, state->block_size, log_error, 0);
task->read_size = handle_read(handle, task->file_pos, buffer, state->block_size, 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), task->file_pos, strerror(errno));
if (is_hw(errno)) {
@ -211,7 +211,7 @@ static void scrub_parity_reader(struct snapraid_worker* worker, struct snapraid_
int ret;
/* read the parity */
ret = parity_read(parity_handle, blockcur, buffer, state->block_size, log_error);
ret = parity_read(parity_handle, blockcur, buffer, state->block_size);
if (ret == -1) {
log_tag("parity_%s:%u:%s: Read error. %s.\n", es(errno), blockcur, lev_config_name(level), strerror(errno));
if (is_hw(errno)) {

View file

@ -149,7 +149,7 @@ static int state_hash_process(struct snapraid_state* state, block_off_t blocksta
}
}
ret = handle_open(&handle[j], file, state->file_mode, log_error, log_error); /* output a message for missing files */
ret = handle_open(&handle[j], file, state->file_mode, 0);
if (ret == -1) {
log_tag("%s:%u:%s:%s: Open error. %s.\n", es(errno), blockcur, disk->name, esc_tag(file->sub), strerror(errno));
if (errno == ENOENT) {
@ -209,7 +209,7 @@ static int state_hash_process(struct snapraid_state* state, block_off_t blocksta
continue;
}
read_size = handle_read(&handle[j], file_pos, buffer, state->block_size, log_fatal, 0);
read_size = handle_read(&handle[j], file_pos, buffer, state->block_size, 0);
if (read_size == -1) {
/* LCOV_EXCL_START */
log_tag("%s:%u:%s:%s: Read error at position %u. %s.\n", es(errno), blockcur, disk->name, esc_tag(file->sub), file_pos, strerror(errno));
@ -506,7 +506,7 @@ static void sync_data_reader(struct snapraid_worker* worker, struct snapraid_tas
}
}
ret = handle_open(handle, task->file, state->file_mode, log_error, log_error); /* output a message for missing files */
ret = handle_open(handle, task->file, state->file_mode, 0);
if (ret == -1) {
log_tag("%s:%u:%s:%s: Open error. %s.\n", es(errno), blockcur, disk->name, esc_tag(task->file->sub), strerror(errno));
if (errno == ENOENT) {
@ -563,7 +563,7 @@ static void sync_data_reader(struct snapraid_worker* worker, struct snapraid_tas
return;
}
task->read_size = handle_read(handle, task->file_pos, buffer, state->block_size, log_error, 0);
task->read_size = handle_read(handle, task->file_pos, buffer, state->block_size, 0);
if (task->read_size == -1) {
/* LCOV_EXCL_START */
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));
@ -1034,7 +1034,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
/* we are sure that parity exists because */
/* we have at least one BLK block */
for (l = 0; l < state->level; ++l) {
ret = parity_read(&parity_handle[l], blockcur, buffer[diskmax + l], state->block_size, log_error);
ret = parity_read(&parity_handle[l], blockcur, buffer[diskmax + l], state->block_size);
if (ret == -1) {
/* LCOV_EXCL_START */
log_tag("parity_%s:%u:%s: Read error. %s.\n", es(errno), blockcur, lev_config_name(l), strerror(errno));