From bafb07a1644896d56ad4b8effaeaae601c5a275b Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 12 Apr 2019 21:12:31 +0200 Subject: First commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- abs.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 abs.c (limited to 'abs.c') diff --git a/abs.c b/abs.c new file mode 100644 index 0000000..ebfcf14 --- /dev/null +++ b/abs.c @@ -0,0 +1,18 @@ +/* See LICENSE file for copyright and license details. */ +#include "internal.h" + + +int +liberror_abs(int i) +{ +#if INT_MIN == -INT_MAX + return abs(i); +#else + if (i != INT_MIN) + return abs(i); + liberror_set_error_errno("The absolute value of largest negative integer " + "cannot be represented as a signed integer", + "abs", EOVERFLOW); + return i; +#endif +} -- cgit v1.2.3-70-g09d2