File: assert.c

package info (click to toggle)
keepalived 1%3A2.3.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,928 kB
  • sloc: ansic: 68,122; sh: 1,868; makefile: 770; python: 35; xml: 13
file content (49 lines) | stat: -rw-r--r-- 1,732 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
 * Soft:        Keepalived is a failover program for the LVS project
 *              <www.linuxvirtualserver.org>. It monitor & manipulate
 *              a loadbalanced server pool using multi-layer checks.
 *
 * Part:        assert facility.
 *
 * Author:      Alexandre Cassen, <acassen@linux-vs.org>
 *
 *              This program is distributed in the hope that it will be useful,
 *              but WITHOUT ANY WARRANTY; without even the implied warranty of
 *              MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *              See the GNU General Public License for more details.
 *
 *              This program is free software; you can redistribute it and/or
 *              modify it under the terms of the GNU General Public License
 *              as published by the Free Software Foundation; either version
 *              2 of the License, or (at your option) any later version.
 *
 * Copyright (C) 2018-2018 Alexandre Cassen, <acassen@gmail.com>
 */
#include "config.h"

#ifndef  NDEBUG

#include <assert.h>
#include <stdlib.h>
#include <string.h>

#include "logger.h"

/* This prints an "Assertion failed" message and aborts.  */
void __assert_fail (const char *__assertion, const char *__file,
			   LINE_type __line, const char *__function)
{
	log_message(LOG_ERR, "assert: %s:%u: %s: Assertion: `%s' failed.", __file, __line, __function, __assertion);
	abort();
}

#ifdef __USE_GNU
/* Likewise, but prints the error text for ERRNUM.  */
void __assert_perror_fail (int __errnum, const char *__file,
				  unsigned int __line, const char *__function)
{
	log_message(LOG_ERR, "assert: %s:%u: %s: Unexpected error: %s.", __file, __line, __function, strerror(__errnum));
	abort();
}
#endif
#endif