Message ID | 20240118032400.3762658-15-pierrick.bouvier@linaro.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | TCG Plugin inline operation enhancement | expand |
Pierrick Bouvier <pierrick.bouvier@linaro.org> writes: > ‘g_pattern_match_string’ is deprecated, > Use 'g_pattern_spec_match_string' instead. Unfortunately this isn't enough as we can still build on older glibs: /* Ask for warnings for anything that was marked deprecated in * the defined version, or before. It is a candidate for rewrite. */ #define GLIB_VERSION_MIN_REQUIRED GLIB_VERSION_2_56 You can do something like: /* * 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) in glib-compat.h but I was wondering if it would be valid to add that dependency to plugins. We might get away with it as it doesn't include anything from QEMU itself. > > passing argument 2 of ‘g_ptr_array_add’ discards ‘const’ qualifier from > pointer target type > > Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> > --- > contrib/plugins/execlog.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/contrib/plugins/execlog.c b/contrib/plugins/execlog.c > index 5a4de1c93be..d12137ce5c0 100644 > --- a/contrib/plugins/execlog.c > +++ b/contrib/plugins/execlog.c > @@ -336,8 +336,8 @@ static void 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(vcpu_index, rd); > g_ptr_array_add(registers, reg); > > @@ -345,7 +345,7 @@ static void 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); > }
On 1/26/24 20:31, Alex Bennée wrote: > Pierrick Bouvier <pierrick.bouvier@linaro.org> writes: > >> ‘g_pattern_match_string’ is deprecated, >> Use 'g_pattern_spec_match_string' instead. > > Unfortunately this isn't enough as we can still build on older glibs: > > /* Ask for warnings for anything that was marked deprecated in > * the defined version, or before. It is a candidate for rewrite. > */ > #define GLIB_VERSION_MIN_REQUIRED GLIB_VERSION_2_56 > > You can do something like: > > /* > * 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) > > in glib-compat.h but I was wondering if it would be valid to add that > dependency to plugins. We might get away with it as it doesn't include > anything from QEMU itself. > Oh I see. Since it's the only plugin using this so far, and it's a "contrib" plugins, I'll simply drop this patch for now. We can always discuss this again in the future. I think you are right, and it's not worth adding this to glib-compat.h. >> >> passing argument 2 of ‘g_ptr_array_add’ discards ‘const’ qualifier from >> pointer target type >> >> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> >> --- >> contrib/plugins/execlog.c | 6 +++--- >> 1 file changed, 3 insertions(+), 3 deletions(-) >> >> diff --git a/contrib/plugins/execlog.c b/contrib/plugins/execlog.c >> index 5a4de1c93be..d12137ce5c0 100644 >> --- a/contrib/plugins/execlog.c >> +++ b/contrib/plugins/execlog.c >> @@ -336,8 +336,8 @@ static void 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(vcpu_index, rd); >> g_ptr_array_add(registers, reg); >> >> @@ -345,7 +345,7 @@ static void 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); >> } >
diff --git a/contrib/plugins/execlog.c b/contrib/plugins/execlog.c index 5a4de1c93be..d12137ce5c0 100644 --- a/contrib/plugins/execlog.c +++ b/contrib/plugins/execlog.c @@ -336,8 +336,8 @@ static void 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(vcpu_index, rd); g_ptr_array_add(registers, reg); @@ -345,7 +345,7 @@ static void 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); }
‘g_pattern_match_string’ is deprecated, Use 'g_pattern_spec_match_string' instead. passing argument 2 of ‘g_ptr_array_add’ discards ‘const’ qualifier from pointer target type Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> --- contrib/plugins/execlog.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)