LCOV - code coverage report
Current view: top level - third_party/heimdal/lib/hcrypto/libtommath - bn_mp_cmp_d.c (source / functions) Hit Total Coverage
Test: coverage report for vadcx-master-patch-75612 fe003de8 Lines: 8 10 80.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_D_C
       3             : /* LibTomMath, multiple-precision integer library -- Tom St Denis */
       4             : /* SPDX-License-Identifier: Unlicense */
       5             : 
       6             : /* compare a digit */
       7         745 : mp_ord mp_cmp_d(const mp_int *a, mp_digit b)
       8             : {
       9             :    /* compare based on sign */
      10         745 :    if (a->sign == MP_NEG) {
      11           0 :       return MP_LT;
      12             :    }
      13             : 
      14             :    /* compare based on magnitude */
      15         745 :    if (a->used > 1) {
      16         164 :       return MP_GT;
      17             :    }
      18             : 
      19             :    /* compare the only digit of a to b */
      20         573 :    if (a->dp[0] > b) {
      21         422 :       return MP_GT;
      22         135 :    } else if (a->dp[0] < b) {
      23           0 :       return MP_LT;
      24             :    } else {
      25         135 :       return MP_EQ;
      26             :    }
      27             : }
      28             : #endif

Generated by: LCOV version 1.14