From patchwork Mon Mar 11 16:57:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Konstantin Kostiuk X-Patchwork-Id: 779417 Delivered-To: patch@linaro.org Received: by 2002:a5d:604e:0:b0:33e:7753:30bd with SMTP id j14csp1630603wrt; Mon, 11 Mar 2024 09:58:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWPS1OrfQMtUgcKERqToGS57ipjtg83FDZ70XU4R47DKnky6pr3NPg1BVEr7SjD1IYJRga9mwJ+3JEfB0Pft1br X-Google-Smtp-Source: AGHT+IFu4tPeFCWQEN2iKFG1MNUd7AVgwysq2Znf06lNDXivp+NW1Cf/gkCsJUZ8vjc18sgm3H/x X-Received: by 2002:a05:620a:11ae:b0:788:207c:64ba with SMTP id c14-20020a05620a11ae00b00788207c64bamr7513833qkk.24.1710176327580; Mon, 11 Mar 2024 09:58:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710176327; cv=none; d=google.com; s=arc-20160816; b=S2mYaSvB49vSt5gAfExzC7Z2DOphJlr+Lac1MH5gOEq1pJ2/XtxsDrUIg6BoMhpZE9 Ic0mOntqsw1el0Kby61H5WT5FOLwI9Fyrtwr28syAjcDFpujHpbaYOvO6DmwkaKmNtJ2 U57qrKqP/Ed6zwWki1jOsmm9hnHGqe6UQ7z2Fyj6khprogXF/bRbCuUOL7Tna52klfEW bWY5BWCe4liYKzuR1uSI+Wqsq5Ao/b1+9IrFbnY7iAvXlU1APVLb5b/jF1+Uz17RK1UF Y2ovr56/yKeVrUWMLwWhZ62ZeUh6ibuTq57NcEPGEE5chLNivwjuE6cxiechxxmIVklI QqvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=9d+LTN83r2rY7ixxhzwmhw6wv45EVmHvQQDqrHorbps=; fh=JcHq4jpm+NZ9Tw/c0uox76tPNGJFwI2IVlXnbWbPlpw=; b=ZQub0owplZGDj9Ub96gB3mfn8jin5WiqMGQMa6BI/pNizKzotpJNMzcd2q9tVUZW7N NNIToLutjjaUtsgvH2VubxUXjRQU92A0tn5VQTOVKwZHpp4xRANjqenV7f7V68O0WcJz 8eUB2ltvBJsnYKEFM/CIHitedlRniAhg1gtGZvBbUVqytebvuKDeYDtKSvbCGISTjjds lPeOitAwyX0eKyNkJ0dOm6OvZqf4cC+iramyn2aWN5K255mbfUz9In1UgP9KfrHsmyPx aAwqcZ27O1U4UHIfGYQAaHzHd82re75HFM10d/1JOV7Uh7wFRQA9mg+rILx+a8b79HSS yZYw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=b5ypW+Ga; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q20-20020a05620a0c9400b0078825f3c45fsi5739134qki.137.2024.03.11.09.58.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Mar 2024 09:58:47 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=b5ypW+Ga; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjiy0-00056G-Ac; Mon, 11 Mar 2024 12:57:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjixz-00054C-0p for qemu-devel@nongnu.org; Mon, 11 Mar 2024 12:57:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjixx-0005zf-E9 for qemu-devel@nongnu.org; Mon, 11 Mar 2024 12:57:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710176252; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9d+LTN83r2rY7ixxhzwmhw6wv45EVmHvQQDqrHorbps=; b=b5ypW+GaLNnf0Q3Lt53qoxnhJTRMdyYoUeFfvXUHVHuH3MmC05LjneLwenwE2f4sogCc3C YMaXYeGlO4h5X0gOBNOwg1R2C7JvdV7mQsXXMf/ZQO4HGxsT8mOOdLqB8/n130pOe9zRhq 0COYOzDTW4TgCHvjCpNC5G+dJ/TFxrA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-15-hJGUVA3GPtWOsZbDXTzDCg-1; Mon, 11 Mar 2024 12:57:29 -0400 X-MC-Unique: hJGUVA3GPtWOsZbDXTzDCg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 494318007A2; Mon, 11 Mar 2024 16:57:29 +0000 (UTC) Received: from srv1.redhat.com (unknown [10.45.224.122]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4E73D10F43; Mon, 11 Mar 2024 16:57:28 +0000 (UTC) From: Konstantin Kostiuk To: qemu-devel@nongnu.org, Peter Maydell , Stefan Hajnoczi Subject: [PULL 1/3] qga/commands-win32: Declare const qualifier before type Date: Mon, 11 Mar 2024 18:57:22 +0200 Message-ID: <20240311165724.176168-2-kkostiuk@redhat.com> In-Reply-To: <20240311165724.176168-1-kkostiuk@redhat.com> References: <20240311165724.176168-1-kkostiuk@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 Received-SPF: pass client-ip=170.10.129.124; envelope-from=kkostiuk@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.029, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé Most of the code base use the 'const' qualifier *before* the type being qualified. Use the same style to unify. Signed-off-by: Philippe Mathieu-Daudé Message-ID: <20240222152835.72095-2-philmd@linaro.org> Reviewed-by: Konstantin Kostiuk Reviewed-by: Yan Vugenfirer Link: https://lore.kernel.org/r/20240304134532.28506-2-kkostiuk@redhat.com Signed-off-by: Konstantin Kostiuk --- qga/commands-win32.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index a1015757d8..79b5a580c9 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -2120,11 +2120,11 @@ GuestUserList *qmp_guest_get_users(Error **errp) typedef struct _ga_matrix_lookup_t { int major; int minor; - char const *version; - char const *version_id; + const char *version; + const char *version_id; } 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][7] = { { /* Desktop editions */ { 5, 0, "Microsoft Windows 2000", "2000"}, @@ -2148,18 +2148,18 @@ static ga_matrix_lookup_t const WIN_VERSION_MATRIX[2][7] = { typedef struct _ga_win_10_0_t { int first_build; - char const *version; - char const *version_id; + const char *version; + const char *version_id; } 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[4] = { {14393, "Microsoft Windows Server 2016", "2016"}, {17763, "Microsoft Windows Server 2019", "2019"}, {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[3] = { {10240, "Microsoft Windows 10", "10"}, {22000, "Microsoft Windows 11", "11"}, {0, 0} @@ -2185,16 +2185,16 @@ static void ga_get_win_version(RTL_OSVERSIONINFOEXW *info, Error **errp) return; } -static char *ga_get_win_name(OSVERSIONINFOEXW const *os_version, bool id) +static char *ga_get_win_name(const OSVERSIONINFOEXW *os_version, bool id) { DWORD major = os_version->dwMajorVersion; DWORD minor = os_version->dwMinorVersion; DWORD build = os_version->dwBuildNumber; int tbl_idx = (os_version->wProductType != VER_NT_WORKSTATION); - ga_matrix_lookup_t const *table = WIN_VERSION_MATRIX[tbl_idx]; - ga_win_10_0_t const *win_10_0_table = tbl_idx ? + const ga_matrix_lookup_t *table = WIN_VERSION_MATRIX[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; - ga_win_10_0_t const *win_10_0_version = NULL; + const ga_win_10_0_t *win_10_0_version = NULL; while (table->version != NULL) { if (major == 10 && minor == 0) { while (win_10_0_table->version != NULL) { From patchwork Mon Mar 11 16:57:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Konstantin Kostiuk X-Patchwork-Id: 779418 Delivered-To: patch@linaro.org Received: by 2002:a5d:604e:0:b0:33e:7753:30bd with SMTP id j14csp1630639wrt; Mon, 11 Mar 2024 09:58:51 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV5DXme3a4NQaZa6WwhCJQjNLEn1Tj1nv3mLqqYz2wae0snO1K/RBlaAIzS7/IGnWv52t2Z677uQ4TrJvaav5WU X-Google-Smtp-Source: AGHT+IG1VrJVHwUFnMvkeyNY4+WKEO2lCYM1DcXM+1HaOFGMdDCvwNYDaUg7dYbEKpPBByhQE51i X-Received: by 2002:a05:620a:1648:b0:787:d904:c4a0 with SMTP id c8-20020a05620a164800b00787d904c4a0mr1239317qko.22.1710176331227; Mon, 11 Mar 2024 09:58:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710176331; cv=none; d=google.com; s=arc-20160816; b=fLKy9LzOeCEGFfdOSuCEL/LU+03GMsM274UumwaDdDhJYCN30qU9h5aKxFkosc4RuP +oxHoohi1c3v+9hs+s6THoQZHR2rPCLt8Rn4ackPVY1NeKO+QrGTrrMSCieqSHflhoyh GPbLz/Fgp9tWTJKuVe64F+msBcreQWWWCHc8WPeTEbMTPN3mS5AW/d4WHzLXO9bQSXCk y09CYoLi2nbMXw/lj7E+sh2oJccGWunGn/5TW04glBFeCjjXoqWhDp/yVKDwVaBz6k8a FxZSLRWs8cyYGxT7mASRu6iNp121fv6GTAtVgDeMb8j8Vq9zN094YSRWLz5+pXT/IDXh oo3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=bQ4JxGLRjBFYllQ7HhDkk3GD2IJwmIxf2BTco2CgMWw=; fh=JcHq4jpm+NZ9Tw/c0uox76tPNGJFwI2IVlXnbWbPlpw=; b=i3iBOWaLPlTozoVWRSTcaLMbJqEQTz0cPQdeVLikglP3/SHYi3D8oYofonoKmEuKs/ TmAiLWAQfADqzP1jfAtUoRrkSExXEG9GQUuoTHe3j8Lk1iU1RPNkPD2nh+cD+bCgiEti L4InpjrEZUdgBVFxRoLlLoUmkGazWBxAkXmximy2uObRlnuwWziJPbuCEEpUm44iOQdH jPIhlzjuk5Y0ciJw/nO7q+X6FHDRCWgaHiZAB9CfOMBAqG/IQyazRDwtyq/QzTEHmjBK 9/V+7ay5QCzYKGjPuauJfZcscgo8ZHIaDShX1pn0p4ZVWxnVYeHZs4g7CcQAjb9LslbT vfzQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="TOqMJ/ed"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id wg25-20020a05620a569900b00787330d0232si5487402qkn.485.2024.03.11.09.58.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Mar 2024 09:58:51 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="TOqMJ/ed"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjiy7-00057Q-SE; Mon, 11 Mar 2024 12:57:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjiy5-00057B-QL for qemu-devel@nongnu.org; Mon, 11 Mar 2024 12:57:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjiy4-00061u-2M for qemu-devel@nongnu.org; Mon, 11 Mar 2024 12:57:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710176259; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bQ4JxGLRjBFYllQ7HhDkk3GD2IJwmIxf2BTco2CgMWw=; b=TOqMJ/ed7U32K7zhlOzMHb4Z+QcCZCkXtyy1JzF1ne0aofsDUuvVBuiI5LsZJrK7kGzBxT o9z/V6JTcWdNEbI83lrxLXAxgYrAcq26gyS0WYhWEIML0ehblnc0GItDT6agJ45VbwXyQa MdEifqCNinoIiDGG5bxDvsP3/88mVrI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-120-hLO8EQKhOi6KlCp97Rg7Qg-1; Mon, 11 Mar 2024 12:57:30 -0400 X-MC-Unique: hLO8EQKhOi6KlCp97Rg7Qg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 86D75855300; Mon, 11 Mar 2024 16:57:30 +0000 (UTC) Received: from srv1.redhat.com (unknown [10.45.224.122]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8D8D610E49; Mon, 11 Mar 2024 16:57:29 +0000 (UTC) From: Konstantin Kostiuk To: qemu-devel@nongnu.org, Peter Maydell , Stefan Hajnoczi Subject: [PULL 2/3] qga/commands-win32: Do not set matrix_lookup_t/win_10_0_t arrays size Date: Mon, 11 Mar 2024 18:57:23 +0200 Message-ID: <20240311165724.176168-3-kkostiuk@redhat.com> In-Reply-To: <20240311165724.176168-1-kkostiuk@redhat.com> References: <20240311165724.176168-1-kkostiuk@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 Received-SPF: pass client-ip=170.10.133.124; envelope-from=kkostiuk@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.029, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé 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é Message-ID: <20240222152835.72095-3-philmd@linaro.org> Reviewed-by: Konstantin Kostiuk Reviewed-by: Yan Vugenfirer Link: https://lore.kernel.org/r/20240304134532.28506-3-kkostiuk@redhat.com Signed-off-by: Konstantin Kostiuk --- qga/commands-win32.c | 48 +++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 79b5a580c9..659dfb624a 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -2124,26 +2124,23 @@ typedef struct _ga_matrix_lookup_t { const char *version_id; } ga_matrix_lookup_t; -static const ga_matrix_lookup_t WIN_VERSION_MATRIX[2][7] = { - { - /* Desktop editions */ - { 5, 0, "Microsoft Windows 2000", "2000"}, - { 5, 1, "Microsoft Windows XP", "xp"}, - { 6, 0, "Microsoft Windows Vista", "vista"}, - { 6, 1, "Microsoft Windows 7" "7"}, - { 6, 2, "Microsoft Windows 8", "8"}, - { 6, 3, "Microsoft Windows 8.1", "8.1"}, - { 0, 0, 0} - },{ - /* Server editions */ - { 5, 2, "Microsoft Windows Server 2003", "2003"}, - { 6, 0, "Microsoft Windows Server 2008", "2008"}, - { 6, 1, "Microsoft Windows Server 2008 R2", "2008r2"}, - { 6, 2, "Microsoft Windows Server 2012", "2012"}, - { 6, 3, "Microsoft Windows Server 2012 R2", "2012r2"}, - { 0, 0, 0}, - { 0, 0, 0} - } +static const ga_matrix_lookup_t WIN_CLIENT_VERSION_MATRIX[] = { + { 5, 0, "Microsoft Windows 2000", "2000"}, + { 5, 1, "Microsoft Windows XP", "xp"}, + { 6, 0, "Microsoft Windows Vista", "vista"}, + { 6, 1, "Microsoft Windows 7" "7"}, + { 6, 2, "Microsoft Windows 8", "8"}, + { 6, 3, "Microsoft Windows 8.1", "8.1"}, + { } +}; + +static const ga_matrix_lookup_t WIN_SERVER_VERSION_MATRIX[] = { + { 5, 2, "Microsoft Windows Server 2003", "2003"}, + { 6, 0, "Microsoft Windows Server 2008", "2008"}, + { 6, 1, "Microsoft Windows Server 2008 R2", "2008r2"}, + { 6, 2, "Microsoft Windows Server 2012", "2012"}, + { 6, 3, "Microsoft Windows Server 2012 R2", "2012r2"}, + { }, }; typedef struct _ga_win_10_0_t { @@ -2152,17 +2149,17 @@ typedef struct _ga_win_10_0_t { const char *version_id; } 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"}, {17763, "Microsoft Windows Server 2019", "2019"}, {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"}, {22000, "Microsoft Windows 11", "11"}, - {0, 0} + { } }; 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 build = os_version->dwBuildNumber; 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 ? WIN_10_0_SERVER_VERSION_MATRIX : WIN_10_0_CLIENT_VERSION_MATRIX; const ga_win_10_0_t *win_10_0_version = NULL;