This repository has been archived by the owner on Jan 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ikey Doherty <[email protected]>
- Loading branch information
Ikey Doherty
committed
Mar 24, 2015
0 parents
commit e860c9a
Showing
46 changed files
with
5,020 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Makefile | ||
Makefile.in | ||
m4/ | ||
config.* | ||
ltmain.sh | ||
libtool | ||
install-sh | ||
stamp-* | ||
depcomp | ||
missing | ||
aclocal.m4 | ||
.deps | ||
compile | ||
configure | ||
*.o | ||
autom4te.cache | ||
cve-check-tool | ||
report.html | ||
test-driver | ||
|
||
# Checks | ||
check_core | ||
check_*.log | ||
check_*.trs | ||
test-*.log | ||
.dirstamp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Ikey Doherty <[email protected]> | ||
John L. Whiteman <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
Hacking cve-check-tool | ||
---------------------- | ||
|
||
Indentation is strictly 8 spaces (set tab stops to 8 spaces) - No tabs | ||
No spaces between function name and parentheses. Only use space after | ||
"if (", etc. | ||
|
||
Curly braces must be on the same line (i.e. expressions) unless it | ||
is the function declaration: | ||
|
||
Acceptable: | ||
int main(int argc, char **argv) | ||
{ | ||
if (someThingOrOther) { | ||
// Do something | ||
} | ||
return 0; | ||
} | ||
|
||
Unacceptable: | ||
int main(int argc, char **argv) { | ||
|
||
if(someThingOrOther) | ||
{ | ||
// Do something | ||
} | ||
return 0; | ||
} | ||
|
||
When appropriate remember to declare your function first! It helps when | ||
looking back through the file. | ||
|
||
Use consistent pointers! "*" should prefix your variable name. Also ensure | ||
your pointers (where appropriate) are not left uninitialized, resulting | ||
in broken g_free() calls. | ||
|
||
Acceptable: | ||
char *something = NULL; | ||
doFunc(&something); | ||
|
||
Unacceptable: | ||
char* something; | ||
doFunc(&someThing); | ||
|
||
Minimise your use of "goto"'s, and test every code path is reached. Also | ||
ensure *every* if/else, etc, even if single line, is wrapped in curly braces. | ||
|
||
Memory management: | ||
------------------ | ||
cve-check-tool prefers a scope-based approach to memory management, | ||
employing a RAII-like system for allocations. Where possible, avoid | ||
explicit free's and reuse of unrelated variables. | ||
|
||
util.h defines a number of autofree()-ready types. These are implemented | ||
using __attribute__ ((cleanup(x))), available in GCC and Clang. Thus, | ||
MSVC (and potentially other compilers) are not supported. | ||
|
||
An autofree variable is declared using the autofree() macro, which is | ||
primarily provided for syntatical sugar. Here is an example of a | ||
variable that is automatically reaped/freed when it goes out of scope: | ||
|
||
autofree(GError) *error = NULL; | ||
|
||
Remember that these *are* scope sensitive, so the following would result | ||
in undefined behaviour: | ||
|
||
gchar *somestr = NULL; | ||
{ | ||
autofree(gchar) *str = g_strdup_printf("Scoped string\n"); | ||
somestr = str; | ||
} | ||
printf("%s: %d\n", somestr, strlen(somestr)); | ||
|
||
At this point, 'str' has been freed, and somestr still points to the | ||
memory that has now been freed. | ||
|
||
As a rule of thumb, if you find yourself in an instance where you have | ||
used an explicit free/unref in a fashion that could be automated, you | ||
should define the cleanup function in util.h (see DEF_AUTOFREE) | ||
|
||
Pull Requests/commiting: | ||
------------------------ | ||
Commits should clearly define the purpose in less than 80 columns in | ||
the first line. Futher expansion, if needed, should be provided in a | ||
following paragraph, separated by one blank line. | ||
|
||
N.B This hacking document is a port of Evolve OS C Coding Style. | ||
For futher details (including *non-glib*) functions, see: | ||
|
||
* https://evolve-os.com/wiki/Development/CodingStyleC |
Oops, something went wrong.