aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Triplett <josh@joshtriplett.org>2013-08-20 20:20:15 -0400
committerLen Brown <len.brown@intel.com>2014-01-18 22:34:09 -0500
commit74823419761c11830ea1819365f82cf3d48795cb (patch)
treeac323646d9af59a412b2e8bdf981dd803b806faf
parent2b92865e648ce04a39fda4f903784a5d01ecb0dc (diff)
turbostat: Check return value of fscanf
Some systems declare fscanf with the warn_unused_result attribute. On such systems, turbostat generates the following warnings: turbostat.c: In function 'get_core_id': turbostat.c:1203:8: warning: ignoring return value of 'fscanf', declared with attribute warn_unused_result [-Wunused-result] turbostat.c: In function 'get_physical_package_id': turbostat.c:1186:8: warning: ignoring return value of 'fscanf', declared with attribute warn_unused_result [-Wunused-result] turbostat.c: In function 'cpu_is_first_core_in_package': turbostat.c:1169:8: warning: ignoring return value of 'fscanf', declared with attribute warn_unused_result [-Wunused-result] turbostat.c: In function 'cpu_is_first_sibling_in_core': turbostat.c:1148:8: warning: ignoring return value of 'fscanf', declared with attribute warn_unused_result [-Wunused-result] Fix these by checking the return value of those four calls to fscanf. Signed-off-by: Josh Triplett <josh@joshtriplett.org> Signed-off-by: Len Brown <len.brown@intel.com>
-rw-r--r--tools/power/x86/turbostat/turbostat.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 51741a1b7021..4f7b88b035c3 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -1189,7 +1189,10 @@ int cpu_is_first_sibling_in_core(int cpu)
1189 perror(path); 1189 perror(path);
1190 exit(1); 1190 exit(1);
1191 } 1191 }
1192 fscanf(filep, "%d", &first_cpu); 1192 if (fscanf(filep, "%d", &first_cpu) != 1) {
1193 perror(path);
1194 exit(1);
1195 }
1193 fclose(filep); 1196 fclose(filep);
1194 return (cpu == first_cpu); 1197 return (cpu == first_cpu);
1195} 1198}
@@ -1210,7 +1213,10 @@ int cpu_is_first_core_in_package(int cpu)
1210 perror(path); 1213 perror(path);
1211 exit(1); 1214 exit(1);
1212 } 1215 }
1213 fscanf(filep, "%d", &first_cpu); 1216 if (fscanf(filep, "%d", &first_cpu) != 1) {
1217 perror(path);
1218 exit(1);
1219 }
1214 fclose(filep); 1220 fclose(filep);
1215 return (cpu == first_cpu); 1221 return (cpu == first_cpu);
1216} 1222}
@@ -1227,7 +1233,10 @@ int get_physical_package_id(int cpu)
1227 perror(path); 1233 perror(path);
1228 exit(1); 1234 exit(1);
1229 } 1235 }
1230 fscanf(filep, "%d", &pkg); 1236 if (fscanf(filep, "%d", &pkg) != 1) {
1237 perror(path);
1238 exit(1);
1239 }
1231 fclose(filep); 1240 fclose(filep);
1232 return pkg; 1241 return pkg;
1233} 1242}
@@ -1244,7 +1253,10 @@ int get_core_id(int cpu)
1244 perror(path); 1253 perror(path);
1245 exit(1); 1254 exit(1);
1246 } 1255 }
1247 fscanf(filep, "%d", &core); 1256 if (fscanf(filep, "%d", &core) != 1) {
1257 perror(path);
1258 exit(1);
1259 }
1248 fclose(filep); 1260 fclose(filep);
1249 return core; 1261 return core;
1250} 1262}