summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8ba5c8a)
raw | patch | inline | side by side (parent: 8ba5c8a)
author | Vincent Brillault <git@lerya.net> | |
Sat, 23 Aug 2014 07:46:31 +0000 (09:46 +0200) | ||
committer | Vincent Brillault <git@lerya.net> | |
Sat, 28 Feb 2015 06:35:40 +0000 (07:35 +0100) |
src/turbostat.c | patch | blob | history |
diff --git a/src/turbostat.c b/src/turbostat.c
index d602ffe6cd3cc85dd83d98bfc2eb241e388b3cb9..ff19cc4b0e6699e085a9633db883b9ad34e90946 100644 (file)
--- a/src/turbostat.c
+++ b/src/turbostat.c
open_msr(int cpu)
{
char pathname[32];
+ int fd;
/* FIXME: Do we really need this, why? */
if (cpu_migrate(cpu)) {
return -ERR_CPU_MIGRATE;
}
- ssnprintf(pathname, 32, "/dev/cpu/%d/msr", cpu);
- return open(pathname, O_RDONLY);
+ ssnprintf(pathname, STATIC_ARRAY_SIZE(pathname), "/dev/cpu/%d/msr", cpu);
+ fd = open(pathname, O_RDONLY);
+ if (fd < 0)
+ return -ERR_CANT_OPEN_MSR;
+ return fd;
}
static int __attribute__((warn_unused_result))
fd = open_msr(cpu);
if (fd < 0)
- return -1;
+ return fd;
retval = read_msr(fd, offset, msr);
close(fd);
return retval;
msr_fd = open_msr(cpu);
if (msr_fd < 0)
- return -ERR_CANT_OPEN_MSR;
+ return msr_fd;
#define READ_MSR(msr, dst) \
do { \