if (SECFailure == rv) { PORT_SetError(SEC_ERROR_BAD_DATA); }
PK11_FindSlotsByAliases(const char *dllName, const char* slotName,                        const char* tokenName, PRBool presentOnly){    SECMODModuleList *mlp;    SECMODModuleList *modules = SECMOD_GetDefaultModuleList();    SECMODListLock *moduleLock = SECMOD_GetDefaultModuleListLock();    int i;    PK11SlotList* slotList = NULL;    PRUint32 slotcount = 0;    slotList = PK11_NewSlotList();    if (!slotList) {        PORT_SetError(SEC_ERROR_NO_MEMORY);        return NULL;    }    if ( ((NULL == dllName) || (0 == *dllName)) &&        ((NULL == slotName) || (0 == *slotName)) &&        ((NULL == tokenName) || (0 == *tokenName)) ) {        /* default to softoken */        PK11_AddSlotToList(slotList, PK11_GetInternalKeySlot());        return slotList;    }    /* work through all the slots */    SECMOD_GetReadLock(moduleLock);    for (mlp = modules; mlp != NULL; mlp = mlp->next) {        PORT_Assert(mlp->module);        if (mlp->module && ((!dllName) || (mlp->module->dllName &&            (0 == PORT_Strcmp(mlp->module->dllName, dllName))))) {            for (i=0; i < mlp->module->slotCount; i++) {                PK11SlotInfo *tmpSlot = (mlp->module->slots?mlp->module->slots[i]:NULL);                PORT_Assert(tmpSlot);                if (tmpSlot && (PR_FALSE == presentOnly || PK11_IsPresent(tmpSlot)) &&                    ( (!tokenName) || (tmpSlot->token_name &&                    (0==PORT_Strcmp(tmpSlot->token_name, tokenName)))) &&                    ( (!slotName) || (tmpSlot->slot_name &&                    (0==PORT_Strcmp(tmpSlot->slot_name, slotName)))) ) {                    PK11SlotInfo* slot = PK11_ReferenceSlot(tmpSlot);                    if (slot) {                        PK11_AddSlotToList(slotList, slot);                        slotcount++;                    }                }            }        }    }    SECMOD_ReleaseReadLock(moduleLock);    if (0 == slotcount) {        PORT_SetError(SEC_ERROR_NO_TOKEN);        PK11_FreeSlotList(slotList);        slotList = NULL;    }    return slotList;}