On Fri, Nov 8, 2013 at 10:20 AM, Ján Tomko <jtomko(a)redhat.com> wrote:
On 11/08/2013 08:47 AM, Niilona wrote:
> @@ -2412,15 +2420,16 @@ virPCIGetVirtualFunctions(const char *sy
> return ret;
> }
>
> - while ((entry = readdir(dir))) {
> - if (STRPREFIX(entry->d_name, "virtfn")) {
> + entry_count = scandir(sysfs_path, &namelist, virtfn_select, alphasort);
alphasort will make sure that the order is always wrong if there are more than
10 functions.
Hopefully we can use versionsort thanks to gnulib.
> +
> + while ( current_entry < entry_count ) {
> virPCIDeviceAddress *config_addr = NULL;
>
> - if (virBuildPath(&device_link, sysfs_path, entry->d_name) == -1)
{
> + if (virBuildPath(&device_link, sysfs_path, namelist[
> current_entry ]->d_name ) == -1) {
> virReportOOMError();
> goto error;
> }
> -
> + current_entry ++;
> VIR_DEBUG("Number of virtual functions: %d",
> *num_virtual_functions);
>
true that alphasort breaks advantage, what's obtained using scandir().
versionsort is a good point.