kernel/eka/drivers/usbho/usbdescriptors/usbdescparser.cpp
branchRCL_3
changeset 44 3e88ff8f41d5
parent 43 c1f20ce4abcf
equal deleted inserted replaced
43:c1f20ce4abcf 44:3e88ff8f41d5
    47 	aDesc = NULL;
    47 	aDesc = NULL;
    48 	TPtrC8 des(aUsbDes);
    48 	TPtrC8 des(aUsbDes);
    49 
    49 
    50 	// First we must find the top level descriptor (the one we will return to the caller).
    50 	// First we must find the top level descriptor (the one we will return to the caller).
    51 	TRAP(ret, aDesc = FindParserAndParseAndCheckL(des, NULL));
    51 	TRAP(ret, aDesc = FindParserAndParseAndCheckL(des, NULL));
       
    52 	if(ret == KErrNone && !aDesc)
       
    53 		{
       
    54 		ret = KErrNotFound;
       
    55 		}
       
    56 
    52 	if(ret == KErrNone)
    57 	if(ret == KErrNone)
    53 		{
    58 		{
    54 		if(!aDesc)
    59 		// Now we have a top level descriptor - we now try to build up the descriptor
    55 			{
    60 		// tree if there are more descriptors available.
    56 			ret = KErrNotFound;
    61 		TRAP(ret, ParseDescriptorTreeL(des, *aDesc));
    57 			}
       
    58 		else
       
    59 			{
       
    60 			// Now we have a top level descriptor - we now try to build up the descriptor
       
    61 			// tree if there are more descriptors available.
       
    62 			TRAP(ret, ParseDescriptorTreeL(des, *aDesc));
       
    63 			}
       
    64 		}
    62 		}
    65 
    63 
    66 	// Ensure that all the data has been parsed if successful.
    64 	// Ensure that all the data has been parsed if successful.
    67 	if(ret == KErrNone && des.Length() > 0)
    65 	if(ret == KErrNone && des.Length() > 0)
    68 		{
    66 		{
    69 		// If no parser was found for some data then we should have been errored with KErrNotFound.
    67 		// If no parser was found for some data then we should have been errored with KErrNotFound.
    70 		__ASSERT_DEBUG(EFalse, UsbDescFault(UsbdiFaults::EUsbDescSuccessButDataLeftUnparsed));
    68 		__ASSERT_DEBUG(EFalse, UsbDescFault(UsbdiFaults::EUsbDescSuccessButDataLeftUnparsed));
    71 		ret = KErrUnknown;
    69 		ret = KErrUnknown;
    72 		}
       
    73 
       
    74 	// release the allocated descriptor if there was an error
       
    75 	if(ret != KErrNone && aDesc)
       
    76 		{
       
    77 		delete aDesc;
       
    78 		aDesc = NULL;
       
    79 		}
    70 		}
    80 
    71 
    81 	return ret;
    72 	return ret;
    82 	}
    73 	}
    83 
    74