[Spice-devel] [PATCH v3 04/11] Rephrase assertion section

Christophe Fergeau cfergeau at redhat.com
Wed Feb 14 13:08:07 UTC 2018


On Thu, Feb 08, 2018 at 12:25:24PM +0100, Christophe de Dinechin wrote:
> From: Christophe de Dinechin <dinechin at redhat.com>
> 
> Signed-off-by: Christophe de Dinechin <dinechin at redhat.com>
> ---
>  docs/spice_style.txt | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/docs/spice_style.txt b/docs/spice_style.txt
> index 13032df6..eef4880f 100644
> --- a/docs/spice_style.txt
> +++ b/docs/spice_style.txt
> @@ -99,10 +99,19 @@ FIXME and TODO
>  
>  Comments that are prefixed with `FIXME` describe a bug that need to be fixed. Generally, it is not allowed to commit new code having `FIXME` comment. Committing  `FIXME` is allowed only for existing bugs. Comments that are prefixed with `TODO` describe further features, optimization or code improvements, and they are allowed to be committed along with the relevant code.
>  
> -ASSERT
> -------
> +Assertions
> +----------
> +
> +Use assertions liberally. Assertions help testing function arguments
> and function results validity. As a result, they make it easier to
> detect bugs. Also, by expressing the intent of the developer, they
> make the code easier to read.  +

Given the rest of the thread, it's not clear if you mean "assertions
which abort the program", or runtime checks such as
g_warn_if_fail()/g_return_if_fail()/... I'm very much in favour of using
the latter functions liberally. I think we should avoid as much as
possible the use of anything calling abort(), especially in library
code. If a user can get the abort() to trigger, that means they can just
kill their VM, which is not a nice thing to do ;) So one should really
think hard before adding a g_assert() in the code.

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20180214/ff7cec39/attachment-0001.sig>


More information about the Spice-devel mailing list