[PATCH v2 05/13] Rephrase section about constants

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Christophe de Dinechin <dinechin@xxxxxxxxxx>

The indent of the rephrasing is that:

- If you have a single constant, use const, e.g. (visible in debugger)
    const unsigned max_stuff = 42;

- If you have multiple constants, prefer enums over #define, as
    already suggested later in the guide:
    enum {
       A = 0,
       B = 42,
       C = -1
    }

Signed-off-by: Christophe de Dinechin <dinechin@xxxxxxxxxx>
---
 docs/spice_style.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/docs/spice_style.txt b/docs/spice_style.txt
index 61cb0701..3e463d2f 100644
--- a/docs/spice_style.txt
+++ b/docs/spice_style.txt
@@ -106,7 +106,9 @@ Using goto is allowed in C code for error handling. In any other case it will be
 Defining Constant values
 ------------------------
 
-Use defines for constant values for improving readability and ease of changes. Alternatively, use global `const` variables.
+Use defines for constant values for improving readability and ease of changes.
+Alternatively, use global `const` variables for individual values.
+If multiple related constants are to be defined, consider the use of enumerations with initializers.
 
 Short functions
 ---------------
-- 
2.13.5 (Apple Git-94)

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]