Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Kaushlendra Kumar and committed by
Len Brown
62127655 cafb47be

+2 -2
+2 -2
tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c
··· 630 630 */ 631 631 FILE *fopen_or_die(const char *path, const char *mode) 632 632 { 633 - FILE *filep = fopen(path, "r"); 633 + FILE *filep = fopen(path, mode); 634 634 635 635 if (!filep) 636 636 err(1, "%s: open failed", path); ··· 644 644 char *buffer; 645 645 646 646 /* 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"); 648 648 649 649 buffer = malloc(4096); 650 650 if (!buffer) {