openbmc / libpldm

Apache License 2.0
9 stars 12 forks source link

C library hygiene: Use symbol prefixes as a namespace mechanism to mitigate the risk of clashes #2

Open amboar opened 2 years ago

amboar commented 2 years ago

libpldm exposes many encode, decode and utility functions as part of its API, but none of them are prefixed to prevent symbol clashes in applications that link against more libraries than just libpldm. For instance, some utility symbols exported by the library include crc8(), crc32() and others.

This violates the best practices suggestion from Good Practices in Library Design, Implementation, and Maintenance:

For every library prepend a chosen prefix to every interface, variable, functions, data structures, a library provides. The prefix need not necessarily be the same for all objects, a library can use more than one prefix.