k9core

Unnamed repository
Log | Files | Refs | LICENSE

commit cb17679d676d67fd4893dd4f07dd7e461eabdf4a
parent d4eb349c685759fdc6fda353ff6f14834ba1bc53
Author: qorg11 <qorg@vxempire.xyz>
Date:   Tue,  2 Jun 2020 01:13:04 +0200

added coding style guide

Diffstat:
ASTYLE.MD | 72++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 72 insertions(+), 0 deletions(-)

diff --git a/STYLE.MD b/STYLE.MD @@ -0,0 +1,72 @@ +# k9core coding style + +Pretty similar to the GNU code standards. + +## Functions definition + +Functions have to begin with return type, breakline, and functionname, +also brackets will be in a new line: + +~~~c +int +main(int argc, char *argv[]) +~~~ + +## Line length + +A line of code must no exced 75 characters. If it exceeds, do a +breakline: + +~~~c + +int +a_very_long_function(int a_very_long_parameter, int + another_very_long_parameter); +~~~ + +## Statements + +Do not do declarations inside an if block. Declarations inside while +loop are OK. + +~~~c +int fd; +if((fd = open("file", O_CREAT)) == -1) /* Don't do this */ +{ + /* Whatever */ +} + +/* Do this instead */ + +int fd = open("file", O_CREAT); +if(fd == -1) +{ + /* Whatever */ +} +~~~ + +## Comments + +Do not use C++ style comments. Comments at beggining of the line +should explain what the line does. not how it does. Comments at the +end of the line must be explanations of something: + +~~~c +// This is a wrong comment + +/* This is a correct comment */ + +/* Makes a syscall giving a file descriptor... */ + +fd = open("whatever",O_RDONLY); /* WRONG */ + +/* Creates a file descriptor on the file whatever */ + +fd = open("whatever",O_RDONLY); /* Yes */ + +/* 420 is 644 in decimal */ <- WRONG +chmod("whatever",420) + +chmod("whatever",420) /* 420 is 644 in decimal + +~~~