py/mpz: Force rhs of mpz_shl_inpl/mpz_shr_inpl to be unsigned.
Python semantics are that rhs of shift must be non-negative, so there's
no need to handle negative values in the underlying mpz implementation.
diff --git a/py/mpz.c b/py/mpz.c
index e7d9972..166fa7a 100644
--- a/py/mpz.c
+++ b/py/mpz.c
@@ -992,11 +992,9 @@
/* computes dest = lhs << rhs
can have dest, lhs the same
*/
-void mpz_shl_inpl(mpz_t *dest, const mpz_t *lhs, mp_int_t rhs) {
+void mpz_shl_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs) {
if (lhs->len == 0 || rhs == 0) {
mpz_set(dest, lhs);
- } else if (rhs < 0) {
- mpz_shr_inpl(dest, lhs, -rhs);
} else {
mpz_need_dig(dest, lhs->len + (rhs + DIG_SIZE - 1) / DIG_SIZE);
dest->len = mpn_shl(dest->dig, lhs->dig, lhs->len, rhs);
@@ -1007,11 +1005,9 @@
/* computes dest = lhs >> rhs
can have dest, lhs the same
*/
-void mpz_shr_inpl(mpz_t *dest, const mpz_t *lhs, mp_int_t rhs) {
+void mpz_shr_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs) {
if (lhs->len == 0 || rhs == 0) {
mpz_set(dest, lhs);
- } else if (rhs < 0) {
- mpz_shl_inpl(dest, lhs, -rhs);
} else {
mpz_need_dig(dest, lhs->len);
dest->len = mpn_shr(dest->dig, lhs->dig, lhs->len, rhs);