From patchwork Tue Mar 26 15:45:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 1916251 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=ZhKSc65n; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V3vMg6Zs7z1yWv for ; Wed, 27 Mar 2024 02:47:59 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rp90E-0004Xp-3C; Tue, 26 Mar 2024 11:46:18 -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 1rp8zy-000408-UR for qemu-ppc@nongnu.org; Tue, 26 Mar 2024 11:46:04 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rp8zx-0001FR-6Q for qemu-ppc@nongnu.org; Tue, 26 Mar 2024 11:46:02 -0400 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-33ed4dd8659so4153848f8f.0 for ; Tue, 26 Mar 2024 08:46:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711467960; x=1712072760; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PZoPdLMWukYfNxcXkCat/bL6sGsc7qqjORe7Wmplu6s=; b=ZhKSc65n6aSSgjvZCIGZUYBuQTJzohbnxNhKAwvMA3eUDpaP4g8GJMX/qfzP0nRfNF kt/nXs3kCQmTcGFyWIRqoSljunIvDVY8GxP6fNXgFx6QYastUV5U85shDd0+t8//0H4y lFqEnAQMZ62hQaA3uHkXKeFlreoMNMjQcuuIE8/32JwyoOju+5s7lBe9fp/gze6VgPpf iL9B9DYDCPoCq5DgGZqEzmEtYK0NvEhYEf42JGJ8iLslKRzb8r3jVtiDAZn2frGL7t9V lUbpySQ++PRTbCyJOpi2gv86GdyZ0Y1kE907bozMH0X839rLA354SASPmgHZNwEWIUvX bHSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711467960; x=1712072760; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PZoPdLMWukYfNxcXkCat/bL6sGsc7qqjORe7Wmplu6s=; b=pWWDU/9jTpjAF938ax6RntLcpMAjN2XrCtTVbniP9TLo1rSH/Xyc0JbiY7xYyX1eCH kPQbKBLixGKKJ+g6MGLnlmgZfSMk36mhwLXWjn8FDAC5xFFd3FW6idyn7eya5p7yRzmF J7uam1eeWNn2fhA+UrYFJ02X0kJy5EoHLqBEVCP4ludIOOHf1L8nzTI4Q+YUMjzOMGkT QucfUYVlhQrfzrOCzl2CN6nb1e3q5xF6ynNPNAe2xC/4ime0YQxaHCV2zNJn2Lv4qCjs elBi7Zd7WuzRYAMRQXprPjsC+D5kaT0+h15zc28N6ujFwvPPgpuSkvbYecMX44gkxyZU RxYg== X-Forwarded-Encrypted: i=1; AJvYcCV7H6iJUSZk+Q244M44KFz4s9ahfZFmr8Ndpg7j9r3eoWAFxHi4BiNsVuTnIeMWE3Fn+wKiabQWwDXBvjLY5uyFcPUO X-Gm-Message-State: AOJu0YzBKBdCu1M9ToZd/xmFhc3tQ7V6ZTH66FrZhm8/ojfXaO9HSnFR 4k3k1TgaG1ZfJw1aQ/tFHDiOfVK/fgCp7zLqJIdlmQnMop+UiGQuQhNcupz0dKE= X-Google-Smtp-Source: AGHT+IGn9vVSpDNh8rQWuVgF1+Gw5LLVBbsr7W6HSykE2xDWZmuWfsooId8xN1cHVcfv8a/1nR/yzg== X-Received: by 2002:adf:e6cc:0:b0:33e:ce08:79b5 with SMTP id y12-20020adfe6cc000000b0033ece0879b5mr1645151wrm.9.1711467959787; Tue, 26 Mar 2024 08:45:59 -0700 (PDT) Received: from m1x-phil.lan ([176.176.155.229]) by smtp.gmail.com with ESMTPSA id s17-20020adfa291000000b00341b7388dafsm11861938wra.77.2024.03.26.08.45.58 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 26 Mar 2024 08:45:59 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Yao Xingtao , Pierrick Bouvier , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , =?utf-8?q?Alex_Benn=C3=A9e?= , Alexandre Iooss , Mahmoud Mandour Subject: [PULL 09/13] contrib/plugins/execlog: Fix compiler warning Date: Tue, 26 Mar 2024 16:45:00 +0100 Message-ID: <20240326154505.8300-10-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240326154505.8300-1-philmd@linaro.org> References: <20240326154505.8300-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=philmd@linaro.org; helo=mail-wr1-x42e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Yao Xingtao 1. The g_pattern_match_string() is deprecated when glib2 version >= 2.70. Use g_pattern_spec_match_string() instead to avoid this problem. 2. The type of second parameter in g_ptr_array_add() is 'gpointer' {aka 'void *'}, but the type of reg->name is 'const char*'. Cast the type of reg->name to 'gpointer' to avoid this problem. compiler warning message: contrib/plugins/execlog.c:330:17: warning: ‘g_pattern_match_string’ is deprecated: Use 'g_pattern_spec_match_string' instead [-Wdeprecated-declarations] 330 | if (g_pattern_match_string(pat, rd->name) || | ^~ In file included from /usr/include/glib-2.0/glib.h:67, from contrib/plugins/execlog.c:9: /usr/include/glib-2.0/glib/gpattern.h:57:15: note: declared here 57 | gboolean g_pattern_match_string (GPatternSpec *pspec, | ^~~~~~~~~~~~~~~~~~~~~~ contrib/plugins/execlog.c:331:21: warning: ‘g_pattern_match_string’ is deprecated: Use 'g_pattern_spec_match_string' instead [-Wdeprecated-declarations] 331 | g_pattern_match_string(pat, rd_lower)) { | ^~~~~~~~~~~~~~~~~~~~~~ /usr/include/glib-2.0/glib/gpattern.h:57:15: note: declared here 57 | gboolean g_pattern_match_string (GPatternSpec *pspec, | ^~~~~~~~~~~~~~~~~~~~~~ contrib/plugins/execlog.c:339:63: warning: passing argument 2 of ‘g_ptr_array_add’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] 339 | g_ptr_array_add(all_reg_names, reg->name); | ~~~^~~~~~ In file included from /usr/include/glib-2.0/glib.h:33: /usr/include/glib-2.0/glib/garray.h:198:62: note: expected ‘gpointer’ {aka ‘void *’} but argument is of type ‘const char *’ 198 | gpointer data); | ~~~~~~~~~~~~~~~~~~^~~~ Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2210 Signed-off-by: Yao Xingtao Message-ID: <20240326015257.21516-1-yaoxt.fnst@fujitsu.com> Reviewed-by: Pierrick Bouvier Reviewed-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daudé --- contrib/plugins/execlog.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/contrib/plugins/execlog.c b/contrib/plugins/execlog.c index a1dfd59ab7..fab18113d4 100644 --- a/contrib/plugins/execlog.c +++ b/contrib/plugins/execlog.c @@ -311,6 +311,24 @@ static Register *init_vcpu_register(qemu_plugin_reg_descriptor *desc) return reg; } +/* + * g_pattern_match_string has been deprecated in Glib since 2.70 and + * will complain about it if you try to use it. Fortunately the + * signature of both functions is the same making it easy to work + * around. + */ +static inline +gboolean g_pattern_spec_match_string_qemu(GPatternSpec *pspec, + const gchar *string) +{ +#if GLIB_CHECK_VERSION(2, 70, 0) + return g_pattern_spec_match_string(pspec, string); +#else + return g_pattern_match_string(pspec, string); +#endif +}; +#define g_pattern_spec_match_string(p, s) g_pattern_spec_match_string_qemu(p, s) + static GPtrArray *registers_init(int vcpu_index) { g_autoptr(GPtrArray) registers = g_ptr_array_new(); @@ -327,8 +345,8 @@ static GPtrArray *registers_init(int vcpu_index) for (int p = 0; p < rmatches->len; p++) { g_autoptr(GPatternSpec) pat = g_pattern_spec_new(rmatches->pdata[p]); g_autofree gchar *rd_lower = g_utf8_strdown(rd->name, -1); - if (g_pattern_match_string(pat, rd->name) || - g_pattern_match_string(pat, rd_lower)) { + if (g_pattern_spec_match_string(pat, rd->name) || + g_pattern_spec_match_string(pat, rd_lower)) { Register *reg = init_vcpu_register(rd); g_ptr_array_add(registers, reg); @@ -336,7 +354,7 @@ static GPtrArray *registers_init(int vcpu_index) if (disas_assist) { g_mutex_lock(&add_reg_name_lock); if (!g_ptr_array_find(all_reg_names, reg->name, NULL)) { - g_ptr_array_add(all_reg_names, reg->name); + g_ptr_array_add(all_reg_names, (gpointer)reg->name); } g_mutex_unlock(&add_reg_name_lock); }