summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAhmed Ibrahim <ahmed.ibr.hashim@gmail.com>2023-03-24 14:10:57 +0200
committerDaniel Black <daniel@mariadb.org>2023-03-30 14:14:19 +1100
commitc4d6d6fd81662269a36a1699fedee00b03949f71 (patch)
treef71fd52071651915eec19bc05b06215103334507
parent5e01255732f554bbf473347566439fd18c006756 (diff)
downloadmariadb-git-c4d6d6fd81662269a36a1699fedee00b03949f71.tar.gz
CODING_STANDARDS: Add variable initializations and functions spacing
-rw-r--r--CODING_STANDARDS.md36
1 files changed, 35 insertions, 1 deletions
diff --git a/CODING_STANDARDS.md b/CODING_STANDARDS.md
index a35ce57d45c..3ecf73768e3 100644
--- a/CODING_STANDARDS.md
+++ b/CODING_STANDARDS.md
@@ -118,6 +118,23 @@ if (!condition)
return success;
```
+#### Functions
+
+Consecutive functions should be separated with 2 empty lines in between
+
+```cpp
+void my_function_1()
+{
+ <logic>
+}
+
+
+void my_function_2()
+{
+ <logic>
+}
+```
+
### File names
File names should be lower case with underscore word separators.
@@ -218,11 +235,28 @@ Variables should be declared at the start of it's context (start of function, in
The benefits of this:
- Code lines gets shorter
- It is easier to see the stack space used by a function.
-- It is easer to find the declaration of the variable.
+- It is easier to find the declaration of the variable.
- If one has to add an 'if (error) goto end' construct, one can do
that without having to move variable declarations around.
+### Variable initializations
+Variables can be initialized using assignment operator or initializer and expression list.
+For Example:
+
+```cpp
+int milliseconds= 1000;
+char type= 't';
+```
+
+Or
+
+```cpp
+int milliseconds{1000};
+char type{'t'};
+```
+
+
### Constant integers
Constant integers that are used to define elements such as buffer sizes should be defined rather than used directly.