* [RFC PATCH] docs/devel: more documentation on the use of suffixes
@ 2021-12-17 17:19 Alex Bennée
2021-12-17 17:26 ` Daniel P. Berrangé
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Alex Bennée @ 2021-12-17 17:19 UTC (permalink / raw)
To: qemu-devel; +Cc: Alex Bennée, berrange
Using _qemu is a little confusing. Let's use _compat for these sorts
of things. We should also mention _impl which is another common suffix
in the code base.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
docs/devel/style.rst | 7 +++++++
include/glib-compat.h | 6 +++---
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/docs/devel/style.rst b/docs/devel/style.rst
index 9c5c0fffd9..60dfdf9b7f 100644
--- a/docs/devel/style.rst
+++ b/docs/devel/style.rst
@@ -151,6 +151,13 @@ If there are two versions of a function to be called with or without a
lock held, the function that expects the lock to be already held
usually uses the suffix ``_locked``.
+If a function is a shim designed to deal with compatibility
+workarounds we use the suffix ``_compat``. These are generally not
+called directly and aliased to the plain function name via the
+pre-processor. Another common suffix that is used is ``__impl`` which
+is often used for the concrete implementation of something that has
+multiple potential approaches hidden behind a common function name or
+one that needs expansion via the pre-processor.
Block structure
===============
diff --git a/include/glib-compat.h b/include/glib-compat.h
index 9e95c888f5..9d3eb1b7a0 100644
--- a/include/glib-compat.h
+++ b/include/glib-compat.h
@@ -46,9 +46,9 @@
* int g_foo(const char *wibble)
*
* We must define a static inline function with the same signature that does
- * what we need, but with a "_qemu" suffix e.g.
+ * what we need, but with a "_compat" suffix e.g.
*
- * static inline void g_foo_qemu(const char *wibble)
+ * static inline void g_foo_compat(const char *wibble)
* {
* #if GLIB_CHECK_VERSION(X, Y, 0)
* g_foo(wibble)
@@ -61,7 +61,7 @@
* ensuring this wrapper function impl doesn't trigger the compiler warning
* about using too new glib APIs. Finally we can do
*
- * #define g_foo(a) g_foo_qemu(a)
+ * #define g_foo(a) g_foo_compat(a)
*
* So now the code elsewhere in QEMU, which *does* have the
* -Wdeprecated-declarations warning active, can call g_foo(...) as normal,
--
2.30.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [RFC PATCH] docs/devel: more documentation on the use of suffixes
2021-12-17 17:19 [RFC PATCH] docs/devel: more documentation on the use of suffixes Alex Bennée
@ 2021-12-17 17:26 ` Daniel P. Berrangé
2021-12-17 18:44 ` Philippe Mathieu-Daudé
2021-12-18 10:05 ` Paolo Bonzini
2 siblings, 0 replies; 4+ messages in thread
From: Daniel P. Berrangé @ 2021-12-17 17:26 UTC (permalink / raw)
To: Alex Bennée; +Cc: qemu-devel
On Fri, Dec 17, 2021 at 05:19:02PM +0000, Alex Bennée wrote:
> Using _qemu is a little confusing. Let's use _compat for these sorts
> of things. We should also mention _impl which is another common suffix
> in the code base.
>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
> docs/devel/style.rst | 7 +++++++
> include/glib-compat.h | 6 +++---
> 2 files changed, 10 insertions(+), 3 deletions(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC PATCH] docs/devel: more documentation on the use of suffixes
2021-12-17 17:19 [RFC PATCH] docs/devel: more documentation on the use of suffixes Alex Bennée
2021-12-17 17:26 ` Daniel P. Berrangé
@ 2021-12-17 18:44 ` Philippe Mathieu-Daudé
2021-12-18 10:05 ` Paolo Bonzini
2 siblings, 0 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-12-17 18:44 UTC (permalink / raw)
To: Alex Bennée, qemu-devel; +Cc: berrange
On 12/17/21 18:19, Alex Bennée wrote:
> Using _qemu is a little confusing. Let's use _compat for these sorts
> of things. We should also mention _impl which is another common suffix
> in the code base.
>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
> docs/devel/style.rst | 7 +++++++
> include/glib-compat.h | 6 +++---
> 2 files changed, 10 insertions(+), 3 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC PATCH] docs/devel: more documentation on the use of suffixes
2021-12-17 17:19 [RFC PATCH] docs/devel: more documentation on the use of suffixes Alex Bennée
2021-12-17 17:26 ` Daniel P. Berrangé
2021-12-17 18:44 ` Philippe Mathieu-Daudé
@ 2021-12-18 10:05 ` Paolo Bonzini
2 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2021-12-18 10:05 UTC (permalink / raw)
To: Alex Bennée, qemu-devel; +Cc: berrange
On 12/17/21 18:19, Alex Bennée wrote:
> Using _qemu is a little confusing. Let's use _compat for these sorts
> of things. We should also mention _impl which is another common suffix
> in the code base.
>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
> docs/devel/style.rst | 7 +++++++
> include/glib-compat.h | 6 +++---
> 2 files changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/docs/devel/style.rst b/docs/devel/style.rst
> index 9c5c0fffd9..60dfdf9b7f 100644
> --- a/docs/devel/style.rst
> +++ b/docs/devel/style.rst
> @@ -151,6 +151,13 @@ If there are two versions of a function to be called with or without a
> lock held, the function that expects the lock to be already held
> usually uses the suffix ``_locked``.
>
> +If a function is a shim designed to deal with compatibility
> +workarounds we use the suffix ``_compat``. These are generally not
> +called directly and aliased to the plain function name via the
> +pre-processor. Another common suffix that is used is ``__impl`` which
> +is often used for the concrete implementation of something that has
> +multiple potential approaches hidden behind a common function name or
> +one that needs expansion via the pre-processor.
Another common suffix is ``_impl``; it is used for the concrete
implementation of a function that will not be called directly, but
rather through a macro or an inline function.
Otherwise it is indeed worth documenting!
Paolo
>
> Block structure
> ===============
> diff --git a/include/glib-compat.h b/include/glib-compat.h
> index 9e95c888f5..9d3eb1b7a0 100644
> --- a/include/glib-compat.h
> +++ b/include/glib-compat.h
> @@ -46,9 +46,9 @@
> * int g_foo(const char *wibble)
> *
> * We must define a static inline function with the same signature that does
> - * what we need, but with a "_qemu" suffix e.g.
> + * what we need, but with a "_compat" suffix e.g.
> *
> - * static inline void g_foo_qemu(const char *wibble)
> + * static inline void g_foo_compat(const char *wibble)
> * {
> * #if GLIB_CHECK_VERSION(X, Y, 0)
> * g_foo(wibble)
> @@ -61,7 +61,7 @@
> * ensuring this wrapper function impl doesn't trigger the compiler warning
> * about using too new glib APIs. Finally we can do
> *
> - * #define g_foo(a) g_foo_qemu(a)
> + * #define g_foo(a) g_foo_compat(a)
> *
> * So now the code elsewhere in QEMU, which *does* have the
> * -Wdeprecated-declarations warning active, can call g_foo(...) as normal,
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-12-18 10:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-17 17:19 [RFC PATCH] docs/devel: more documentation on the use of suffixes Alex Bennée
2021-12-17 17:26 ` Daniel P. Berrangé
2021-12-17 18:44 ` Philippe Mathieu-Daudé
2021-12-18 10:05 ` Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).