12643f83cSAndrew Jeffery# Checklist for making changes to `libpldm` 22643f83cSAndrew Jeffery 3ac3802e0SAndrew Jeffery## Philosophy and influences 4ac3802e0SAndrew Jeffery 5ac3802e0SAndrew Jeffery- [Good Practices in Library Design, Implementation, and Maintenance - Ulrich 6ac3802e0SAndrew Jeffery Drepper][goodpractice] 7ac3802e0SAndrew Jeffery 8ac3802e0SAndrew Jeffery[goodpractice]: https://www.akkadia.org/drepper/goodpractice.pdf 9ac3802e0SAndrew Jeffery 10ac3802e0SAndrew Jeffery- [How Do I Make This Hard to Misuse? - Rusty Russell][rusty-api-scale-good] 11ac3802e0SAndrew Jeffery 12ac3802e0SAndrew Jeffery[rusty-api-scale-good]: https://ozlabs.org/~rusty/index.cgi/tech/2008-03-30.html 13ac3802e0SAndrew Jeffery 14ac3802e0SAndrew Jeffery- [What If I Don't Actually Like My Users? - Rusty Russell][rusty-api-scale-bad] 15ac3802e0SAndrew Jeffery 16ac3802e0SAndrew Jeffery[rusty-api-scale-bad]: https://ozlabs.org/~rusty/index.cgi/tech/2008-04-01.html 17ac3802e0SAndrew Jeffery 188979bf35SAndrew Jeffery- [Red flags that indicate questionable quality - Lennart 198979bf35SAndrew Jeffery Poettering][poettering-library-red-flags] 208979bf35SAndrew Jeffery 218979bf35SAndrew Jeffery[poettering-library-red-flags]: 228979bf35SAndrew Jeffery https://mastodon.social/@pid_eins/112517953375791453 238979bf35SAndrew Jeffery 249817fa5cSAndrew Jeffery- [Not sure if this is a gcc bug or some weird corner of UB or what... - Andrew 259817fa5cSAndrew Jeffery Zonenberg][azonenberg-packed-struct] 269817fa5cSAndrew Jeffery 279817fa5cSAndrew Jeffery[azonenberg-packed-struct]: https://ioc.exchange/@azonenberg/112535511250395148 289817fa5cSAndrew Jeffery 294d1b1a54SAndrew Jeffery- [The Good, the Bad, and the Weird - Trail of Bits 304d1b1a54SAndrew Jeffery Blog][trail-of-bits-weird-machines] 314d1b1a54SAndrew Jeffery 324d1b1a54SAndrew Jeffery[trail-of-bits-weird-machines]: 334d1b1a54SAndrew Jeffery https://blog.trailofbits.com/2018/10/26/the-good-the-bad-and-the-weird/ 344d1b1a54SAndrew Jeffery 355302dc24SAndrew Jeffery- [Logic for Programmers - Hillel Wayne][logic-for-programmers] 365302dc24SAndrew Jeffery 375302dc24SAndrew Jeffery[logic-for-programmers]: https://leanpub.com/logic 385302dc24SAndrew Jeffery 39bf827b6fSAndrew Jeffery- [Parse, don’t validate - Alexis King][alexis-king-parse-dont-validate] 409902eabcSAndrew Jeffery 419902eabcSAndrew Jeffery[alexis-king-parse-dont-validate]: 429902eabcSAndrew Jeffery https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/ 439902eabcSAndrew Jeffery 44bd092fc7SAndrew Jeffery- [The byte order fallacy - command center][command-center-byte-order-fallacy] 45bd092fc7SAndrew Jeffery 46bd092fc7SAndrew Jeffery[command-center-byte-order-fallacy]: 47bd092fc7SAndrew Jeffery https://commandcenter.blogspot.com/2012/04/byte-order-fallacy.html 48bd092fc7SAndrew Jeffery 491bfd0346SAndrew Jeffery- [what’s the most annoying thing about writing C - Jessica 501bfd0346SAndrew Jeffery Paquette][barrelshifter-annoying-c] 511bfd0346SAndrew Jeffery 521bfd0346SAndrew Jeffery[barrelshifter-annoying-c]: 531bfd0346SAndrew Jeffery https://mastodon.social/@barrelshifter/114016810912730423 541bfd0346SAndrew Jeffery 5593b071beSAndrew Jeffery- [The Power of Ten: Rules for Developing Safety Critical Code - NASA/JPL 5693b071beSAndrew Jeffery Laboratory for Reliable Software][nasa-reliable-code] 5793b071beSAndrew Jeffery 5893b071beSAndrew Jeffery[nasa-reliable-code]: 5993b071beSAndrew Jeffery https://www.cs.otago.ac.nz/cosc345/resources/nasa-10-rules.pdf 6093b071beSAndrew Jeffery 613b986d3aSAndrew Jeffery- [C Isn't A Programming Language Anymore - Aria Desires][aria-c-is-a-protocol] 623b986d3aSAndrew Jeffery 633b986d3aSAndrew Jeffery[aria-c-is-a-protocol]: https://faultlore.com/blah/c-isnt-a-language/ 643b986d3aSAndrew Jeffery 65ac3802e0SAndrew Jeffery## References 66ac3802e0SAndrew Jeffery 67eba23b93SAndrew Jeffery- [The C programming language - C Standards Committee][c-language] 68ac3802e0SAndrew Jeffery 69eba23b93SAndrew Jeffery[c-language]: https://www.c-language.org/ 70ac3802e0SAndrew Jeffery 714d1b1a54SAndrew Jeffery- [SEI CERT C Coding Standard][sei-cert-c-coding-standard] 724d1b1a54SAndrew Jeffery 734d1b1a54SAndrew Jeffery[sei-cert-c-coding-standard]: 744d1b1a54SAndrew Jeffery https://wiki.sei.cmu.edu/confluence/display/c/SEI+CERT+C+Coding+Standard 754d1b1a54SAndrew Jeffery 76efd5e1d5SAndrew Jeffery- [Common Weakness Enumeration (CWE) - Software 77efd5e1d5SAndrew Jeffery Development][common-weakness-enumeration-sw] 78efd5e1d5SAndrew Jeffery 79efd5e1d5SAndrew Jeffery[common-weakness-enumeration-sw]: 80efd5e1d5SAndrew Jeffery https://cwe.mitre.org/data/definitions/699.html 81efd5e1d5SAndrew Jeffery 822643f83cSAndrew Jeffery## Definitions 832643f83cSAndrew Jeffery 84ee6fb1aeSAndrew Jeffery- **Error condition**: An invalid state reached at runtime, caused either by 85ee6fb1aeSAndrew Jeffery resource exhaustion, or incorrect use of the library's public APIs and data 86ee6fb1aeSAndrew Jeffery types. 87ee6fb1aeSAndrew Jeffery 88ee6fb1aeSAndrew Jeffery- **Invariant**: A condition in the library's implementation that must never 89ee6fb1aeSAndrew Jeffery evaluate false. 90ee6fb1aeSAndrew Jeffery 91ee6fb1aeSAndrew Jeffery- **Public API**: Any definitions and declarations under `include/libpldm`. 92ee6fb1aeSAndrew Jeffery 93d0c7105cSAndrew Jeffery- **Wire format**: Any message structure defined in the DMTF PLDM protocol 94d0c7105cSAndrew Jeffery specifications. 95d0c7105cSAndrew Jeffery 96ee6fb1aeSAndrew Jeffery## Elaborations 97ee6fb1aeSAndrew Jeffery 98ee6fb1aeSAndrew Jeffery- Resource exhaustion is always an error condition and never an invariant 99ee6fb1aeSAndrew Jeffery violation. 100ee6fb1aeSAndrew Jeffery 101ee6fb1aeSAndrew Jeffery- An invariant violation is always a programming failure of the library's 102ee6fb1aeSAndrew Jeffery implementation, and never the result of incorrect use of the library's public 103ee6fb1aeSAndrew Jeffery APIs (see error condition). 104ee6fb1aeSAndrew Jeffery 105c51a4a12SAndrew Jeffery- Corollaries of the above two points: 106ee6fb1aeSAndrew Jeffery - Incorrect use of public API functions is always an error condition, and is 107ee6fb1aeSAndrew Jeffery dealt with by returning an error code. 108ee6fb1aeSAndrew Jeffery 109ee6fb1aeSAndrew Jeffery - Incorrect use of static functions in the library's implementation is an 110ee6fb1aeSAndrew Jeffery invariant violation which may be established using `assert()`. 111ee6fb1aeSAndrew Jeffery 112ee6fb1aeSAndrew Jeffery- `assert()` is the recommended way to demonstrate invariants are upheld. 1132643f83cSAndrew Jeffery 114ab020b60SAndrew Jeffery## Library background 115ab020b60SAndrew Jeffery 116ab020b60SAndrew Jeffery### The ABI lifecycle 117ab020b60SAndrew Jeffery 118ab020b60SAndrew Jeffery```mermaid 119ab020b60SAndrew Jeffery--- 120ab020b60SAndrew Jefferytitle: libpldm symbol lifecycle 121ab020b60SAndrew Jeffery--- 122ab020b60SAndrew JefferystateDiagram-v2 123ab020b60SAndrew Jeffery direction LR 124ab020b60SAndrew Jeffery [*] --> Testing: Add 125ab020b60SAndrew Jeffery Testing --> Testing: Change 126ab020b60SAndrew Jeffery Testing --> [*]: Remove 127ab020b60SAndrew Jeffery Testing --> Stable: Stabilise 128ab020b60SAndrew Jeffery Stable --> Deprecated: Deprecate 129ab020b60SAndrew Jeffery Deprecated --> [*]: Remove 130ab020b60SAndrew Jeffery``` 131ab020b60SAndrew Jeffery 132ab020b60SAndrew JefferyThe ABI of the library produced by the build is controlled using the `abi` meson 133ab020b60SAndrew Jefferyoption. The following use cases determine how the `abi` option should be 134ab020b60SAndrew Jefferyspecified: 135ab020b60SAndrew Jeffery 136ab020b60SAndrew Jeffery| Use Case | Meson Configuration | 137ab020b60SAndrew Jeffery| ----------- | --------------------------------- | 138ab020b60SAndrew Jeffery| Production | `-Dabi=deprecated,stable` | 139ab020b60SAndrew Jeffery| Maintenance | `-Dabi=stable` | 140ab020b60SAndrew Jeffery| Development | `-Dabi=deprecated,stable,testing` | 141ab020b60SAndrew Jeffery 142ab020b60SAndrew Jeffery### Maintenance 143ab020b60SAndrew Jeffery 144ab020b60SAndrew JefferyApplications and libraries that depend on `libpldm` can identify how to migrate 145ab020b60SAndrew Jefferyoff of deprecated APIs by constraining the library ABI to the stable category. 146ab020b60SAndrew JefferyThis will force the compiler identify any call-sites that try to link against 147ab020b60SAndrew Jefferydeprecated symbols. 148ab020b60SAndrew Jeffery 149ab020b60SAndrew Jeffery### Development 150ab020b60SAndrew Jeffery 151ab020b60SAndrew JefferyApplications and libraries often require functionality that doesn't yet exist in 152ab020b60SAndrew Jeffery`libpldm`. The work is thus in two parts: 153ab020b60SAndrew Jeffery 154ab020b60SAndrew Jeffery1. Add the required APIs to `libpldm` 155ab020b60SAndrew Jeffery2. Use the new APIs from `libpldm` in the dependent application or library 156ab020b60SAndrew Jeffery 157ab020b60SAndrew JefferyAdding APIs to a library is a difficult task. Generally, once an API is exposed 158ab020b60SAndrew Jefferyin the library's ABI, any changes to the API risk breaking applications already 159ab020b60SAndrew Jefferymaking use of it. To make sure we have more than one shot at getting an API 160ab020b60SAndrew Jefferyright, all new APIs must first be exposed in the testing category. Concretely: 161ab020b60SAndrew Jeffery 162ab020b60SAndrew JefferyPatches adding new APIs MUST mark them as testing and MUST NOT mark them as 163ab020b60SAndrew Jefferystable. 164ab020b60SAndrew Jeffery 165ab020b60SAndrew Jeffery### Marking functions as testing, stable or deprecated 166ab020b60SAndrew Jeffery 167ab020b60SAndrew JefferyThree macros are provided through `config.h` (automatically included for all 168ab020b60SAndrew Jefferytranslation units) to mark functions as testing, stable or deprecated: 169ab020b60SAndrew Jeffery 170ab020b60SAndrew Jeffery1. `LIBPLDM_ABI_TESTING` 171ab020b60SAndrew Jeffery2. `LIBPLDM_ABI_STABLE` 172ab020b60SAndrew Jeffery3. `LIBPLDM_ABI_DEPRECATED` 173ab020b60SAndrew Jeffery 174ab020b60SAndrew JefferyThese annotations go immediately before your function signature: 175ab020b60SAndrew Jeffery 176ab020b60SAndrew Jeffery```c 177ab020b60SAndrew JefferyLIBPLDM_ABI_TESTING 178ab020b60SAndrew Jefferypldm_requester_rc_t pldm_transport_send_msg(struct pldm_transport *transport, 179ab020b60SAndrew Jeffery pldm_tid_t tid, 180ab020b60SAndrew Jeffery const void *pldm_req_msg, 181ab020b60SAndrew Jeffery size_t req_msg_len) 182ab020b60SAndrew Jeffery{ 183ab020b60SAndrew Jeffery ... 184ab020b60SAndrew Jeffery} 185ab020b60SAndrew Jeffery``` 186ab020b60SAndrew Jeffery 187ab020b60SAndrew Jeffery### What does it mean to mark a function as stable? 188ab020b60SAndrew Jeffery 189ab020b60SAndrew JefferyMarking a function as stable makes the following promise to users of the 190ab020b60SAndrew Jefferylibrary: 191ab020b60SAndrew Jeffery 192ab020b60SAndrew Jeffery> We will not remove or change the symbol name, argument count, argument types, 193ab020b60SAndrew Jeffery> return type, or interpretation of relevant values for the function before 194ab020b60SAndrew Jeffery> first marking it as `LIBPLDM_ABI_DEPRECATED` and then subsequently creating a 195ab020b60SAndrew Jeffery> tagged release 196ab020b60SAndrew Jeffery 197ab020b60SAndrew JefferyMarking a function as stable does _not_ promise that it is free of 198ab020b60SAndrew Jefferyimplementation bugs. It is just a promise that the prototype won't change 199ab020b60SAndrew Jefferywithout notice. 200ab020b60SAndrew Jeffery 201ab020b60SAndrew JefferyGiven this, it is always okay to implement functions marked stable in terms of 202ab020b60SAndrew Jefferyfunctions marked testing inside of libpldm. If we remove or change the prototype 203ab020b60SAndrew Jefferyof a function marked testing the only impact is that we need to fix up any call 204ab020b60SAndrew Jefferysites of that function in the same patch. 205ab020b60SAndrew Jeffery 206ab020b60SAndrew Jeffery### Requirements for stabilising a function 207ab020b60SAndrew Jeffery 208ab020b60SAndrew JefferyTo move a function from the testing category to the stable category, it's 209ab020b60SAndrew Jefferyrequired that patches demonstrating use of the function in a dependent 210ab020b60SAndrew Jefferyapplication or library be linked in the commit message of the stabilisation 211ab020b60SAndrew Jefferychange. We require this to demonstrate that the implementer has considered its 212ab020b60SAndrew Jefferyuse in context _before_ preventing us from making changes to the API. 213ab020b60SAndrew Jeffery 214ab020b60SAndrew Jeffery### Building a dependent application or library against a testing ABI 215ab020b60SAndrew Jeffery 216ab020b60SAndrew JefferyMeson is broadly used in the OpenBMC ecosystem, the historical home of 217ab020b60SAndrew Jeffery`libpldm`. Meson's subprojects are a relatively painless way of managing 218ab020b60SAndrew Jefferydependencies for the purpose of developing complex applications and libraries. 219ab020b60SAndrew JefferyUse of `libpldm` as a subproject is both supported and encouraged. 220ab020b60SAndrew Jeffery 221ab020b60SAndrew Jeffery`libpldm`'s ABI can be controlled from a parent project through meson's 222ab020b60SAndrew Jefferysubproject configuration syntax: 223ab020b60SAndrew Jeffery 224ab020b60SAndrew Jeffery```shell 225ab020b60SAndrew Jefferymeson setup ... -Dlibpldm:abi=deprecated,stable,testing ... 226ab020b60SAndrew Jeffery``` 227ab020b60SAndrew Jeffery 2282643f83cSAndrew Jeffery## Adding a new API 2292643f83cSAndrew Jeffery 2301c4c704dSAndrew Jeffery### Naming macros, functions and types 2311c4c704dSAndrew Jeffery 2321c4c704dSAndrew Jeffery- [ ] All publicly exposed macros, types and functions relating to the PLDM 2331c4c704dSAndrew Jeffery specifications must be prefixed with either `pldm_` or `PLDM_` as 2341c4c704dSAndrew Jeffery appropriate 2351c4c704dSAndrew Jeffery - The only (temporary) exception are the `encode_*()` and `decode_*()` 2361c4c704dSAndrew Jeffery function symbols 2371c4c704dSAndrew Jeffery 2381c4c704dSAndrew Jeffery- [ ] All publicly exposed macros, types and functions relating to the library 2391c4c704dSAndrew Jeffery implementation must be prefixed with `libpldm_` or `LIBPLDM_` 2401c4c704dSAndrew Jeffery 2411c4c704dSAndrew Jeffery- [ ] All `pldm_`-prefixed symbols must also name the related specification. For 2421c4c704dSAndrew Jeffery example, for DSP0248 Platform Monitoring and Control, the symbol prefix 2431c4c704dSAndrew Jeffery should be `pldm_platform_`. 2441c4c704dSAndrew Jeffery 2451c4c704dSAndrew Jeffery- [ ] All enum members must be prefixed with the type name 2461c4c704dSAndrew Jeffery 24773625d74SAndrew Jeffery### API design 24873625d74SAndrew Jeffery 24973625d74SAndrew Jeffery- [ ] If I've added support for a new PLDM message type, then I've defined both 2500b140da0SAndrew Jeffery the encoder and decoder for that message. 2510b140da0SAndrew Jeffery - This applies for both request _and_ response message types. 2521c4c704dSAndrew Jeffery 25302c9d37fSAndrew Jeffery- [ ] I've designed my APIs so their implementation does not require heap 25402c9d37fSAndrew Jeffery allocation. 25502c9d37fSAndrew Jeffery - Prefer [defining iterators][libpldm-iterator] over the message buffer to 25602c9d37fSAndrew Jeffery extract sub-structures from variable-length messages. Iterators avoid both 25702c9d37fSAndrew Jeffery requiring heap allocation in the implementation or splitting the API to 25802c9d37fSAndrew Jeffery allow the caller to allocate appropriate space. Instead, the caller is 25902c9d37fSAndrew Jeffery provided with an on-stack struct containing the extracted sub-structure. 26002c9d37fSAndrew Jeffery 26102c9d37fSAndrew Jeffery[libpldm-iterator]: 26202c9d37fSAndrew Jeffery https://github.com/openbmc/libpldm/commit/3a2c6589c5660d2066b612bae28ca393a8aa1c2b 26302c9d37fSAndrew Jeffery 264c47f1a26SAndrew Jeffery- [ ] My new public message codec functions take a `struct` representing the 265c47f1a26SAndrew Jeffery message as a parameter 266c47f1a26SAndrew Jeffery - Function prototypes must _not_ decompose the message to individual 267c47f1a26SAndrew Jeffery parameters. This approach is not ergonomic and is difficult to make 268c47f1a26SAndrew Jeffery type-safe. This is especially true for message decoding functions which must 269c47f1a26SAndrew Jeffery use pointers for out-parameters, where it has often become ambiguous whether 270c47f1a26SAndrew Jeffery the underlying memory represents a single object or an array. 271c47f1a26SAndrew Jeffery 27244471feaSAndrew Jeffery- [ ] Each new `struct` I've defined is used in at least one new function I've 27344471feaSAndrew Jeffery added to the public API. 27444471feaSAndrew Jeffery 2752643f83cSAndrew Jeffery- [ ] My new public `struct` definitions are _not_ marked 2762643f83cSAndrew Jeffery `__attribute__((packed))` 2772643f83cSAndrew Jeffery 2782222595dSAndrew Jeffery- [ ] My new public `struct` definitions do _not_ define a flexible array 2792222595dSAndrew Jeffery member, unless: 2802222595dSAndrew Jeffery - [ ] It's contained in an `#ifndef __cplusplus` macro guard, as flexible 2812222595dSAndrew Jeffery arrays are not specified by C++, and 2822222595dSAndrew Jeffery 2832222595dSAndrew Jeffery - [ ] I've implemented an accessor function so the array base pointer can be 2842222595dSAndrew Jeffery accessed from C++, and 2852222595dSAndrew Jeffery 2862222595dSAndrew Jeffery - [ ] It is defined as per the C17 specification by omitting the length[^1] 2872222595dSAndrew Jeffery - Note: Any array defined with length 1 is _not_ a flexible array, and any 2882222595dSAndrew Jeffery access beyond the first element invokes undefined behaviour in both C and 2892222595dSAndrew Jeffery C++. 2902222595dSAndrew Jeffery 291eee9ad05SAndrew Jeffery - [ ] I've annotated the flexible array member with `LIBPLDM_CC_COUNTED_BY()` 292eee9ad05SAndrew Jeffery 2932222595dSAndrew Jeffery[^1]: 2942222595dSAndrew Jeffery [C17 draft specification][c17-draft-standard], 6.7.2.1 Structure and union 2952222595dSAndrew Jeffery specifiers, paragraph 18. 2962222595dSAndrew Jeffery 297412fa270SPatrick Williams[c17-draft-standard]: 298412fa270SPatrick Williams https://web.archive.org/web/20181230041359/http://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf 299412fa270SPatrick Williams 30073625d74SAndrew Jeffery### ABI control 30173625d74SAndrew Jeffery 30273625d74SAndrew Jeffery- [ ] My new function symbols are marked with `LIBPLDM_ABI_TESTING` in the 30373625d74SAndrew Jeffery implementation 30473625d74SAndrew Jeffery 30573625d74SAndrew Jeffery- [ ] I've guarded the test cases of functions marked `LIBPLDM_ABI_TESTING` so 30673625d74SAndrew Jeffery that they are not compiled when the corresponding function symbols aren't 30773625d74SAndrew Jeffery visible 30873625d74SAndrew Jeffery 30973625d74SAndrew Jeffery### Error handling and invariants 3102643f83cSAndrew Jeffery 311ee6fb1aeSAndrew Jeffery- [ ] All my error conditions are handled by returning an error code to the 312ee6fb1aeSAndrew Jeffery caller. 313ee6fb1aeSAndrew Jeffery 314ee6fb1aeSAndrew Jeffery- [ ] All my invariants are tested using `assert()`. 315ee6fb1aeSAndrew Jeffery 316ee6fb1aeSAndrew Jeffery- [ ] I have not used `assert()` to evaluate any error conditions without also 317ee6fb1aeSAndrew Jeffery handling the error condition by returning an error code the the caller. 318ee6fb1aeSAndrew Jeffery - Release builds of the library are configured with `assert()` disabled 319ee6fb1aeSAndrew Jeffery (`-Db_ndebug=if-release`, which provides `-DNDEBUG` in `CFLAGS`). 320ee6fb1aeSAndrew Jeffery 3218c0e7a31SAndrew Jeffery- [ ] My new APIs return negative `errno` values on error and not PLDM 3228c0e7a31SAndrew Jeffery completion codes. 323c8df31c1SAndrew Jeffery - [ ] The specific error values my function returns and their meaning in the 324c8df31c1SAndrew Jeffery context of the function call are listed in the API documentation. 325c8df31c1SAndrew Jeffery 32673625d74SAndrew Jeffery### Implementation 3272643f83cSAndrew Jeffery 32873625d74SAndrew Jeffery- [ ] If my work interacts with the PLDM wire format, then I have done so using 32973625d74SAndrew Jeffery the `msgbuf` APIs found in `src/msgbuf.h` (and under `src/msgbuf/`) to 33073625d74SAndrew Jeffery minimise concerns around spatial memory safety and endian-correctness. 33173625d74SAndrew Jeffery 332059684c8SAndrew Jeffery- [ ] I've used `goto` to clean up resources acquired prior to encountering an 333059684c8SAndrew Jeffery error condition 334059684c8SAndrew Jeffery - Replication of resource cleanup across multiple error paths is error-prone, 335059684c8SAndrew Jeffery especially when multiple, dependent resources have been acquired. 336059684c8SAndrew Jeffery 337059684c8SAndrew Jeffery- [ ] I've released acquired resources in stack-order 338059684c8SAndrew Jeffery - This should be the case regardless of whether we're in the happy path at the 339059684c8SAndrew Jeffery end of object lifetime or an error path during construction. 340059684c8SAndrew Jeffery 341effec66fSAndrew Jeffery- [ ] I've declared variables in [reverse-christmas-tree (inverted pyramid) 342effec66fSAndrew Jeffery order][hisham-make-pyramids] in any block scopes I've added or changed. 343effec66fSAndrew Jeffery 344effec66fSAndrew Jeffery[hisham-make-pyramids]: 345effec66fSAndrew Jeffery https://web.archive.org/web/20220404224603/https://hisham.hm/2018/06/16/when-listing-repeated-things-make-pyramids/ 346effec66fSAndrew Jeffery 34773625d74SAndrew Jeffery### Testing 3482643f83cSAndrew Jeffery 3492643f83cSAndrew Jeffery- [ ] I've implemented test cases with reasonable branch coverage of each new 3502643f83cSAndrew Jeffery function I've added 3512643f83cSAndrew Jeffery 35273625d74SAndrew Jeffery### Maintenance 3532643f83cSAndrew Jeffery 3542643f83cSAndrew Jeffery- [ ] If I've added support for a new message type, then my commit message 3552643f83cSAndrew Jeffery specifies all of: 3562643f83cSAndrew Jeffery - [ ] The relevant DMTF specification by its DSP number and title 3572643f83cSAndrew Jeffery - [ ] The relevant version of the specification 3582643f83cSAndrew Jeffery - [ ] The section of the specification that defines the message type 3592643f83cSAndrew Jeffery 3602643f83cSAndrew Jeffery- [ ] If my work impacts the public API of the library, then I've added an entry 3612643f83cSAndrew Jeffery to `CHANGELOG.md` describing my work 3622643f83cSAndrew Jeffery 363ab020b60SAndrew Jeffery### OEM/vendor-specific APIs 364ab020b60SAndrew Jeffery 365ab020b60SAndrew Jeffery- [ ] I've documented the wire format for all OEM messages under 366ab020b60SAndrew Jeffery `docs/oem/${OEM_NAME}/` 367ab020b60SAndrew Jeffery 368ab020b60SAndrew Jeffery- [ ] I've added public OEM API declarations and definitions under 369ab020b60SAndrew Jeffery `include/libpldm/oem/${OEM_NAME}/`, and installed them to the same 370ab020b60SAndrew Jeffery relative location. 371ab020b60SAndrew Jeffery 372ab020b60SAndrew Jeffery- [ ] I've implemented the public OEM APIs under `src/oem/${OEM_NAME}/` 373ab020b60SAndrew Jeffery 374ab020b60SAndrew Jeffery- [ ] I've implemented the OEM API tests under `tests/oem/${OEM_NAME}/` 375ab020b60SAndrew Jeffery 376ab020b60SAndrew JefferyThe `${OEM_NAME}` folder must be created with the name of the OEM/vendor in 377ab020b60SAndrew Jefferylower case. 378ab020b60SAndrew Jeffery 379ab020b60SAndrew JefferyFinally, the OEM name must be added to the list of choices for the `oem` meson 380ab020b60SAndrew Jefferyoption, and the `meson.build` files updated throughout the tree to guard 381ab020b60SAndrew Jefferyintegration of the OEM extensions. 382ab020b60SAndrew Jeffery 3832643f83cSAndrew Jeffery## Stabilising an existing API 3842643f83cSAndrew Jeffery 3852643f83cSAndrew Jeffery- [ ] The API of interest is currently marked `LIBPLDM_ABI_TESTING` 3862643f83cSAndrew Jeffery 3872643f83cSAndrew Jeffery- [ ] My commit message links to a publicly visible patch that makes use of the 3882643f83cSAndrew Jeffery API 3892643f83cSAndrew Jeffery 3902643f83cSAndrew Jeffery- [ ] My commit updates the annotation from `LIBPLDM_ABI_TESTING` to 3912643f83cSAndrew Jeffery `LIBPLDM_ABI_STABLE` only for the function symbols demonstrated by the 3922643f83cSAndrew Jeffery patch linked in the commit message. 3932643f83cSAndrew Jeffery 3942643f83cSAndrew Jeffery- [ ] I've removed guards from the function's tests so they are always compiled 3952643f83cSAndrew Jeffery 3962643f83cSAndrew Jeffery- [ ] If I've updated the ABI dump, then I've used the OpenBMC CI container to 3972643f83cSAndrew Jeffery do so. 3982643f83cSAndrew Jeffery 3992643f83cSAndrew Jeffery## Updating an ABI dump 4002643f83cSAndrew Jeffery 401687f14b8SAndrew JefferyTo update the ABI dump you'll need to build an appropriate OpenBMC CI container 402687f14b8SAndrew Jefferyimage of your own. Some hints on how to do this locally can be found [in the 403687f14b8SAndrew Jefferyopenbmc/docs repository][openbmc-docs-local-ci]. You can list your locally built 404687f14b8SAndrew Jefferyimages with `docker images`. 4052643f83cSAndrew Jeffery 406687f14b8SAndrew Jeffery[openbmc-docs-local-ci]: 407687f14b8SAndrew Jeffery https://github.com/openbmc/docs/blob/master/testing/local-ci-build.md 408687f14b8SAndrew Jeffery 409687f14b8SAndrew JefferyAssuming: 410687f14b8SAndrew Jeffery 411412fa270SPatrick Williams```shell 412687f14b8SAndrew Jefferyexport OPENBMC_CI_IMAGE=openbmc/ubuntu-unit-test:2024-W21-ce361f95ff4fa669 413687f14b8SAndrew Jeffery``` 414687f14b8SAndrew Jeffery 415687f14b8SAndrew Jefferythe ABI dump can be updated with: 416687f14b8SAndrew Jeffery 417412fa270SPatrick Williams```shell 418687f14b8SAndrew Jefferydocker run \ 419687f14b8SAndrew Jeffery --cap-add=sys_admin \ 420687f14b8SAndrew Jeffery --rm=true \ 421687f14b8SAndrew Jeffery --privileged=true \ 422687f14b8SAndrew Jeffery -u $USER \ 423687f14b8SAndrew Jeffery -w $(pwd) \ 424687f14b8SAndrew Jeffery -v $(pwd):$(pwd) \ 425687f14b8SAndrew Jeffery -e MAKEFLAGS= \ 426687f14b8SAndrew Jeffery -t $OPENBMC_CI_IMAGE \ 427687f14b8SAndrew Jeffery ./scripts/abi-dump-updater 428687f14b8SAndrew Jeffery``` 4292643f83cSAndrew Jeffery 4302643f83cSAndrew Jeffery## Removing an API 4312643f83cSAndrew Jeffery 4322643f83cSAndrew Jeffery- [ ] If the function is marked `LIBPLDM_ABI_TESTING`, then I have removed it 4332643f83cSAndrew Jeffery 4342643f83cSAndrew Jeffery- [ ] If the function is marked `LIBPLDM_ABI_STABLE`, then I have changed the 4352643f83cSAndrew Jeffery annotation to `LIBPLDM_ABI_DEPRECATED` and left it in-place. 4365befd128SAndrew Jeffery - [ ] I have updated the ABI dump, or will mark the change as WIP until it has 4375befd128SAndrew Jeffery been. 4385befd128SAndrew Jeffery 4392643f83cSAndrew Jeffery- [ ] If the function is marked `LIBPLDM_ABI_DEPRECATED`, then I have removed it 4402643f83cSAndrew Jeffery only after satisfying myself that each of the following is true: 4412643f83cSAndrew Jeffery - [ ] There are no known users of the function left in the community 4422643f83cSAndrew Jeffery - [ ] There has been at least one tagged release of `libpldm` subsequent to 4432643f83cSAndrew Jeffery the API being marked deprecated 4442643f83cSAndrew Jeffery 445d9b70ba7SAndrew Jeffery## Renaming an API 446d9b70ba7SAndrew Jeffery 447d9b70ba7SAndrew JefferyA change to an API is a pure rename only if there are no additional behavioural 448d9b70ba7SAndrew Jefferychanges. Renaming an API with no other behavioural changes is really two 449d9b70ba7SAndrew Jefferyactions: 450d9b70ba7SAndrew Jeffery 451d9b70ba7SAndrew Jeffery1. Introducing the new API name 452d9b70ba7SAndrew Jeffery2. Deprecating the old API name 453d9b70ba7SAndrew Jeffery 454d9b70ba7SAndrew Jeffery- [ ] Only the name of the function has changed. None of its behaviour has 455d9b70ba7SAndrew Jeffery changed. 456d9b70ba7SAndrew Jeffery 457d9b70ba7SAndrew Jeffery- [ ] Both the new and the old functions are declared in the public headers 458d9b70ba7SAndrew Jeffery 459d9b70ba7SAndrew Jeffery- [ ] I've aliased the old function name to the new function name via the 460d9b70ba7SAndrew Jeffery `libpldm_deprecated_aliases` list in `meson.build` 461d9b70ba7SAndrew Jeffery 462d9b70ba7SAndrew Jeffery- [ ] I've added a [semantic patch][coccinelle] to migrate users from the old 463d9b70ba7SAndrew Jeffery name to the new name 464d9b70ba7SAndrew Jeffery 465d9b70ba7SAndrew Jeffery[coccinelle]: https://coccinelle.gitlabpages.inria.fr/website/ 466d9b70ba7SAndrew Jeffery 4675befd128SAndrew Jeffery- [ ] I've updated the ABI dump to capture the rename, or will mark the change 4685befd128SAndrew Jeffery as WIP until it has been. 469b127b12fSAndrew Jeffery 470b127b12fSAndrew Jeffery## Fixing Implementation Defects 471b127b12fSAndrew Jeffery 472b127b12fSAndrew Jeffery- [ ] My change fixing the bug includes a [Fixes tag][linux-kernel-fixes-tag] 473b127b12fSAndrew Jeffery identifying the change introducing the defect. 474b127b12fSAndrew Jeffery 475b127b12fSAndrew Jeffery[linux-kernel-fixes-tag]: 476b127b12fSAndrew Jeffery https://docs.kernel.org/process/submitting-patches.html#describe-your-changes 477b127b12fSAndrew Jeffery 478b127b12fSAndrew Jeffery- [ ] My change fixing the bug includes test cases demonstrating that the bug is 479b127b12fSAndrew Jeffery fixed. 480