pdr: Further constrain first and last pointer semantics

The property that we're trying to uphold across pldm_pdr's first and
last members is that they are either both NULL, or both point to valid
records that are reachable from each other.

Properly specify this property by hoisting the assert out of the
if-condition body and adjusting it to cover the behaviour of both
branches. Hoisting the assertion resolves the following issue identified
by clang-tidy:

```
../src/pdr.c:83:20: error: Access to field 'next' results in a dereference of a null pointer (loaded from field 'last') [clang-analyzer-core.NullDereference,-warnings-as-errors]
                repo->last->next = record;
                                 ^
../src/pdr.c:285:9: note: Calling 'pldm_pdr_add'
        return pldm_pdr_add(repo, data, size, bmc_record_handle, false,
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/pdr.c:42:9: note: Assuming 'repo' is not equal to null
        assert(repo != NULL);
               ^
/usr/include/assert.h:95:7: note: expanded from macro 'assert'
    ((expr)                                                             \
      ^~~~
../src/pdr.c:42:2: note: '?' condition is true
        assert(repo != NULL);
        ^
/usr/include/assert.h:95:6: note: expanded from macro 'assert'
    ((expr)                                                             \
     ^
../src/pdr.c:43:9: note: 'data' is not equal to null
        assert(data != NULL);
               ^
/usr/include/assert.h:95:7: note: expanded from macro 'assert'
    ((expr)                                                             \
      ^~~~
../src/pdr.c:43:2: note: '?' condition is true
        assert(data != NULL);
        ^
/usr/include/assert.h:95:6: note: expanded from macro 'assert'
    ((expr)                                                             \
     ^
../src/pdr.c:44:9: note: 'size' is not equal to 0
        assert(size != 0);
               ^
/usr/include/assert.h:95:7: note: expanded from macro 'assert'
    ((expr)                                                             \
      ^~~~
../src/pdr.c:44:2: note: '?' condition is true
        assert(size != 0);
        ^
/usr/include/assert.h:95:6: note: expanded from macro 'assert'
    ((expr)                                                             \
     ^
../src/pdr.c:47:9: note: Assuming 'record' is not equal to null
        assert(record != NULL);
               ^
/usr/include/assert.h:95:7: note: expanded from macro 'assert'
    ((expr)                                                             \
      ^~~~
../src/pdr.c:47:2: note: '?' condition is true
        assert(record != NULL);
        ^
/usr/include/assert.h:95:6: note: expanded from macro 'assert'
    ((expr)                                                             \
     ^
../src/pdr.c:49:6: note: Assuming 'record_handle' is 0
        if (record_handle) {
            ^~~~~~~~~~~~~
../src/pdr.c:49:2: note: Taking false branch
        if (record_handle) {
        ^
../src/pdr.c:52:19: note: Assuming field 'last' is null
                uint32_t curr = repo->last ? repo->last->record_handle : 0;
                                ^~~~~~~~~~
../src/pdr.c:52:19: note: Assuming pointer value is null
                uint32_t curr = repo->last ? repo->last->record_handle : 0;
                                ^~~~~~~~~~
../src/pdr.c:52:19: note: '?' condition is false
../src/pdr.c:53:10: note: 'curr' is not equal to -1
                assert(curr != UINT32_MAX);
                       ^
/usr/include/assert.h:95:7: note: expanded from macro 'assert'
    ((expr)                                                             \
      ^~~~
../src/pdr.c:53:3: note: '?' condition is true
                assert(curr != UINT32_MAX);
                ^
/usr/include/assert.h:95:6: note: expanded from macro 'assert'
    ((expr)                                                             \
     ^
../src/pdr.c:60:6: note: 'data' is not equal to NULL
        if (data != NULL) {
            ^~~~
../src/pdr.c:60:2: note: Taking true branch
        if (data != NULL) {
        ^
../src/pdr.c:62:10: note: Assuming field 'data' is not equal to null
                assert(record->data != NULL);
                       ^
/usr/include/assert.h:95:7: note: expanded from macro 'assert'
    ((expr)                                                             \
      ^~~~
../src/pdr.c:62:3: note: '?' condition is true
                assert(record->data != NULL);
                ^
/usr/include/assert.h:95:6: note: expanded from macro 'assert'
    ((expr)                                                             \
     ^
../src/pdr.c:70:8: note: 'record_handle' is 0
                if (!record_handle) {
                     ^~~~~~~~~~~~~
../src/pdr.c:70:3: note: Taking true branch
                if (!record_handle) {
                ^
../src/pdr.c:78:6: note: Assuming field 'first' is not equal to NULL
        if (repo->first == NULL) {
            ^~~~~~~~~~~~~~~~~~~
../src/pdr.c:78:2: note: Taking false branch
        if (repo->first == NULL) {
        ^
../src/pdr.c:83:20: note: Access to field 'next' results in a dereference of a null pointer (loaded from field 'last')
                repo->last->next = record;
                      ~~~~       ^
```

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: Ia54a3796ffa83804c23f913caed7d0943d1e7ad1
diff --git a/src/pdr.c b/src/pdr.c
index 6fb5518..cd7857a 100644
--- a/src/pdr.c
+++ b/src/pdr.c
@@ -79,8 +79,8 @@
 	}
 	record->next = NULL;
 
+	assert(!repo->first == !repo->last);
 	if (repo->first == NULL) {
-		assert(repo->last == NULL);
 		repo->first = record;
 		repo->last = record;
 	} else {