Skip to contentSkip to conversation

staging: sm750fb: Remove redundant NULL and zero assignments in probe

PATCH In review Temitope obabi 2 participants 2 messages Oct 19 – Nov 20

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 staging: sm750fb: Remove redundant NULL and zero assignments in probe

The sm750_dev structure is allocated with devm_kzalloc() just above, so its memory is already zeroed. Remove the explicit NULL assignments to fbinfo[0] and fbinfo[1] and the zero assignment to mtrr.vram, which only set fields that are already zero.

---
Changes in v2:
- Remove an accidental duplicate of the note at the end of the patch. No code changes.

Note: Greg replied to my earlier sm750fb patch that keeping the explicit zero assignments is good because it is clear what is happening. In that patch the allocation was in a different function. Here the assignments are in lynxfb_pci_probe(), just after the devm_kzalloc() call and its NULL check, so I think removing them may still be useful.

 drivers/staging/sm750fb/sm750.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/staging/sm750fb/sm750.c +0 -3
index 8b93bfeb217b..8702f6313f78 100644
@@ -969,13 +969,10 @@ static int lynxfb_pci_probe(struct pci_dev *pdev,
 	if (!sm750_dev)
 		return err;
 
-	sm750_dev->fbinfo[0] = NULL;
-	sm750_dev->fbinfo[1] = NULL;
 	sm750_dev->devid = pdev->device;
 	sm750_dev->revid = pdev->revision;
 	sm750_dev->pdev = pdev;
 	sm750_dev->mtrr_off = g_nomtrr;
-	sm750_dev->mtrr.vram = 0;
 	sm750_dev->accel_off = g_noaccel;
 	spin_lock_init(&sm750_dev->slock);
 
Signature · 1 line
2.53.0
maintainer
#1 lore raw
Quoted 12 lines · Temitope obabi

The sm750_dev structure is allocated with devm_kzalloc() just above, so its memory is already zeroed. Remove the explicit NULL assignments to fbinfo[0] and fbinfo[1] and the zero assignment to mtrr.vram, which only set fields that are already zero.

---
Changes in v2:
- Remove an accidental duplicate of the note at the end of the patch. No code changes.

Quoted 6 lines

Note: Greg replied to my earlier sm750fb patch that keeping the explicit zero assignments is good because it is clear what is happening. In that patch the allocation was in a different function. Here the assignments are in lynxfb_pci_probe(), just after the devm_kzalloc() call and its NULL check, so I think removing them may still be useful.

Let's leave them as-is, it's nice to be explicit at times.

thanks,

greg k-h