diff options
Diffstat (limited to 'src/common_device_name.c')
-rw-r--r-- | src/common_device_name.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/common_device_name.c b/src/common_device_name.c index 896a8a3..8e8a752 100644 --- a/src/common_device_name.c +++ b/src/common_device_name.c @@ -77,7 +77,7 @@ typedef FILE pci_id_file; /** * Node for sorting vendor IDs. - * + * * Each structure forms an internal node of an n-way tree. Each node selects * \c pci_id_node::bits number of bits from the vendor ID. Starting from the * root of the tree, a slice of the low-order bits of the vendor ID are @@ -86,7 +86,7 @@ typedef FILE pci_id_file; * At the leaf nodes (i.e., the node entered when all 16 bits of the vendor ID * have been used), the \c pci_id_node::children is actually an array of * pointers to \c pci_id_leaf structures. - * + * * \todo * Determine if there is a cleaner way (in the source code) to have the * \c children array change type based on whether the node is internal or @@ -105,7 +105,7 @@ struct pci_id_node { struct pci_id_leaf { uint16_t vendor; const char * vendor_name; - + size_t num_devices; struct pci_device_leaf * devices; }; @@ -122,7 +122,7 @@ _pci_hidden struct pci_id_node * tree = NULL; /** * Get a pointer to the leaf node for a vendor ID. - * + * * If the vendor ID does not exist in the tree, it is added. */ static struct pci_id_leaf * @@ -159,7 +159,7 @@ insert( uint16_t vendor ) n->children[ idx ] = child; } else { - struct pci_id_leaf * leaf = + struct pci_id_leaf * leaf = calloc( 1, sizeof( struct pci_id_leaf ) ); leaf->vendor = vendor; @@ -177,9 +177,9 @@ insert( uint16_t vendor ) /** * Populate a vendor node with all the devices associated with that vendor - * + * * \param vend Vendor node that is to be filled from the pci.ids file. - * + * * \todo * The parsing in this function should be more rhobust. There are some error * cases (i.e., a 0-tab line followed by a 2-tab line) that aren't handled @@ -202,7 +202,7 @@ populate_vendor( struct pci_id_leaf * vend, int fill_device_data ) } f = pci_id_file_open(); - + /* If the pci.ids file could not be opened, there's nothing we can do. */ if (f == NULL) { @@ -223,14 +223,14 @@ populate_vendor( struct pci_id_leaf * vend, int fill_device_data ) break; } } - + if ( !isxdigit( buf[ num_tabs + 0 ] ) || !isxdigit( buf[ num_tabs + 1 ] ) || !isxdigit( buf[ num_tabs + 2 ] ) || !isxdigit( buf[ num_tabs + 3 ] ) ) { continue; } - + new_line = strchr( buf, '\n' ); if ( new_line != NULL ) { *new_line = '\0'; @@ -263,7 +263,7 @@ populate_vendor( struct pci_id_leaf * vend, int fill_device_data ) struct pci_device_leaf * d; struct pci_device_leaf * dev; struct pci_device_leaf * last_dev; - + d = realloc( vend->devices, (vend->num_devices + 1) @@ -279,7 +279,7 @@ populate_vendor( struct pci_id_leaf * vend, int fill_device_data ) if ( num_tabs == 1 ) { dev->id.vendor_id = vend->vendor; - dev->id.device_id = (unsigned) strtoul( & buf[ num_tabs ], + dev->id.device_id = (unsigned) strtoul( & buf[ num_tabs ], NULL, 16 ); dev->id.subvendor_id = PCI_MATCH_ANY; dev->id.subdevice_id = PCI_MATCH_ANY; @@ -295,13 +295,13 @@ populate_vendor( struct pci_id_leaf * vend, int fill_device_data ) dev->id.subvendor_id= (unsigned) strtoul( & buf[ num_tabs ], NULL, 16 ); - dev->id.subdevice_id = (unsigned) strtoul( & buf[ num_tabs + 5 ], + dev->id.subdevice_id = (unsigned) strtoul( & buf[ num_tabs + 5 ], NULL, 16 ); dev->device_name = strdup( & buf[ num_tabs + 5 + 6 ] ); } } } - + pci_id_file_close( f ); } |