All, I have attached a patch against 0.9.1rc2 to get rid of some compilation warnings (tested with gcc, but should be fine for other compilers as well, AFAICT). Can someone take a look at this and possibly apply some variant of it to the 0.9 branch (and trunk)? Please pay specific attention to the return values and additional code this patch adds for error cases; it is possible they might introduce a bug somewhere because of my lack of knowledge on hwloc's internals.
Thanks, -- Pavan -- Pavan Balaji http://www.mcs.anl.gov/~balaji
Index: src/topology-linux.c =================================================================== --- src/topology-linux.c (revision 1228) +++ src/topology-linux.c (working copy) @@ -155,6 +155,11 @@ static int hwloc_linux_set_thread_cpubind(hwloc_topology_t topology, pthread_t tid, hwloc_cpuset_t hwloc_set, int strict) { +#ifdef CPU_SET + cpu_set_t linux_set; + unsigned cpu; +#endif /* CPU_SET */ + if (!pthread_setaffinity_np) { /* ?! Application uses set_thread_cpubind, but doesn't link against libpthread ?! */ errno = ENOSYS; @@ -167,9 +172,6 @@ */ #ifdef CPU_SET - cpu_set_t linux_set; - unsigned cpu; - CPU_ZERO(&linux_set); hwloc_cpuset_foreach_begin(cpu, hwloc_set) CPU_SET(cpu, &linux_set); @@ -238,7 +240,8 @@ if (!fd) return -1; - fgets(string, 11, fd); + if (fgets(string, 11, fd) == NULL) + return -1; *value = strtoul(string, NULL, 10); fclose(fd); @@ -323,7 +326,8 @@ if (!fd) return 0; - fgets(cpuset_name, sizeof(cpuset_name), fd); + if (fgets(cpuset_name, sizeof(cpuset_name), fd) == NULL) + return 0; fclose(fd); tmp = strchr(cpuset_name, '\n'); @@ -343,7 +347,8 @@ if (!fd) return 0; - fgets(info, infomax, fd); + if (fgets(info, infomax, fd) == NULL) + return 0; fclose(fd); tmp = strchr(info, '\n'); @@ -860,7 +865,10 @@ getprocnb_end() if (str[strlen(str)-1]!='\n') { - fscanf(fd,"%*[^\n]"); + if (fscanf(fd,"%*[^\n]") == EOF) { + fclose(fd); + return -1; + } getc(fd); } } @@ -914,7 +922,8 @@ dmi_line[0] = '\0'; fd = hwloc_fopen("/sys/class/dmi/id/board_vendor", "r", topology->backend_params.sysfs.root_fd); if (fd) { - fgets(dmi_line, DMI_BOARD_STRINGS_LEN, fd); + if (fgets(dmi_line, DMI_BOARD_STRINGS_LEN, fd) == NULL) + return; fclose (fd); if (dmi_line[0] != '\0') { tmp = strchr(dmi_line, '\n'); @@ -928,7 +937,8 @@ dmi_line[0] = '\0'; fd = hwloc_fopen("/sys/class/dmi/id/board_name", "r", topology->backend_params.sysfs.root_fd); if (fd) { - fgets(dmi_line, DMI_BOARD_STRINGS_LEN, fd); + if (fgets(dmi_line, DMI_BOARD_STRINGS_LEN, fd) == NULL) + return; fclose (fd); if (dmi_line[0] != '\0') { tmp = strchr(dmi_line, '\n');