|
@@ -35,15 +35,18 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
#include "logging.h"
|
|
|
|
|
|
#include <ctype.h>
|
|
|
+#include <errno.h>
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
|
* Sets all governors to a value
|
|
|
*/
|
|
|
-static void set_gov_state(const char *value)
|
|
|
+static int set_gov_state(const char *value)
|
|
|
{
|
|
|
char governors[MAX_GOVERNORS][MAX_GOVERNOR_LENGTH] = { { 0 } };
|
|
|
int num = fetch_governors(governors);
|
|
|
+ int retval = EXIT_SUCCESS;
|
|
|
+ int res = 0;
|
|
|
|
|
|
LOG_MSG("Setting governors to %s\n", value);
|
|
|
for (int i = 0; i < num; i++) {
|
|
@@ -54,9 +57,15 @@ static void set_gov_state(const char *value)
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- fprintf(f, "%s\n", value);
|
|
|
+ res = fprintf(f, "%s\n", value);
|
|
|
+ if (res < 0) {
|
|
|
+ LOG_ERROR("Failed to set governor %s to %s: %s", gov, value, strerror(errno));
|
|
|
+ retval = EXIT_FAILURE;
|
|
|
+ }
|
|
|
fclose(f);
|
|
|
}
|
|
|
+
|
|
|
+ return retval;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -75,7 +84,7 @@ int main(int argc, char *argv[])
|
|
|
return EXIT_FAILURE;
|
|
|
}
|
|
|
|
|
|
- set_gov_state(value);
|
|
|
+ return set_gov_state(value);
|
|
|
} else {
|
|
|
fprintf(stderr, "usage: cpugovctl [get] [set VALUE]\n");
|
|
|
return EXIT_FAILURE;
|