soc/intel/xeon_sp: Use "if (!ptr)" in preference to "if (ptr == NULL)"

Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Change-Id: I664f5b7d354b0d9a7144c25604ae4efbdd9ba9a9
Reviewed-on: https://review.coreboot.org/c/coreboot/+/67593
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Jonathan Zhang <jonzhang@fb.com>
diff --git a/src/soc/intel/xeon_sp/chip_common.c b/src/soc/intel/xeon_sp/chip_common.c
index 1c1715f..0cddec1 100644
--- a/src/soc/intel/xeon_sp/chip_common.c
+++ b/src/soc/intel/xeon_sp/chip_common.c
@@ -91,7 +91,7 @@
 
 	printk(BIOS_SPEW, "%s:%s scanning buses under device %s\n",
 		__FILE__, __func__, dev_path(dev));
-	while (link != NULL) {
+	while (link) {
 		if (link->secondary == 0)  { // scan only PSTACK buses
 			struct device *d;
 			for (d = link->children; d; d = d->sibling)
@@ -171,7 +171,7 @@
 {
 	struct stack_dev_resource *cur = *root;
 	while (cur) {
-		if (cur->align == res->align || cur->next == NULL) /* equal or last record */
+		if (cur->align == res->align || !cur->next) /* equal or last record */
 			break;
 		else if (cur->align > res->align) {
 			if (cur->next->align < res->align) /* need to insert new record here */
@@ -192,7 +192,7 @@
 		if (!cur) {
 			*root = nr; /* head node */
 		} else if (cur->align > nr->align) {
-			if (cur->next == NULL) {
+			if (!cur->next) {
 				cur->next = nr;
 			} else {
 				nr->next = cur->next;
@@ -206,20 +206,20 @@
 		nr = cur;
 	}
 
-	assert(nr != NULL && nr->align == res->align);
+	assert(nr && nr->align == res->align);
 
 	struct pci_resource *npr = malloc(sizeof(struct pci_resource));
-	if (npr == NULL)
+	if (!npr)
 		die("%s: out of memory.\n", __func__);
 	npr->res = res;
 	npr->dev = dev;
 	npr->next = NULL;
 
-	if (nr->children == NULL) {
+	if (!nr->children) {
 		nr->children = npr;
 	} else {
 		struct pci_resource *pr = nr->children;
-		while (pr->next != NULL)
+		while (pr->next)
 			pr = pr->next;
 		pr->next = npr;
 	}
@@ -343,7 +343,7 @@
 
 		/* get IIO stack for this bus */
 		stack = find_stack_for_bus(stack_list, bus->secondary);
-		assert(stack != NULL);
+		assert(stack);
 
 		/* Assign resources to bridge */
 		for (curdev = bus->children; curdev; curdev = curdev->sibling)
@@ -473,7 +473,7 @@
 	xeonsp_pci_domain_read_resources(dev);
 
 	struct bus *link = dev->link_list;
-	while (link != NULL) {
+	while (link) {
 		assign_resources(link);
 		link = link->next;
 	}
@@ -499,7 +499,7 @@
 			continue;
 
 		iiostack_bus = malloc(sizeof(struct bus));
-		if (iiostack_bus == NULL)
+		if (!iiostack_bus)
 			die("%s: out of memory.\n", __func__);
 		memset(iiostack_bus, 0, sizeof(*iiostack_bus));
 		memcpy(iiostack_bus, dev->bus, sizeof(*iiostack_bus));
@@ -518,11 +518,11 @@
 			printk(BIOS_WARNING, "IIO Stack device %s not visible\n",
 				dev_path(&dummy));
 
-		if (dev->link_list == NULL) {
+		if (!dev->link_list) {
 			dev->link_list = iiostack_bus;
 		} else {
 			struct bus *nlink = dev->link_list;
-			while (nlink->next != NULL)
+			while (nlink->next)
 				nlink = nlink->next;
 			nlink->next = iiostack_bus;
 		}
diff --git a/src/soc/intel/xeon_sp/cpx/romstage.c b/src/soc/intel/xeon_sp/cpx/romstage.c
index ad794c3..efdce78 100644
--- a/src/soc/intel/xeon_sp/cpx/romstage.c
+++ b/src/soc/intel/xeon_sp/cpx/romstage.c
@@ -48,9 +48,9 @@
 	memmap_addr = (const struct SystemMemoryMapHob **)
 		fsp_find_extension_hob_by_guid(mem_hob_guid, &hob_size);
 	/* hob_size is the size of the 8-byte address not the hob data */
-	assert(memmap_addr != NULL && hob_size != 0);
+	assert(memmap_addr && hob_size != 0);
 	/* assert the pointer to the hob is not NULL */
-	assert(*memmap_addr != NULL);
+	assert(*memmap_addr);
 
 	return *memmap_addr;
 }
@@ -85,14 +85,14 @@
 	uint32_t vdd_voltage;
 
 	hob = get_system_memory_map();
-	assert(hob != NULL);
+	assert(hob);
 
 	/*
 	 * Allocate CBMEM area for DIMM information used to populate SMBIOS
 	 * table 17
 	 */
 	mem_info = cbmem_add(CBMEM_ID_MEMINFO, sizeof(*mem_info));
-	if (mem_info == NULL) {
+	if (!mem_info) {
 		printk(BIOS_ERR, "CBMEM entry for DIMM info missing\n");
 		return;
 	}
diff --git a/src/soc/intel/xeon_sp/cpx/soc_util.c b/src/soc/intel/xeon_sp/cpx/soc_util.c
index ed23976..cd1e06d 100644
--- a/src/soc/intel/xeon_sp/cpx/soc_util.c
+++ b/src/soc/intel/xeon_sp/cpx/soc_util.c
@@ -18,9 +18,9 @@
 	memmap_addr = (const struct SystemMemoryMapHob **)
 		fsp_find_extension_hob_by_guid(mem_hob_guid, &hob_size);
 	/* hob_size is the size of the 8-byte address not the hob data */
-	assert(memmap_addr != NULL && hob_size != 0);
+	assert(memmap_addr && hob_size != 0);
 	/* assert the pointer to the hob is not NULL */
-	assert(*memmap_addr != NULL);
+	assert(*memmap_addr);
 
 	return *memmap_addr;
 }
diff --git a/src/soc/intel/xeon_sp/memmap.c b/src/soc/intel/xeon_sp/memmap.c
index b640c2d..c256484 100644
--- a/src/soc/intel/xeon_sp/memmap.c
+++ b/src/soc/intel/xeon_sp/memmap.c
@@ -59,7 +59,7 @@
 
 	dpr.raw = 0;
 
-	if (dev == NULL) {
+	if (!dev) {
 		printk(BIOS_ERR, "BUS 0: Unable to find VTD PCI dev");
 		return dpr;
 	}
@@ -76,7 +76,7 @@
 			uint8_t bus = ri->BusBase;
 			dev = VTD_DEV(bus);
 
-			if (dev == NULL) {
+			if (!dev) {
 				printk(BIOS_ERR, "BUS %x: Unable to find VTD PCI dev\n", bus);
 				dpr.raw = 0;
 				return  dpr;
diff --git a/src/soc/intel/xeon_sp/nb_acpi.c b/src/soc/intel/xeon_sp/nb_acpi.c
index 0519d44..b3e4575 100644
--- a/src/soc/intel/xeon_sp/nb_acpi.c
+++ b/src/soc/intel/xeon_sp/nb_acpi.c
@@ -46,7 +46,7 @@
 	unsigned int mmap_index;
 
 	memory_map = get_system_memory_map();
-	assert(memory_map != NULL);
+	assert(memory_map);
 	printk(BIOS_DEBUG, "memory_map: %p\n", memory_map);
 
 	mmap_index = 0;
@@ -332,7 +332,7 @@
 	ptr = cbmem_find(CBMEM_ID_STORAGE_DATA);
 	if (!ptr) {
 		ptr = cbmem_add(CBMEM_ID_STORAGE_DATA, size);
-		assert(ptr != NULL);
+		assert(ptr);
 		memset(ptr, 0, size);
 	}
 
diff --git a/src/soc/intel/xeon_sp/skx/chip.c b/src/soc/intel/xeon_sp/skx/chip.c
index 92f2afa..7850787 100644
--- a/src/soc/intel/xeon_sp/skx/chip.c
+++ b/src/soc/intel/xeon_sp/skx/chip.c
@@ -78,7 +78,7 @@
 
 	microcode_file = cbfs_map("cpu_microcode_blob.bin", &microcode_len);
 
-	if ((microcode_file != NULL) && (microcode_len != 0)) {
+	if ((microcode_file) && (microcode_len != 0)) {
 		/* Update CPU Microcode patch base address/size */
 		silupd->FspsConfig.PcdCpuMicrocodePatchBase =
 		       (uint32_t)microcode_file;
diff --git a/src/soc/intel/xeon_sp/skx/cpu.c b/src/soc/intel/xeon_sp/skx/cpu.c
index 027e9bb..d2e4af1 100644
--- a/src/soc/intel/xeon_sp/skx/cpu.c
+++ b/src/soc/intel/xeon_sp/skx/cpu.c
@@ -61,7 +61,7 @@
 
 	printk(BIOS_INFO, "%s dev: %s, cpu: %d, apic_id: 0x%x\n",
 		__func__, dev_path(cpu), cpu_index(), cpu->path.apic.apic_id);
-	assert(chip_config != NULL);
+	assert(chip_config);
 
 	/* set MSR_PKG_CST_CONFIG_CONTROL - scope per core*/
 	msr.hi = 0;
diff --git a/src/soc/intel/xeon_sp/skx/hob_display.c b/src/soc/intel/xeon_sp/skx/hob_display.c
index 4f9636d..efe1038 100644
--- a/src/soc/intel/xeon_sp/skx/hob_display.c
+++ b/src/soc/intel/xeon_sp/skx/hob_display.c
@@ -37,7 +37,7 @@
 	const struct hob_resource *res;
 
 	res = fsp_hob_header_to_resource(hob);
-	assert(res != NULL);
+	assert(res);
 	printk(BIOS_DEBUG, "\tResource type: 0x%x, attribute: 0x%x, addr: 0x%08llx, len: 0x%08llx\n",
 		res->type, res->attribute_type, res->addr, res->length);
 	printk(BIOS_DEBUG, "\tOwner GUID: ");
@@ -57,7 +57,7 @@
 	size_t hob_size = 0;
 	const struct SystemMemoryMapHob *hob =
 		fsp_find_extension_hob_by_guid(fsp_hob_memmap_guid, &hob_size);
-	assert(hob != NULL && hob_size != 0);
+	assert(hob && hob_size != 0);
 
 	printk(BIOS_DEBUG, "===================== MEMORY MAP HOB DATA =====================\n");
 	printk(BIOS_DEBUG, "hob: %p, hob_size: 0x%zx, SystemMemoryMapHob size: 0x%zx, "
@@ -90,7 +90,7 @@
 	size_t hob_size = 0;
 	const IIO_UDS *hob = fsp_find_extension_hob_by_guid(fsp_hob_iio_uds_guid, &hob_size);
 
-	assert(hob != NULL && hob_size != 0);
+	assert(hob && hob_size != 0);
 
 	printk(BIOS_DEBUG, "===================== IIO_UDS HOB DATA =====================\n");
 
diff --git a/src/soc/intel/xeon_sp/skx/soc_util.c b/src/soc/intel/xeon_sp/skx/soc_util.c
index cc8db64..3258007 100644
--- a/src/soc/intel/xeon_sp/skx/soc_util.c
+++ b/src/soc/intel/xeon_sp/skx/soc_util.c
@@ -50,7 +50,7 @@
 	const struct SystemMemoryMapHob *memmap_addr;
 
 	memmap_addr = fsp_find_extension_hob_by_guid(mem_hob_guid, &hob_size);
-	assert(memmap_addr != NULL && hob_size != 0);
+	assert(memmap_addr && hob_size != 0);
 
 	return memmap_addr;
 }
diff --git a/src/soc/intel/xeon_sp/util.c b/src/soc/intel/xeon_sp/util.c
index 4295704..818dd78 100644
--- a/src/soc/intel/xeon_sp/util.c
+++ b/src/soc/intel/xeon_sp/util.c
@@ -92,11 +92,11 @@
 	static const IIO_UDS *hob;
 	const uint8_t fsp_hob_iio_universal_data_guid[16] = FSP_HOB_IIO_UNIVERSAL_DATA_GUID;
 
-	if (hob != NULL)
+	if (hob)
 		return hob;
 
 	hob = fsp_find_extension_hob_by_guid(fsp_hob_iio_universal_data_guid, &hob_size);
-	assert(hob != NULL && hob_size != 0);
+	assert(hob && hob_size != 0);
 	return hob;
 }
 
@@ -150,11 +150,11 @@
 static void get_cpu_info_from_apicid(uint32_t apicid, uint32_t core_bits, uint32_t thread_bits,
 	uint8_t *package, uint8_t *core, uint8_t *thread)
 {
-	if (package != NULL)
+	if (package)
 		*package = (apicid >> (thread_bits + core_bits));
-	if (core != NULL)
+	if (core)
 		*core = (uint32_t)((apicid >> thread_bits) & ~((~0) << core_bits));
-	if (thread != NULL)
+	if (thread)
 		*thread = (uint32_t)(apicid & ~((~0) << thread_bits));
 }