diff mbox series

Type encrypted flag as bool

Message ID 20201215151417.781452-1-sbabic@denx.de
State Accepted
Headers show
Series Type encrypted flag as bool | expand

Commit Message

Stefano Babic Dec. 15, 2020, 3:14 p.m. UTC
Calling copyfile the parameter "encrypted" is used as bool and not as
int. Replace type in function and where it is called.

Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 core/cpio_utils.c           | 6 +++---
 core/stream_interface.c     | 6 +++---
 handlers/raw_handler.c      | 2 +-
 handlers/readback_handler.c | 2 +-
 include/swupdate.h          | 2 +-
 include/util.h              | 2 +-
 parser/parse_external.c     | 2 +-
 7 files changed, 11 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/core/cpio_utils.c b/core/cpio_utils.c
index 8520a0e..84e9c83 100644
--- a/core/cpio_utils.c
+++ b/core/cpio_utils.c
@@ -381,7 +381,7 @@  static int zstd_step(void* state, void* buffer, size_t size)
 
 int copyfile(int fdin, void *out, unsigned int nbytes, unsigned long *offs, unsigned long long seek,
 	int skip_file, int __attribute__ ((__unused__)) compressed,
-	uint32_t *checksum, unsigned char *hash, int encrypted, const char *imgivt, writeimage callback)
+	uint32_t *checksum, unsigned char *hash, bool encrypted, const char *imgivt, writeimage callback)
 {
 	unsigned int percent, prevpercent = 0;
 	int ret = 0;
@@ -713,7 +713,7 @@  int extract_sw_description(int fd, const char *descfile, off_t *offs, bool encry
 		close(fdout);
 		return -1;
 	}
-	if (copyfile(fd, &fdout, fdh.size, &offset, 0, 0, 0, &checksum, NULL, encrypted ? 1 : 0, NULL, NULL) < 0) {
+	if (copyfile(fd, &fdout, fdh.size, &offset, 0, 0, 0, &checksum, NULL, encrypted, NULL, NULL) < 0) {
 		ERROR("%s corrupted or not valid", descfile);
 		close(fdout);
 		return -1;
@@ -839,7 +839,7 @@  int cpio_scan(int fd, struct swupdate_cfg *cfg, off_t start)
 		 * we do not have to provide fdout
 		 */
 		if (copyfile(fd, NULL, fdh.size, &offset, 0, 1, 0, &checksum, img ? img->sha256 : NULL,
-				0, NULL, NULL) != 0) {
+				false, NULL, NULL) != 0) {
 			ERROR("invalid archive");
 			return -1;
 		}
diff --git a/core/stream_interface.c b/core/stream_interface.c
index d0586ea..6d32998 100644
--- a/core/stream_interface.c
+++ b/core/stream_interface.c
@@ -103,7 +103,7 @@  static int extract_file_to_tmp(int fd, const char *fname, unsigned long *poffs,
 		return -1;
 
 	if (copyfile(fd, &fdout, fdh.size, poffs, 0, 0, 0, &checksum, NULL,
-		     encrypted ? 1 : 0, NULL, NULL) < 0) {
+		     encrypted, NULL, NULL) < 0) {
 		close(fdout);
 		return -1;
 	}
@@ -221,7 +221,7 @@  static int extract_files(int fd, struct swupdate_cfg *software)
 				fdout = openfileoutput(img->extract_file);
 				if (fdout < 0)
 					return -1;
-				if (copyfile(fd, &fdout, fdh.size, &offset, 0, 0, 0, &checksum, img->sha256, 0, NULL, NULL) < 0) {
+				if (copyfile(fd, &fdout, fdh.size, &offset, 0, 0, 0, &checksum, img->sha256, false, NULL, NULL) < 0) {
 					close(fdout);
 					return -1;
 				}
@@ -233,7 +233,7 @@  static int extract_files(int fd, struct swupdate_cfg *software)
 				break;
 
 			case SKIP_FILE:
-				if (copyfile(fd, &fdout, fdh.size, &offset, 0, skip, 0, &checksum, NULL, 0, NULL, NULL) < 0) {
+				if (copyfile(fd, &fdout, fdh.size, &offset, 0, skip, 0, &checksum, NULL, false, NULL, NULL) < 0) {
 					return -1;
 				}
 				if (!swupdate_verify_chksum(checksum, fdh.chksum)) {
diff --git a/handlers/raw_handler.c b/handlers/raw_handler.c
index ab210c0..489919d 100644
--- a/handlers/raw_handler.c
+++ b/handlers/raw_handler.c
@@ -181,7 +181,7 @@  static int copy_raw_image(struct img_type *img,
 			0, /* no compressed */
 			&checksum,
 			0, /* no sha256 */
-			0, /* no encrypted */
+			false, /* no encrypted */
 			NULL, /* no IVT */
 			NULL);
 
diff --git a/handlers/readback_handler.c b/handlers/readback_handler.c
index d67d0f4..9dc99fc 100644
--- a/handlers/readback_handler.c
+++ b/handlers/readback_handler.c
@@ -106,7 +106,7 @@  static int readback_postinst(struct img_type *img)
 			0,     /* no compressed */
 			NULL,  /* no checksum */
 			hash,
-			0,     /* no encrypted */
+			false,     /* no encrypted */
 			NULL,     /* no IVT */
 			NULL); /* no callback */
 	if (status == 0) {
diff --git a/include/swupdate.h b/include/swupdate.h
index 720868c..a687927 100644
--- a/include/swupdate.h
+++ b/include/swupdate.h
@@ -81,7 +81,7 @@  struct img_type {
 	int provided;
 	int compressed;
 	int preserve_attributes; /* whether to preserve attributes in archives */
-	int is_encrypted;
+	bool is_encrypted;
 	char ivt_ascii[33];
 	int install_directly;
 	int is_script;
diff --git a/include/util.h b/include/util.h
index 97cdad0..a0edd3e 100644
--- a/include/util.h
+++ b/include/util.h
@@ -189,7 +189,7 @@  strlcpy(char *dst, const char * src, size_t size);
 int copyfile(int fdin, void *out, unsigned int nbytes, unsigned long *offs,
 	unsigned long long seek,
 	int skip_file, int compressed, uint32_t *checksum,
-	unsigned char *hash, int encrypted, const char *imgivt, writeimage callback);
+	unsigned char *hash, bool encrypted, const char *imgivt, writeimage callback);
 int copyimage(void *out, struct img_type *img, writeimage callback);
 int extract_sw_description(int fd, const char *descfile, off_t *offs, bool encrypted);
 off_t extract_next_file(int fd, int fdout, off_t start, int compressed,
diff --git a/parser/parse_external.c b/parser/parse_external.c
index baa0595..802a76c 100644
--- a/parser/parse_external.c
+++ b/parser/parse_external.c
@@ -82,7 +82,7 @@  static void sw_append_stream(struct img_type *img, const char *key,
 	if (!strcmp(key, "sha256"))
 		ascii_to_hash(img->sha256, value);
 	if (!strcmp(key, "encrypted"))
-		img->is_encrypted = 1;
+		img->is_encrypted = true;
 	if (!strcmp(key, "compressed")) {
 		if (value != NULL) {
 			if (!strcmp(value, "zlib")) {