avoid error: variable modified at file scope

This commit is contained in:
Frank Morgner
2013-08-07 21:43:44 +02:00
parent 4971ca1e17
commit 7e6b7cd4f6
2 changed files with 14 additions and 13 deletions

View File

@@ -44,7 +44,7 @@ static const char reader_format_str[] = "Virtual PCD %02"SCNu32;
static const SCARDHANDLE validhandle = 1; static const SCARDHANDLE validhandle = 1;
/* part of libvpcd, but not exported */ /* part of libvpcd, but not exported */
extern const unsigned char VICC_MAX_SLOTS; extern const unsigned char vicc_max_slots;
extern const char *hostname; extern const char *hostname;
static LONG autoallocate(void *buf, LPDWORD len, DWORD max, void **rbuf) static LONG autoallocate(void *buf, LPDWORD len, DWORD max, void **rbuf)
@@ -80,7 +80,7 @@ static void initialize_globals(void)
hostname = VPCDHOST; hostname = VPCDHOST;
for (Lun = 0; for (Lun = 0;
Lun < PCSCLITE_MAX_READERS_CONTEXTS && Lun < VICC_MAX_SLOTS; Lun < PCSCLITE_MAX_READERS_CONTEXTS && Lun < vicc_max_slots;
Lun++) { Lun++) {
IFDHCreateChannel (Lun, Channel); IFDHCreateChannel (Lun, Channel);
} }
@@ -91,7 +91,7 @@ static void release_globals(void)
{ {
DWORD Lun; DWORD Lun;
for (Lun = 0; for (Lun = 0;
Lun < PCSCLITE_MAX_READERS_CONTEXTS && Lun < VICC_MAX_SLOTS; Lun < PCSCLITE_MAX_READERS_CONTEXTS && Lun < vicc_max_slots;
Lun++) { Lun++) {
IFDHCloseChannel (Lun); IFDHCloseChannel (Lun);
} }

View File

@@ -27,9 +27,10 @@
/* pcscd allows at most 16 readers. We will use 10. /* pcscd allows at most 16 readers. We will use 10.
* See PCSCLITE_MAX_READERS_CONTEXTS in pcsclite.h */ * See PCSCLITE_MAX_READERS_CONTEXTS in pcsclite.h */
const unsigned char VICC_MAX_SLOTS = #define VICC_MAX_SLOTS \
PCSCLITE_MAX_READERS_CONTEXTS > 6 ? PCSCLITE_MAX_READERS_CONTEXTS > 6 ? \
PCSCLITE_MAX_READERS_CONTEXTS-6 : 1; PCSCLITE_MAX_READERS_CONTEXTS-6 : 1
const unsigned char vicc_max_slots = VICC_MAX_SLOTS;
static struct vicc_ctx *ctx[VICC_MAX_SLOTS]; static struct vicc_ctx *ctx[VICC_MAX_SLOTS];
const char *hostname = NULL; const char *hostname = NULL;
@@ -39,7 +40,7 @@ RESPONSECODE
IFDHCreateChannel (DWORD Lun, DWORD Channel) IFDHCreateChannel (DWORD Lun, DWORD Channel)
{ {
size_t slot = Lun & 0xffff; size_t slot = Lun & 0xffff;
if (slot >= VICC_MAX_SLOTS) { if (slot >= vicc_max_slots) {
return IFD_COMMUNICATION_ERROR; return IFD_COMMUNICATION_ERROR;
} }
if (!hostname) if (!hostname)
@@ -123,7 +124,7 @@ RESPONSECODE
IFDHCloseChannel (DWORD Lun) IFDHCloseChannel (DWORD Lun)
{ {
size_t slot = Lun & 0xffff; size_t slot = Lun & 0xffff;
if (slot >= VICC_MAX_SLOTS) { if (slot >= vicc_max_slots) {
return IFD_COMMUNICATION_ERROR; return IFD_COMMUNICATION_ERROR;
} }
if (vicc_exit(ctx[slot]) < 0) { if (vicc_exit(ctx[slot]) < 0) {
@@ -141,7 +142,7 @@ IFDHGetCapabilities (DWORD Lun, DWORD Tag, PDWORD Length, PUCHAR Value)
unsigned char *atr = NULL; unsigned char *atr = NULL;
ssize_t size; ssize_t size;
size_t slot = Lun & 0xffff; size_t slot = Lun & 0xffff;
if (slot >= VICC_MAX_SLOTS) { if (slot >= vicc_max_slots) {
return IFD_COMMUNICATION_ERROR; return IFD_COMMUNICATION_ERROR;
} }
@@ -179,7 +180,7 @@ IFDHGetCapabilities (DWORD Lun, DWORD Tag, PDWORD Length, PUCHAR Value)
return IFD_COMMUNICATION_ERROR; return IFD_COMMUNICATION_ERROR;
} }
*Value = VICC_MAX_SLOTS; *Value = vicc_max_slots;
*Length = 1; *Length = 1;
break; break;
@@ -221,7 +222,7 @@ RESPONSECODE
IFDHPowerICC (DWORD Lun, DWORD Action, PUCHAR Atr, PDWORD AtrLength) IFDHPowerICC (DWORD Lun, DWORD Action, PUCHAR Atr, PDWORD AtrLength)
{ {
size_t slot = Lun & 0xffff; size_t slot = Lun & 0xffff;
if (slot >= VICC_MAX_SLOTS) { if (slot >= vicc_max_slots) {
return IFD_COMMUNICATION_ERROR; return IFD_COMMUNICATION_ERROR;
} }
switch (Action) { switch (Action) {
@@ -266,7 +267,7 @@ IFDHTransmitToICC (DWORD Lun, SCARD_IO_HEADER SendPci, PUCHAR TxBuffer,
ssize_t size; ssize_t size;
RESPONSECODE r = IFD_COMMUNICATION_ERROR; RESPONSECODE r = IFD_COMMUNICATION_ERROR;
size_t slot = Lun & 0xffff; size_t slot = Lun & 0xffff;
if (slot >= VICC_MAX_SLOTS) { if (slot >= vicc_max_slots) {
return IFD_COMMUNICATION_ERROR; return IFD_COMMUNICATION_ERROR;
} }
@@ -306,7 +307,7 @@ RESPONSECODE
IFDHICCPresence (DWORD Lun) IFDHICCPresence (DWORD Lun)
{ {
size_t slot = Lun & 0xffff; size_t slot = Lun & 0xffff;
if (slot >= VICC_MAX_SLOTS) { if (slot >= vicc_max_slots) {
return IFD_COMMUNICATION_ERROR; return IFD_COMMUNICATION_ERROR;
} }
switch (vicc_present(ctx[slot])) { switch (vicc_present(ctx[slot])) {