From: Brice Goglin Date: Fri, 14 Feb 2014 08:35:16 +0000 (+0100) Subject: linux: reverse size/nmemb in fread calls so that we return the number of chars that... X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;p=people%2Fandrewcoop%2Fhwloc.git linux: reverse size/nmemb in fread calls so that we return the number of chars that were really read --- diff --git a/src/topology-linux.c b/src/topology-linux.c index fd7dd30f..a5235cea 100644 --- a/src/topology-linux.c +++ b/src/topology-linux.c @@ -4708,7 +4708,7 @@ hwloc_look_linuxfs_pci(struct hwloc_backend *backend) snprintf(path, sizeof(path), "/sys/bus/pci/devices/%s/vendor", dirent->d_name); file = hwloc_fopen(path, "r", root_fd); if (file) { - read = fread(value, sizeof(value), 1, file); + read = fread(value, 1, sizeof(value), file); fclose(file); if (read) attr->vendor_id = strtoul(value, NULL, 16); @@ -4716,7 +4716,7 @@ hwloc_look_linuxfs_pci(struct hwloc_backend *backend) snprintf(path, sizeof(path), "/sys/bus/pci/devices/%s/device", dirent->d_name); file = hwloc_fopen(path, "r", root_fd); if (file) { - read = fread(value, sizeof(value), 1, file); + read = fread(value, 1, sizeof(value), file); fclose(file); if (read) attr->device_id = strtoul(value, NULL, 16); @@ -4724,7 +4724,7 @@ hwloc_look_linuxfs_pci(struct hwloc_backend *backend) snprintf(path, sizeof(path), "/sys/bus/pci/devices/%s/class", dirent->d_name); file = hwloc_fopen(path, "r", root_fd); if (file) { - read = fread(value, sizeof(value), 1, file); + read = fread(value, 1, sizeof(value), file); fclose(file); if (read) attr->class_id = strtoul(value, NULL, 16) >> 8; @@ -4732,7 +4732,7 @@ hwloc_look_linuxfs_pci(struct hwloc_backend *backend) snprintf(path, sizeof(path), "/sys/bus/pci/devices/%s/subsystem_vendor", dirent->d_name); file = hwloc_fopen(path, "r", root_fd); if (file) { - read = fread(value, sizeof(value), 1, file); + read = fread(value, 1, sizeof(value), file); fclose(file); if (read) attr->subvendor_id = strtoul(value, NULL, 16); @@ -4740,7 +4740,7 @@ hwloc_look_linuxfs_pci(struct hwloc_backend *backend) snprintf(path, sizeof(path), "/sys/bus/pci/devices/%s/subsystem_device", dirent->d_name); file = hwloc_fopen(path, "r", root_fd); if (file) { - read = fread(value, sizeof(value), 1, file); + read = fread(value, 1, sizeof(value), file); fclose(file); if (read) attr->subdevice_id = strtoul(value, NULL, 16); diff --git a/src/topology-pci.c b/src/topology-pci.c index aa366c76..eaf6da21 100644 --- a/src/topology-pci.c +++ b/src/topology-pci.c @@ -255,7 +255,7 @@ hwloc_look_pci(struct hwloc_backend *backend) domain, pcidev->bus, pcidev->dev, pcidev->func); file = fopen(path, "r"); if (file) { - read = fread(value, sizeof(value), 1, file); + read = fread(value, 1, sizeof(value), file); fclose(file); if (read) obj->attr->pcidev.vendor_id = strtoul(value, NULL, 16); @@ -265,7 +265,7 @@ hwloc_look_pci(struct hwloc_backend *backend) domain, pcidev->bus, pcidev->dev, pcidev->func); file = fopen(path, "r"); if (file) { - read = fread(value, sizeof(value), 1, file); + read = fread(value, 1, sizeof(value), file); fclose(file); if (read) obj->attr->pcidev.device_id = strtoul(value, NULL, 16);