comparison libtommath/bn_mp_abs.c @ 1733:d529a52b2f7c coverity coverity

merge coverity from main
author Matt Johnston <matt@ucc.asn.au>
date Fri, 26 Jun 2020 21:07:34 +0800
parents 1051e4eea25a
children
comparison
equal deleted inserted replaced
1643:b59623a64678 1733:d529a52b2f7c
1 #include <tommath_private.h> 1 #include "tommath_private.h"
2 #ifdef BN_MP_ABS_C 2 #ifdef BN_MP_ABS_C
3 /* LibTomMath, multiple-precision integer library -- Tom St Denis 3 /* LibTomMath, multiple-precision integer library -- Tom St Denis */
4 * 4 /* SPDX-License-Identifier: Unlicense */
5 * LibTomMath is a library that provides multiple-precision
6 * integer arithmetic as well as number theoretic functionality.
7 *
8 * The library was designed directly after the MPI library by
9 * Michael Fromberger but has been written from scratch with
10 * additional optimizations in place.
11 *
12 * The library is free for all purposes without any express
13 * guarantee it works.
14 *
15 * Tom St Denis, [email protected], http://libtom.org
16 */
17 5
18 /* b = |a| 6 /* b = |a|
19 * 7 *
20 * Simple function copies the input and fixes the sign to positive 8 * Simple function copies the input and fixes the sign to positive
21 */ 9 */
22 int 10 mp_err mp_abs(const mp_int *a, mp_int *b)
23 mp_abs (mp_int * a, mp_int * b)
24 { 11 {
25 int res; 12 mp_err err;
26 13
27 /* copy a to b */ 14 /* copy a to b */
28 if (a != b) { 15 if (a != b) {
29 if ((res = mp_copy (a, b)) != MP_OKAY) { 16 if ((err = mp_copy(a, b)) != MP_OKAY) {
30 return res; 17 return err;
31 } 18 }
32 } 19 }
33 20
34 /* force the sign of b to positive */ 21 /* force the sign of b to positive */
35 b->sign = MP_ZPOS; 22 b->sign = MP_ZPOS;
36 23
37 return MP_OKAY; 24 return MP_OKAY;
38 } 25 }
39 #endif 26 #endif
40
41 /* ref: $Format:%D$ */
42 /* git commit: $Format:%H$ */
43 /* commit time: $Format:%ai$ */