lrzip icon indicating copy to clipboard operation
lrzip copied to clipboard

util.h: failure and fatal macros always fatal_exit

Open pete4abw opened this issue 2 years ago • 0 comments

The macros failure_return, failure_goto will never return due to the construction of the function failure. The macros fatal_return, fatal_goto will never return due to the construction of the function fatal,

This could result in an unintended removal of an lrz file if keep broken files is not set.

Also, there is residual library cruft in these functions and the control structure.

Throughout the program there is an inconsistent use of failure and fatal all of which will never return anyway. A simplified and standardized error handling method is required.

control->log_cb and control->library_mode have no meaning.

static inline void failure(const rzip_control *control, unsigned int line, const char *file, const char *func, const char *format, ...)
{
	va_list ap;

	va_start(ap, format);
	if (!control->log_cb)
		vfprintf(stderr, format, ap);
	else
		control->log_cb(control->log_data, 0, line, file, func, format, ap);
	va_end(ap);
	if (!control->library_mode)
		fatal_exit((rzip_control*)control);
}
static inline void fatal(const rzip_control *control, unsigned int line, const char *file, const char *func, const char *format, ...)
{
	va_list ap;

	va_start(ap, format);
	if (!control->log_cb) {
		vfprintf(stderr, format, ap);
		perror(NULL);
	} else
		control->log_cb(control->log_data, 0, line, file, func, format, ap);
	va_end(ap);
	if (!control->library_mode)
		fatal_exit((rzip_control*)control);
}

pete4abw avatar Mar 14 '22 11:03 pete4abw