@@ -29,12 +29,11 @@
#define NPAD_BYTES(o) ((4 - (o % 4)) % 4)
-int get_cpiohdr(unsigned char *buf, unsigned long *size,
- unsigned long *namesize, unsigned long *chksum)
+int get_cpiohdr(unsigned char *buf, struct filehdr *fhdr)
{
struct new_ascii_header *cpiohdr;
- if (!buf)
+ if (!buf || !fhdr)
return -EINVAL;
cpiohdr = (struct new_ascii_header *)buf;
@@ -45,9 +44,9 @@ int get_cpiohdr(unsigned char *buf, unsigned long *size,
ERROR("CPIO Format not recognized: magic not found");
return -EINVAL;
}
- *size = FROM_HEX(cpiohdr->c_filesize);
- *namesize = FROM_HEX(cpiohdr->c_namesize);
- *chksum = FROM_HEX(cpiohdr->c_chksum);
+ fhdr->size = FROM_HEX(cpiohdr->c_filesize);
+ fhdr->namesize = FROM_HEX(cpiohdr->c_namesize);
+ fhdr->chksum = FROM_HEX(cpiohdr->c_chksum);
return 0;
}
@@ -654,7 +653,7 @@ int extract_cpio_header(int fd, struct filehdr *fhdr, unsigned long *offset)
unsigned char buf[sizeof(fhdr->filename)];
if (fill_buffer(fd, buf, sizeof(struct new_ascii_header), offset, NULL, NULL) < 0)
return -EINVAL;
- if (get_cpiohdr(buf, &fhdr->size, &fhdr->namesize, &fhdr->chksum) < 0) {
+ if (get_cpiohdr(buf, fhdr) < 0) {
ERROR("CPIO Header corrupted, cannot be parsed");
return -EINVAL;
}
@@ -401,7 +401,7 @@ static int save_stream(int fdin, struct swupdate_cfg *software)
ret = -EFAULT;
goto no_copy_output;
}
- if (get_cpiohdr(buf, &fdh.size, &fdh.namesize, &fdh.chksum) < 0) {
+ if (get_cpiohdr(buf, &fdh) < 0) {
ERROR("CPIO Header corrupted, cannot be parsed");
ret = -EINVAL;
goto no_copy_output;
@@ -49,8 +49,7 @@ struct filehdr {
char filename[MAX_IMAGE_FNAME];
};
-int get_cpiohdr(unsigned char *buf, unsigned long *size,
- unsigned long *namesize, unsigned long *chksum);
+int get_cpiohdr(unsigned char *buf, struct filehdr *fhdr);
int extract_cpio_header(int fd, struct filehdr *fhdr, unsigned long *offset);
int extract_img_from_cpio(int fd, unsigned long offset, struct filehdr *fdh);
void extract_padding(int fd, unsigned long *offset);
Pass the pointer to the structure instead of the single fields. Signed-off-by: Stefano Babic <sbabic@denx.de> --- core/cpio_utils.c | 13 ++++++------- core/stream_interface.c | 2 +- include/cpiohdr.h | 3 +-- 3 files changed, 8 insertions(+), 10 deletions(-)