Rename duplicate CONFIG_VALUE_MAX

Leave a static assert to ensure they're in sync when relevant in gamemode-gpu
This commit is contained in:
Marc Di Luzio 2019-06-01 11:12:10 +01:00
parent c5c966ad54
commit 702407595a
3 changed files with 9 additions and 7 deletions

View File

@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
*/ */
#pragma once #pragma once
#define CONFIG_VALUE_MAX 256 #define GPU_VALUE_MAX 256
/* Enums for GPU vendors */ /* Enums for GPU vendors */
enum GPUVendor { enum GPUVendor {
@ -52,7 +52,7 @@ struct GameModeGPUInfo {
long nv_mem; /* Nvidia mem clock */ long nv_mem; /* Nvidia mem clock */
long nv_powermizer_mode; /* NV Powermizer Mode */ long nv_powermizer_mode; /* NV Powermizer Mode */
char amd_performance_level[CONFIG_VALUE_MAX]; /* The AMD performance level set to */ char amd_performance_level[GPU_VALUE_MAX]; /* The AMD performance level set to */
}; };
/* Get the vendor for a device */ /* Get the vendor for a device */

View File

@ -42,6 +42,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include "build-config.h" #include "build-config.h"
_Static_assert(CONFIG_VALUE_MAX == GPU_VALUE_MAX, "Config max value and GPU value out of sync!");
/** /**
* Attempts to identify the current in use GPU information * Attempts to identify the current in use GPU information
*/ */

View File

@ -304,8 +304,8 @@ static int get_gpu_state_amd(struct GameModeGPUInfo *info)
int ret = 0; int ret = 0;
char buff[CONFIG_VALUE_MAX] = { 0 }; char buff[GPU_VALUE_MAX] = { 0 };
if (!fgets(buff, CONFIG_VALUE_MAX, file)) { if (!fgets(buff, GPU_VALUE_MAX, file)) {
LOG_ERROR("Could not read file %s (%s)!\n", path, strerror(errno)); LOG_ERROR("Could not read file %s (%s)!\n", path, strerror(errno));
ret = -1; ret = -1;
} }
@ -317,8 +317,8 @@ static int get_gpu_state_amd(struct GameModeGPUInfo *info)
if (ret == 0) { if (ret == 0) {
/* Copy in the value from the file */ /* Copy in the value from the file */
strncpy(info->amd_performance_level, buff, CONFIG_VALUE_MAX - 1); strncpy(info->amd_performance_level, buff, GPU_VALUE_MAX - 1);
info->amd_performance_level[CONFIG_VALUE_MAX - 1] = '\0'; info->amd_performance_level[GPU_VALUE_MAX - 1] = '\0';
} }
return ret; return ret;
@ -468,7 +468,7 @@ int main(int argc, char *argv[])
LOG_ERROR("Must pass performance level for AMD gpu!\n"); LOG_ERROR("Must pass performance level for AMD gpu!\n");
print_usage_and_exit(); print_usage_and_exit();
} }
strncpy(info.amd_performance_level, argv[3], CONFIG_VALUE_MAX - 1); strncpy(info.amd_performance_level, argv[3], GPU_VALUE_MAX - 1);
return set_gpu_state_amd(&info); return set_gpu_state_amd(&info);
break; break;
default: default: