Skip to content

Commit

Permalink
contributing: update to reference single line braces
Browse files Browse the repository at this point in the history
Signed-off-by: Maryam Tahhan <[email protected]>
  • Loading branch information
maryamtahhan committed Dec 19, 2022
1 parent 25d5fef commit e7bcf8a
Showing 1 changed file with 47 additions and 3 deletions.
50 changes: 47 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ This document outlines how to contribute code to the CNDP project.
The CNDP code can be cloned from the repository on GitHub:

``` bash
git clone https://github.com/CloudNativeDataPlane/cndp.git
$ git clone https://github.com/CloudNativeDataPlane/cndp.git
Cloning into 'cndp'...
remote: Enumerating objects: 4541, done.
remote: Counting objects: 100% (4541/4541), done.
remote: Compressing objects: 100% (1952/1952), done.
remote: Total 4541 (delta 2509), reused 4389 (delta 2462), pack-reused 0
Receiving objects: 100% (4541/4541), 2.74 MiB | 17.13 MiB/s, done.
Resolving deltas: 100% (2509/2509), done.
```

## Submitting Patches
Expand All @@ -18,8 +25,35 @@ Use GitHub Pull requests to change CNDP.

C code should follow the CNDP coding standards.

A .clang-format is available in the CNDP repo and can be run with ninja or a
pre-commit hook is available and can be used to apply the clang format to
A .clang-format file is available in the CNDP repo and can be run with ninja:

``` bash
$ ninja -C builddir clang-format
ninja: Entering directory `builddir'
[0/1] /usr/bin/meson --internal clangformat /home/cndp /home/cndp/builddir
```
Or with git-clang-format if it is installed:
``` bash
$ git clang-format --diff
diff --git a/examples/cli/main.c b/examples/cli/main.c
index 66b42e7..3f7a15a 100644
--- a/examples/cli/main.c
+++ b/examples/cli/main.c
@@ -62,7 +62,8 @@ __on_exit(int val, void *arg __cne_unused, int exit_type)
}
static int
-sizeof_cmd(int argc, char **argv) {
+sizeof_cmd(int argc, char **argv)
+{
// clang-format off
struct struct_sizes ssizes[] = {
{"mmap_sizes_t", sizeof(mmap_sizes_t)},
```
Or a pre-commit hook is available and can be used to apply the clang format to
modified files in a commit by doing the following before committing changes:
``` bash
Expand Down Expand Up @@ -87,6 +121,16 @@ int foobar(foo_t *foo) {
Naming header files as xyz\_private.h and cne\_xyz.h is preferred. The .c files should be named
xyz.c or cne\_xyz.c.
### Braces for single line statements
Do not use braces where a single statement (if, while, for, ...) will do:
``` c
if (foo)
do_this();
else
do_that();
```
## Maintainers
The CNDP maintainers are as follows:
Expand Down

0 comments on commit e7bcf8a

Please sign in to comment.