pdr: Allow record_handle to be NULL for pldm_pdr_add_check()

This makes it slightly more ergonomic when we don't care for the handle
value of the new record.

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: Ic6d212031916d9f065769e4126838ff04bcf1ddc
diff --git a/src/pdr.c b/src/pdr.c
index 4b34196..56c07b5 100644
--- a/src/pdr.c
+++ b/src/pdr.c
@@ -56,11 +56,11 @@
 {
 	uint32_t curr;
 
-	if (!repo || !data || !size || !record_handle) {
+	if (!repo || !data || !size) {
 		return -EINVAL;
 	}
 
-	if (*record_handle) {
+	if (record_handle && *record_handle) {
 		curr = *record_handle;
 	} else if (repo->last) {
 		curr = repo->last->record_handle;
@@ -91,7 +91,7 @@
 	record->terminus_handle = terminus_handle;
 	record->record_handle = curr;
 
-	if (!*record_handle && data) {
+	if (record_handle && !*record_handle && data) {
 		/* If record handle is 0, that is an indication for this API to
 		 * compute a new handle. For that reason, the computed handle
 		 * needs to be populated in the PDR header. For a case where the
@@ -116,7 +116,9 @@
 	repo->size += record->size;
 	++repo->record_count;
 
-	*record_handle = record->record_handle;
+	if (record_handle) {
+		*record_handle = record->record_handle;
+	}
 
 	return 0;
 }