LCOV - code coverage report
Current view: top level - third_party/heimdal/lib/hcrypto/libtommath - bn_mp_cmp_mag.c (source / functions) Hit Total Coverage
Test: coverage report for vadcx-master-patch-75612 fe003de8 Lines: 15 15 100.0 %
Date: 2024-02-29 22:57:05 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #include "tommath_private.h"
       2             : #ifdef BN_MP_CMP_MAG_C
       3             : /* LibTomMath, multiple-precision integer library -- Tom St Denis */
       4             : /* SPDX-License-Identifier: Unlicense */
       5             : 
       6             : /* compare maginitude of two ints (unsigned) */
       7     2051140 : mp_ord mp_cmp_mag(const mp_int *a, const mp_int *b)
       8             : {
       9      119881 :    int     n;
      10      119881 :    const mp_digit *tmpa, *tmpb;
      11             : 
      12             :    /* compare based on # of non-zero digits */
      13     2051140 :    if (a->used > b->used) {
      14       20983 :       return MP_GT;
      15             :    }
      16             : 
      17     2028677 :    if (a->used < b->used) {
      18       40483 :       return MP_LT;
      19             :    }
      20             : 
      21             :    /* alias for a */
      22     1987491 :    tmpa = a->dp + (a->used - 1);
      23             : 
      24             :    /* alias for b */
      25     1987491 :    tmpb = b->dp + (a->used - 1);
      26             : 
      27             :    /* compare based on digits  */
      28     2166858 :    for (n = 0; n < a->used; ++n, --tmpa, --tmpb) {
      29     2166503 :       if (*tmpa > *tmpb) {
      30      679114 :          return MP_GT;
      31             :       }
      32             : 
      33     1439077 :       if (*tmpa < *tmpb) {
      34     1190346 :          return MP_LT;
      35             :       }
      36             :    }
      37         333 :    return MP_EQ;
      38             : }
      39             : #endif

Generated by: LCOV version 1.14