Skip to content

Commit

Permalink
fix: more readability changes
Browse files Browse the repository at this point in the history
  • Loading branch information
CooperW824 committed Aug 15, 2021
1 parent e51252e commit 001e772
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
14 changes: 8 additions & 6 deletions src/hobbits-plugins/importerexporters/UsbDevice/usbdevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
* @brief Construct a new UsbDevice::UsbDevice object and setup the parameters and parameter helper.
*
*/

//Fix CLass name
UsbDevice::UsbDevice()
{
QList<ParameterDelegate::ParameterInfo> importInfos = {
Expand Down Expand Up @@ -225,13 +223,16 @@ QSharedPointer<ImportResult> UsbDevice::importBits(const Parameters &parameters,

//determine transfer type, as some transfers we can't handle yet.

if (transferType == 0){
if (transferType == 0)
{
return ImportResult::error("Control Transfer Endpoints Not Supported");
}
else if(transferType == 1){
else if(transferType == 1)
{
return ImportResult::error("Isochronous Transfer Endpoints Not Supported");
}
else if(transferType == 2){
else if(transferType == 2)
{
transferTypeStr += ", Bulk Transfer"; //for setting metadata
setupLibusb(params); //try to init libusb
if (params.errorCode < 0)
Expand Down Expand Up @@ -290,7 +291,8 @@ QSharedPointer<ImportResult> UsbDevice::importBits(const Parameters &parameters,
}
exitLibusb(true, params); //exit libusb with closing the device
}
else if (transferType == 3){
else if (transferType == 3)
{
/**
* This is the same thing as the bulk transfer implementation, but instead with an interrup transfer, only 2 lines of
* code are different, these lines replace bulk transfer with interrupt transfer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,14 @@ bool UsbDeviceImportEditor::setParameters(const Parameters &parameters)
void UsbDeviceImportEditor::initLibusb(){
m_devices.clear(); //clearing the device list
int r = libusb_init(&m_ctx); //initialize a library session
if(r < 0) { //check if error, if there is an error r will be less than 0
if(r < 0)
{ //check if error, if there is an error r will be less than 0
std::runtime_error libusb_init_error("Error while trying to initialize Libusb");
throw libusb_init_error;
}
m_cnt = libusb_get_device_list(m_ctx, &m_devs);
if (m_cnt < 0){ //check if there is an error, if there is an error m_cnt will be less than 0
if (m_cnt < 0)
{ //check if there is an error, if there is an error m_cnt will be less than 0
std::runtime_error libusb_device_list_error("Error getting device list");
throw libusb_device_list_error;
}
Expand Down Expand Up @@ -168,7 +170,8 @@ void UsbDeviceImportEditor::populateInterfaces(QString device){

m_device = device; // setting the global device descriptor string
m_interfaces.clear(); //clear the interfaces selector
if(m_devices.contains(device) == true){ //check if the device selected is actually in the devices list
if(m_devices.contains(device) == true)
{ //check if the device selected is actually in the devices list

m_deviceNum = m_devices.indexOf(device);
m_dev = m_devs[m_deviceNum]; //set the libusb device
Expand Down Expand Up @@ -209,7 +212,8 @@ void UsbDeviceImportEditor::populateInterfaces(QString device){
void UsbDeviceImportEditor::populateAltSet(QString interface){

m_altSets.clear();
if(m_interfaces.contains(interface) == true){
if(m_interfaces.contains(interface) == true)
{

m_interfaceNum = m_interfaces.indexOf(interface);

Expand Down Expand Up @@ -242,7 +246,8 @@ void UsbDeviceImportEditor::populateAltSet(QString interface){
*
* @param altSet The QString describing the Alternate Setting selected from the AltSetSelector ComboBox
*/
void UsbDeviceImportEditor::populateEndpoint(QString altSet){
void UsbDeviceImportEditor::populateEndpoint(QString altSet)
{
m_endpoints.clear();
if(m_altSets.contains(altSet) == true){

Expand Down Expand Up @@ -276,7 +281,8 @@ void UsbDeviceImportEditor::populateEndpoint(QString altSet){
* @param endpoint The QString of the endpoint selected from the EndpointSelector ComboBox
*/
void UsbDeviceImportEditor::configureEndpoint(QString endpoint){
if(m_endpoints.contains(endpoint)){
if(m_endpoints.contains(endpoint))
{
m_endpointNum = m_endpoints.indexOf(endpoint);

libusb_config_descriptor *config;
Expand Down

0 comments on commit 001e772

Please sign in to comment.