File tree 1 file changed +9
-5
lines changed
1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -84,23 +84,27 @@ struct cpuinfo_freebsd_topology cpuinfo_freebsd_detect_topology(void) {
84
84
cpuinfo_log_error ("failed to parse topology_spec:%s" ,
85
85
topology_spec );
86
86
free (topology_spec );
87
- return topology ;
87
+ goto fail ;
88
88
}
89
89
free (topology_spec );
90
90
topology .cores = sysctl_int ("kern.smp.cores" );
91
91
if (topology .cores == 0 ) {
92
- topology .packages = 0 ;
93
- return topology ;
92
+ goto fail ;
94
93
}
94
+ if (topology .cores < topology .packages ) {
95
+ goto fail ;
96
+ }
95
97
topology .threads_per_core = sysctl_int ("kern.smp.threads_per_core" );
96
98
if (topology .threads_per_core == 0 ) {
97
- topology .packages = 0 ;
98
- return topology ;
99
+ goto fail ;
99
100
}
100
101
cpuinfo_log_debug ("freebsd topology: packages = %d, cores = %d, "
101
102
"threads_per_core = %d" ,
102
103
topology .packages , topology .cores ,
103
104
topology .threads_per_core );
104
105
topology .threads = topology .threads_per_core * topology .cores ;
105
106
return topology ;
107
+ fail :
108
+ topology .packages = 0 ;
109
+ return topology ;
106
110
}
You can’t perform that action at this time.
0 commit comments