Skip to contentSkip to conversation

update the array size

PATCH In review Dehan Meng 2 participants 3 messages Feb 22, 2024

lore
Share & tools
lore

Dehan Meng

author
#0 lore raw

v2 cover update the array size

v1 -> v2
update the array size "WIN_10_0_SERVER_VERSION_MATRIX" in case array out of range elements.

Dehan Meng (1):
qga-win: Add support of Windows Server 2025 in get-osinfo command

 qga/commands-win32.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Signature · 1 line
2.35.1
author
#1 lore raw

PATCH v2 1/1 qga-win: Add support of Windows Server 2025 in get-osinfo command

Add support of Windows Server 2025 in get-osinfo command

---
 qga/commands-win32.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
qga/commands-win32.c +2 -1
index 697c65507c..b37fa7b5ba 100644
@@ -2150,10 +2150,11 @@ typedef struct _ga_win_10_0_t {
     char const *version_id;
 } ga_win_10_0_t;
 
-static ga_win_10_0_t const WIN_10_0_SERVER_VERSION_MATRIX[4] = {
+static ga_win_10_0_t const WIN_10_0_SERVER_VERSION_MATRIX[5] = {
     {14393, "Microsoft Windows Server 2016",    "2016"},
     {17763, "Microsoft Windows Server 2019",    "2019"},
     {20344, "Microsoft Windows Server 2022",    "2022"},
+    {26040, "MIcrosoft Windows Server 2025",    "2025"},
     {0, 0}
 };
 
Signature · 1 line
2.35.1
#2 lore raw

Re: [PATCH v2 1/1] qga-win: Add support of Windows Server 2025 in get-osinfo command

Hi Dehan,

Quoted 12 lines · Dehan Meng

Add support of Windows Server 2025 in get-osinfo command

---
  qga/commands-win32.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
qga/commands-win32.c +0 -0
index 697c65507c..b37fa7b5ba 100644

qga/commands-win32.c typedef struct _ga_win_10_0_t { · line 2153

Quoted 5 lines
qga/commands-win32.c +1 -1
@@ -2150,10 +2150,11 @@ typedef struct _ga_win_10_0_t {
      char const *version_id;
  } ga_win_10_0_t;
 
-static ga_win_10_0_t const WIN_10_0_SERVER_VERSION_MATRIX[4] = {
+static ga_win_10_0_t const WIN_10_0_SERVER_VERSION_MATRIX[5] = {

These arrays are NULL-terminated, they are iterated until the NULL value is found:

   while (table->version != NULL) {

So setting their size isn't really useful.

qga/commands-win32.c typedef struct _ga_win_10_0_t { · line 2160

Quoted 7 lines
qga/commands-win32.c +1 -0
      {14393, "Microsoft Windows Server 2016",    "2016"},
      {17763, "Microsoft Windows Server 2019",    "2019"},
      {20344, "Microsoft Windows Server 2022",    "2022"},
+    {26040, "MIcrosoft Windows Server 2025",    "2025"},
      {0, 0}
  };
 

IMO this can be simplified in a preliminary patch as (untested):

-- >8 --

qga/commands-win32.c +7 -8
index a1015757d8..c14c5cc4eb 100644
@@ -2126,3 +2126,3 @@ typedef struct _ga_matrix_lookup_t {
 
-static ga_matrix_lookup_t const WIN_VERSION_MATRIX[2][7] = {
+static const ga_matrix_lookup_t WIN_VERSION_MATRIX[2][] = {
     {
@@ -2135,3 +2135,3 @@ static ga_matrix_lookup_t const WIN_VERSION_MATRIX[2][7] = {
         { 6, 3, "Microsoft Windows 8.1",    "8.1"},
-        { 0, 0, 0}
+        { }
     },{
@@ -2143,4 +2143,3 @@ static ga_matrix_lookup_t const WIN_VERSION_MATRIX[2][7] = {
         { 6, 3, "Microsoft Windows Server 2012 R2",     "2012r2"},
-        { 0, 0, 0},
-        { 0, 0, 0}
+        { },
     }
@@ -2154,3 +2153,3 @@ typedef struct _ga_win_10_0_t {
 
-static ga_win_10_0_t const 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"},
@@ -2158,9 +2157,9 @@ static ga_win_10_0_t const WIN_10_0_SERVER_VERSION_MATRIX[4] = {
     {20344, "Microsoft Windows Server 2022",    "2022"},
-    {0, 0}
+    { }
 };
 
-static ga_win_10_0_t const 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"},
     {22000, "Microsoft Windows 11",    "11"},
-    {0, 0}
+    { }
 };

---

Then your patch becomes a one-line one.

Regard,

Phil.