Skip to content
Snippets Groups Projects
Commit 7e396dd7 authored by Martin Perry's avatar Martin Perry Committed by Morris Jette
Browse files

Treat fopen failure of /proc/cpuinfo as a fatal error

In acct_gather_energy/rapl initialization, if the fopen of /proc/cpuinfo fails we should treat this as a fatal condition rather than continue.  Patch is attached.

Problem found by Coverity tool, CID 20186
bug 331
parent 7395805c
No related branches found
No related tags found
No related merge requests found
...@@ -239,7 +239,7 @@ static void _hardware(void) ...@@ -239,7 +239,7 @@ static void _hardware(void)
int cpu, pkg; int cpu, pkg;
if ((fd = fopen("/proc/cpuinfo", "r")) == 0) if ((fd = fopen("/proc/cpuinfo", "r")) == 0)
error("fopen"); fatal("RAPL: error on attempt to open /proc/cpuinfo");
while (fgets(buf, 1024, fd)) { while (fgets(buf, 1024, fd)) {
if (strncmp(buf, "processor", sizeof("processor") - 1) == 0) { if (strncmp(buf, "processor", sizeof("processor") - 1) == 0) {
sscanf(buf, "processor\t: %d", &cpu); sscanf(buf, "processor\t: %d", &cpu);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment