Add clang format for C and C++

The libpldm is written in C and can be shared with projects other than
OpenBMC. The code written in C follows the Linux kernel coding guidelines.
The libpldmresponder and the application code follows the modern C++ and the
clang format follows the OpenBMC coding guidelines.

clang-format for each input file will try to find the .clang-format file
located in the closest parent directory of the input file. Since the C code is
in libpldm directory it has a specific .clang-format.

Change-Id: I9346d454cb20009c6daf526d4ceb722d7400a8d1
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
2 files changed
tree: 2f866123bffea20138b0e56cfa44d108c453c2a4
  1. libpldm/
  2. .clang-format
  3. LICENSE
  4. README.md
README.md

Code Organization

At a high-level, code in this repository belongs to one of the following three components.

libpldm

This is a library which deals with the encoding and decoding of PLDM messages. It should be possible to use this library by projects other than OpenBMC, and hence certain constraints apply to it:

  • keeping it light weight
  • implementation in C
  • minimal dynamic memory allocations
  • endian-safe
  • no OpenBMC specific dependencies

Source files are named according to the PLDM Type, for eg base.[h/c], fru.[h/c], etc.

Given a PLDM command "foo", the library will provide the following API: For the Requester function:

encode_foo_req() - encode a foo request
decode_foo_resp() - decode a response to foo

For the Responder function:

decode_foo_req() - decode a foo request
encode_foo_resp() - encode a response to foo

The library also provides API to pack and unpack PLDM headers.

libpldmresponder

This library provides handlers for incoming PLDM request messages. It provides for a registration as well as a plug-in mechanism. The library is implemented in modern C++, and handles OpenBMC's platform specifics.

The handlers are of the form

Response handler(Request payload, size_t payloadLen)

Source files are named according to the PLDM Type, for eg base.[hpp/cpp], fru.[hpp/cpp], etc.

daemon

This is the PLDM daemon application that deals with various aspects of the requester and responder functions, as explained at https://github.com/openbmc/docs/blob/master/designs/pldm-stack.md.

TODO

Consider hosting libpldm above in a repo of its own, probably even outside the OpenBMC project? A separate repo would enable something like git submodule.