Hi,

The sign of a BIGNUM is irrelevant when inspecting its bit
representation.  Also, the construct

        if (BN_is_negative(v))
                BN_set_negative(v, 0);

was already redundant since a mere

        BN_set_negative(v, 0);

would have been enough to do the same thing.  In any case, none of this
is necessary.

Index: inout.c
===================================================================
RCS file: /cvs/src/usr.bin/dc/inout.c,v
retrieving revision 1.20
diff -u -p -r1.20 inout.c
--- inout.c     26 Feb 2017 11:29:55 -0000      1.20
+++ inout.c     26 Oct 2017 04:44:01 -0000
@@ -390,22 +390,14 @@ print_value(FILE *f, const struct value
 void
 print_ascii(FILE *f, const struct number *n)
 {
-       BIGNUM *v;
        int numbits, i, ch;
 
-       v = BN_dup(n->number);
-       bn_checkp(v);
-
-       if (BN_is_negative(v))
-               BN_set_negative(v, 0);
-
-       numbits = BN_num_bytes(v) * 8;
+       numbits = BN_num_bytes(n->number) * 8;
        while (numbits > 0) {
                ch = 0;
                for (i = 0; i < 8; i++)
-                       ch |= BN_is_bit_set(v, numbits-i-1) << (7 - i);
+                       ch |= BN_is_bit_set(n->number, numbits-i-1) << (7 - i);
                (void)putc(ch, f);
                numbits -= 8;
        }
-       BN_free(v);
 }

Regards,

kshe

Reply via email to