Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

util.h: failure and fatal macros always fatal_exit #222

Open
pete4abw opened this issue Mar 14, 2022 · 0 comments
Open

util.h: failure and fatal macros always fatal_exit #222

pete4abw opened this issue Mar 14, 2022 · 0 comments

Comments

@pete4abw
Copy link
Contributor

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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant