Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Reduce on level of indentation and add curly brackets around the while
Baptiste Daroussin committed 9 years ago
commit 8e194911b14ce22d597036493c365d821bee0737
parent 1488a13
1 file changed +17 -15
modified libpkg/packing.c
@@ -214,27 +214,29 @@ packing_append_file_attr(struct packing *pack, const char *filepath,

	archive_write_header(pack->awrite, entry);

-
	if (archive_entry_size(entry) > 0) {
-
		if ((fd = open(filepath, O_RDONLY)) < 0) {
-
			pkg_emit_errno("open", filepath);
-
			retcode = EPKG_FATAL;
-
			goto cleanup;
-
		}
+
	if (archive_entry_size(entry) <= 0)
+
		goto cleanup;

-
		while ((len = read(fd, buf, sizeof(buf))) > 0)
-
			if (archive_write_data(pack->awrite, buf, len) == -1) {
-
				pkg_emit_errno("archive_write_data", "archive write error");
-
				retcode = EPKG_FATAL;
-
				break;
-
			}
+
	if ((fd = open(filepath, O_RDONLY)) < 0) {
+
		pkg_emit_errno("open", filepath);
+
		retcode = EPKG_FATAL;
+
		goto cleanup;
+
	}

-
		if (len == -1) {
-
			pkg_emit_errno("read", "file read error");
+
	while ((len = read(fd, buf, sizeof(buf))) > 0) {
+
		if (archive_write_data(pack->awrite, buf, len) == -1) {
+
			pkg_emit_errno("archive_write_data", "archive write error");
			retcode = EPKG_FATAL;
+
			break;
		}
-
		close(fd);
	}

+
	if (len == -1) {
+
		pkg_emit_errno("read", "file read error");
+
		retcode = EPKG_FATAL;
+
	}
+
	close(fd);
+

cleanup:
	archive_entry_free(entry);
	return (retcode);