Skip to content

Commit 6212765

Browse files
kaushlenlenb
authored andcommitted
tools/power x86_energy_perf_policy: Fix incorrect fopen mode usage
The fopen_or_die() function was previously hardcoded to open files in read-only mode ("r"), ignoring the mode parameter passed to it. This patch corrects fopen_or_die() to use the provided mode argument, allowing for flexible file access as intended. Additionally, the call to fopen_or_die() in err_on_hypervisor() incorrectly used the mode "ro", which is not a valid fopen mode. This is fixed to use the correct "r" mode. Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
1 parent cafb47b commit 6212765

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ void cmdline(int argc, char **argv)
630630
*/
631631
FILE *fopen_or_die(const char *path, const char *mode)
632632
{
633-
FILE *filep = fopen(path, "r");
633+
FILE *filep = fopen(path, mode);
634634

635635
if (!filep)
636636
err(1, "%s: open failed", path);
@@ -644,7 +644,7 @@ void err_on_hypervisor(void)
644644
char *buffer;
645645

646646
/* On VMs /proc/cpuinfo contains a "flags" entry for hypervisor */
647-
cpuinfo = fopen_or_die("/proc/cpuinfo", "ro");
647+
cpuinfo = fopen_or_die("/proc/cpuinfo", "r");
648648

649649
buffer = malloc(4096);
650650
if (!buffer) {

0 commit comments

Comments
 (0)