diff mbox series

[28/47] libsemanage: simplify loop exit

Message ID 20241111141706.38039-28-cgoettsche@seltendoof.de (mailing list archive)
State New
Delegated to: Petr Lautrbach
Headers show
Series [01/47] libsemanage: white space cleanup | expand

Commit Message

Christian Göttsche Nov. 11, 2024, 2:16 p.m. UTC
From: Christian Göttsche <cgzones@googlemail.com>

Simplify the loop condition and make the loop exit more explicit to
avoid static analyzers reporting a potential uninitialized variable.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 libsemanage/src/semanage_store.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libsemanage/src/semanage_store.c b/libsemanage/src/semanage_store.c
index cb5bc149..c84ca43b 100644
--- a/libsemanage/src/semanage_store.c
+++ b/libsemanage/src/semanage_store.c
@@ -738,13 +738,14 @@  int semanage_copy_file(const char *src, const char *dst, mode_t mode,
 		goto out;
 	}
 	umask(mask);
-	while (retval == 0 && (amount_read = read(in, buf, sizeof(buf))) > 0) {
+	while ((amount_read = read(in, buf, sizeof(buf))) > 0) {
 		if (write_full(out, buf, amount_read) == -1) {
 			if (errno)
 				errsv = errno;
 			else
 				errsv = EIO;
 			retval = -1;
+			break;
 		}
 	}
 	if (amount_read < 0) {