proc: Remove redundant size checks in proc_bus_pci_read/write()
PATCH 1/1 proc: Remove redundant size checks in proc_bus_pci_read/write()
Remove redundant "if (nbytes >= size)" checks in proc_bus_pci_read() and proc_bus_pci_write() functions. The subsequent "if (pos + nbytes
Quoted 1 line
size)" check already handles this condition by adjusting nbytes to
"size - pos", making the earlier check unnecessary.
This simplifies the logic without changing functionality since both checks serve the same purpose of preventing reads/writes beyond the available size.
Signed-off-by Kaushlendra Kumar <[email protected]>
--- drivers/pci/proc.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/pci/proc.c +0 -4
@@ -47,8 +47,6 @@ static ssize_t proc_bus_pci_read(struct file *file, char __user *buf,if (pos >= size)return 0 ; -if (nbytes >= size) - nbytes = size;if (pos + nbytes > size) nbytes = size - pos; cnt = nbytes;
@@ -123,8 +121,6 @@ static ssize_t proc_bus_pci_write(struct file *file, const char __user *buf,if (pos >= size)return 0 ; -if (nbytes >= size) - nbytes = size;if (pos + nbytes > size) nbytes = size - pos; cnt = nbytes;
Signature · 1 line
2.34.1