xref: /linux/drivers/md/dm-vdo/permassert.c (revision 79790b6818e96c58fe2bffee1b418c16e64e7b80)
103d1089eSMatthew Sakai // SPDX-License-Identifier: GPL-2.0-only
203d1089eSMatthew Sakai /*
303d1089eSMatthew Sakai  * Copyright 2023 Red Hat
403d1089eSMatthew Sakai  */
503d1089eSMatthew Sakai 
603d1089eSMatthew Sakai #include "permassert.h"
703d1089eSMatthew Sakai 
803d1089eSMatthew Sakai #include "errors.h"
903d1089eSMatthew Sakai #include "logger.h"
1003d1089eSMatthew Sakai 
vdo_assertion_failed(const char * expression_string,const char * file_name,int line_number,const char * format,...)11e6016736SMatthew Sakai int vdo_assertion_failed(const char *expression_string, const char *file_name,
1203d1089eSMatthew Sakai 			 int line_number, const char *format, ...)
1303d1089eSMatthew Sakai {
1403d1089eSMatthew Sakai 	va_list args;
1503d1089eSMatthew Sakai 
1603d1089eSMatthew Sakai 	va_start(args, format);
1703d1089eSMatthew Sakai 
18*3584240bSMike Snitzer 	vdo_log_embedded_message(VDO_LOG_ERR, VDO_LOGGING_MODULE_NAME, "assertion \"",
1903d1089eSMatthew Sakai 				 format, args, "\" (%s) failed at %s:%d",
2003d1089eSMatthew Sakai 				 expression_string, file_name, line_number);
21*3584240bSMike Snitzer 	vdo_log_backtrace(VDO_LOG_ERR);
2203d1089eSMatthew Sakai 
2303d1089eSMatthew Sakai 	va_end(args);
2403d1089eSMatthew Sakai 
2503d1089eSMatthew Sakai 	return UDS_ASSERTION_FAILED;
2603d1089eSMatthew Sakai }
27