mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-19 16:12:40 -06:00
qga/commands-win32: Do not set matrix_lookup_t/win_10_0_t arrays size
ga_get_win_name() iterates over all elements in the arrays by checking the 'version' field is non-NULL. Since the arrays are guarded by a NULL terminating element, we don't need to specify their size: static char *ga_get_win_name(...) { ... const ga_matrix_lookup_t *table = WIN_VERSION_MATRIX[tbl_idx]; const ga_win_10_0_t *win_10_0_table = ... ... while (table->version != NULL) { ^^^^^^^^^^^^^^^ while (win_10_0_table->version != NULL) { ^^^^^^^^^^^^^^^ This will simplify maintenance when adding new entries to these arrays. Split WIN_VERSION_MATRIX into WIN_CLIENT_VERSION_MATRIX and WIN_SERVER_VERSION_MATRIX because multidimensional array must have bounds for all dimensions except the first. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-ID: <20240222152835.72095-3-philmd@linaro.org> Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com> Reviewed-by: Yan Vugenfirer <yvugenfi@redhat.com> Link: https://lore.kernel.org/r/20240304134532.28506-3-kkostiuk@redhat.com Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
This commit is contained in:
parent
68bc26717e
commit
734e7b73df
1 changed files with 23 additions and 25 deletions
|
@ -2124,26 +2124,23 @@ typedef struct _ga_matrix_lookup_t {
|
||||||
const char *version_id;
|
const char *version_id;
|
||||||
} ga_matrix_lookup_t;
|
} ga_matrix_lookup_t;
|
||||||
|
|
||||||
static const ga_matrix_lookup_t WIN_VERSION_MATRIX[2][7] = {
|
static const ga_matrix_lookup_t WIN_CLIENT_VERSION_MATRIX[] = {
|
||||||
{
|
|
||||||
/* Desktop editions */
|
|
||||||
{ 5, 0, "Microsoft Windows 2000", "2000"},
|
{ 5, 0, "Microsoft Windows 2000", "2000"},
|
||||||
{ 5, 1, "Microsoft Windows XP", "xp"},
|
{ 5, 1, "Microsoft Windows XP", "xp"},
|
||||||
{ 6, 0, "Microsoft Windows Vista", "vista"},
|
{ 6, 0, "Microsoft Windows Vista", "vista"},
|
||||||
{ 6, 1, "Microsoft Windows 7" "7"},
|
{ 6, 1, "Microsoft Windows 7" "7"},
|
||||||
{ 6, 2, "Microsoft Windows 8", "8"},
|
{ 6, 2, "Microsoft Windows 8", "8"},
|
||||||
{ 6, 3, "Microsoft Windows 8.1", "8.1"},
|
{ 6, 3, "Microsoft Windows 8.1", "8.1"},
|
||||||
{ 0, 0, 0}
|
{ }
|
||||||
},{
|
};
|
||||||
/* Server editions */
|
|
||||||
|
static const ga_matrix_lookup_t WIN_SERVER_VERSION_MATRIX[] = {
|
||||||
{ 5, 2, "Microsoft Windows Server 2003", "2003"},
|
{ 5, 2, "Microsoft Windows Server 2003", "2003"},
|
||||||
{ 6, 0, "Microsoft Windows Server 2008", "2008"},
|
{ 6, 0, "Microsoft Windows Server 2008", "2008"},
|
||||||
{ 6, 1, "Microsoft Windows Server 2008 R2", "2008r2"},
|
{ 6, 1, "Microsoft Windows Server 2008 R2", "2008r2"},
|
||||||
{ 6, 2, "Microsoft Windows Server 2012", "2012"},
|
{ 6, 2, "Microsoft Windows Server 2012", "2012"},
|
||||||
{ 6, 3, "Microsoft Windows Server 2012 R2", "2012r2"},
|
{ 6, 3, "Microsoft Windows Server 2012 R2", "2012r2"},
|
||||||
{ 0, 0, 0},
|
{ },
|
||||||
{ 0, 0, 0}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _ga_win_10_0_t {
|
typedef struct _ga_win_10_0_t {
|
||||||
|
@ -2152,17 +2149,17 @@ typedef struct _ga_win_10_0_t {
|
||||||
const char *version_id;
|
const char *version_id;
|
||||||
} ga_win_10_0_t;
|
} ga_win_10_0_t;
|
||||||
|
|
||||||
static const ga_win_10_0_t WIN_10_0_SERVER_VERSION_MATRIX[4] = {
|
static const ga_win_10_0_t WIN_10_0_SERVER_VERSION_MATRIX[] = {
|
||||||
{14393, "Microsoft Windows Server 2016", "2016"},
|
{14393, "Microsoft Windows Server 2016", "2016"},
|
||||||
{17763, "Microsoft Windows Server 2019", "2019"},
|
{17763, "Microsoft Windows Server 2019", "2019"},
|
||||||
{20344, "Microsoft Windows Server 2022", "2022"},
|
{20344, "Microsoft Windows Server 2022", "2022"},
|
||||||
{0, 0}
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
static const ga_win_10_0_t WIN_10_0_CLIENT_VERSION_MATRIX[3] = {
|
static const ga_win_10_0_t WIN_10_0_CLIENT_VERSION_MATRIX[] = {
|
||||||
{10240, "Microsoft Windows 10", "10"},
|
{10240, "Microsoft Windows 10", "10"},
|
||||||
{22000, "Microsoft Windows 11", "11"},
|
{22000, "Microsoft Windows 11", "11"},
|
||||||
{0, 0}
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
static void ga_get_win_version(RTL_OSVERSIONINFOEXW *info, Error **errp)
|
static void ga_get_win_version(RTL_OSVERSIONINFOEXW *info, Error **errp)
|
||||||
|
@ -2191,7 +2188,8 @@ static char *ga_get_win_name(const OSVERSIONINFOEXW *os_version, bool id)
|
||||||
DWORD minor = os_version->dwMinorVersion;
|
DWORD minor = os_version->dwMinorVersion;
|
||||||
DWORD build = os_version->dwBuildNumber;
|
DWORD build = os_version->dwBuildNumber;
|
||||||
int tbl_idx = (os_version->wProductType != VER_NT_WORKSTATION);
|
int tbl_idx = (os_version->wProductType != VER_NT_WORKSTATION);
|
||||||
const ga_matrix_lookup_t *table = WIN_VERSION_MATRIX[tbl_idx];
|
const ga_matrix_lookup_t *table = tbl_idx ?
|
||||||
|
WIN_SERVER_VERSION_MATRIX : WIN_CLIENT_VERSION_MATRIX;
|
||||||
const ga_win_10_0_t *win_10_0_table = tbl_idx ?
|
const ga_win_10_0_t *win_10_0_table = tbl_idx ?
|
||||||
WIN_10_0_SERVER_VERSION_MATRIX : WIN_10_0_CLIENT_VERSION_MATRIX;
|
WIN_10_0_SERVER_VERSION_MATRIX : WIN_10_0_CLIENT_VERSION_MATRIX;
|
||||||
const ga_win_10_0_t *win_10_0_version = NULL;
|
const ga_win_10_0_t *win_10_0_version = NULL;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue