Learning VPP: Code style

logo_fdio-300x184

Overview

It is important that an open-source or proprietary product follows strict code style guidelines. It helps people who are involved in the project to understand, extend and maintain the codebase far more comfortably. Let alone it makes the code listings look neat and clean.

And VPP could be a good example of the above statement. It has a strict and well-defined code style that is based on GNU Coding Standards.

Hints

For example, an indentation looks as follows.

if (1)
  {
  }

A routine definition looks as follows.

static int
vnet_test_add_del(u8 * name, u32 index, u8 add);

A function call looks as follows.

vnet_feature_enable_disable ("device-input", "test",
			     sw_if_index, enable_disable, 0, 0);

To verify that your code is following the agreement the following command is used.

make checkstyle

VPP developers provided the rules written as a clang-format file that can be used by different tools and IDEs to enforce code formatting.

References

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s