44 lines
1.1 KiB
Diff
44 lines
1.1 KiB
Diff
From 1462a0a25286d36cf85acb4bab189ae6cc8eabd0 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Micha=C5=82=20Trojnara?= <Michal.Trojnara@stunnel.org>
|
|
Date: Fri, 31 Aug 2018 08:45:16 +0200
|
|
Subject: [PATCH 14/23] Improved code readability
|
|
|
|
---
|
|
src/p11_slot.c | 13 +++++++------
|
|
1 file changed, 7 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/src/p11_slot.c b/src/p11_slot.c
|
|
index 94ec378..c5140c1 100644
|
|
--- a/src/p11_slot.c
|
|
+++ b/src/p11_slot.c
|
|
@@ -119,19 +119,20 @@ PKCS11_SLOT *pkcs11_find_token(PKCS11_CTX *ctx, PKCS11_SLOT *slots, unsigned int
|
|
*/
|
|
PKCS11_SLOT *pkcs11_find_next_token(PKCS11_CTX *ctx, PKCS11_SLOT *slots, unsigned int nslots, PKCS11_SLOT *current)
|
|
{
|
|
+ int offset;
|
|
+
|
|
if (slots == NULL)
|
|
return NULL;
|
|
|
|
if (current) {
|
|
- if (slots > current || (current - slots) > nslots)
|
|
+ offset = current + 1 - slots;
|
|
+ if (offset < 1 || (unsigned int)offset >= nslots)
|
|
return NULL;
|
|
-
|
|
- current++;
|
|
- nslots -= (current - slots);
|
|
- slots = current;
|
|
+ } else {
|
|
+ offset = 0;
|
|
}
|
|
|
|
- return pkcs11_find_token(ctx, slots, nslots);
|
|
+ return pkcs11_find_token(ctx, slots+offset, nslots-offset);
|
|
}
|
|
|
|
/*
|
|
--
|
|
2.17.1
|
|
|