Chameleon

Chameleon Commit Details

Date:2014-01-07 09:28:20 (10 years 2 months ago)
Author:Chuck Fry
Commit:2304
Parents: 2303
Message:get_pci_dev_path: get rid of tmp buffer, use snprintf, improved O(n) algorithm instead of O(n^2) (whoopee); dump_pci_dt: hack fix for printf format string vs. args mismatch
Changes:
M/branches/chucko/i386/libsaio/pci.c

File differences

branches/chucko/i386/libsaio/pci.c
151151
152152
153153
154
154
155155
156156
157157
......
159159
160160
161161
162
163
164
165
166
167
168
169
170
171
172
173
174
162
163
164
165
166
167
168
169
170
171
172
173
174
175175
176176
177177
......
184184
185185
186186
187
187
188
188189
189190
190191
{
pci_dt_t*current;
pci_dt_t*end;
chartmp[64];
int dev_path_len = 0;
dev_path[0] = 0;
end = root_pci_dev;
int uid = getPciRootUID();
while (end != pci_dt)
{
current = pci_dt;
while (current->parent != end)
current = current->parent;
end = current;
if (current->parent == root_pci_dev)
{
sprintf(tmp, "PciRoot(0x%x)/Pci(0x%x,0x%x)", uid,
current->dev.bits.dev, current->dev.bits.func);
} else {
sprintf(tmp, "/Pci(0x%x,0x%x)",
current->dev.bits.dev, current->dev.bits.func);
}
strcat(dev_path, tmp);
current = pci_dt;
while (current->parent != end)
current = current->parent;
end = current;
if (current->parent == root_pci_dev) {
dev_path_len +=
snprintf(dev_path + dev_path_len, sizeof(dev_path) - dev_path_len, "PciRoot(0x%x)/Pci(0x%x,0x%x)", uid,
current->dev.bits.dev, current->dev.bits.func);
} else {
dev_path_len +=
snprintf(dev_path + dev_path_len, sizeof(dev_path) - dev_path_len, "/Pci(0x%x,0x%x)",
current->dev.bits.dev, current->dev.bits.func);
}
}
return dev_path;
}
while (current) {
printf("%02x:%02x.%x [%04x%02x] [%04x:%04x] (subsys [%04x:%04x]):: %s\n",
current->dev.bits.bus, current->dev.bits.dev, current->dev.bits.func,
current->class_id, current->vendor_id, current->device_id,
current->class_id, 0 /* FIXME: what should this be? */,
current->vendor_id, current->device_id,
current->subsys_id.subsys.vendor_id, current->subsys_id.subsys.device_id,
get_pci_dev_path(current));
dump_pci_dt(current->children);

Archive Download the corresponding diff file

Revision: 2304