Merge "sysupgrade-helper : Fix warnings during compilation"

This commit is contained in:
Linux Build Service Account 2023-09-27 18:09:26 -07:00 committed by Gerrit - the friendly Code Review server
commit ad66d83448
2 changed files with 12 additions and 6 deletions

View file

@ -794,7 +794,7 @@ int get_ubi_volume_id(char *vol_name)
fgets(ubi_vol_name, sizeof(ubi_vol_name), fp); fgets(ubi_vol_name, sizeof(ubi_vol_name), fp);
if (strstr(ubi_vol_name, vol_name)) { if (strstr(ubi_vol_name, vol_name)) {
printf("%s volume id = %d\n", vol_name, i); printf("%s volume id = %d\n", vol_name, i);
close(fp); fclose(fp);
return i; return i;
} }
} }
@ -811,10 +811,11 @@ int get_ubi_volume_id(char *vol_name)
* to get the ELF header of rootfs metadata. * to get the ELF header of rootfs metadata.
*/ */
void extract_binary(struct image_section *section) int extract_binary(struct image_section *section)
{ {
extract_kernel_binary(section, "kernel"); extract_kernel_binary(section, "kernel");
parse_elf_image_phdr(section); parse_elf_image_phdr(section);
return 1;
} }
/** /**
@ -1013,7 +1014,7 @@ int extract_rootfs_binary(char *filename)
fp = mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, ifd, 0); fp = mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, ifd, 0);
if (fp == MAP_FAILED) { if (fp == MAP_FAILED) {
perror("mmap"); perror("mmap");
close(fp); close(ifd);
return 0; return 0;
} }
@ -1049,13 +1050,16 @@ int compute_sha_hash(struct image_section *section)
int retval; int retval;
#ifdef USE_SHA384 #ifdef USE_SHA384
snprintf(command, sizeof(command), retval = snprintf(command, sizeof(command),
"openssl dgst -sha384 -binary -out %s %s", sha_hash, section->tmp_file); "openssl dgst -sha384 -binary -out %s %s", sha_hash, section->tmp_file);
#endif #endif
#ifdef USE_SHA256 #ifdef USE_SHA256
snprintf(command, sizeof(command), retval = snprintf(command, sizeof(command),
"openssl dgst -sha256 -binary -out %s %s", sha_hash, section->tmp_file); "openssl dgst -sha256 -binary -out %s %s", sha_hash, section->tmp_file);
#endif #endif
if (retval < 0) {
return retval;
}
retval = system(command); retval = system(command);
if (retval != 0) { if (retval != 0) {
printf("Error generating sha-hash, command : %s\n",command); printf("Error generating sha-hash, command : %s\n",command);

View file

@ -113,8 +113,10 @@ int is_version_check_enabled(void);
int get_sw_id_from_component_bin(struct image_section *); int get_sw_id_from_component_bin(struct image_section *);
int get_sw_id_from_component_bin_elf(struct image_section *); int get_sw_id_from_component_bin_elf(struct image_section *);
int get_sw_id_from_component_bin_elf64(struct image_section *); int get_sw_id_from_component_bin_elf64(struct image_section *);
void extract_binary(struct image_section *); int extract_binary(struct image_section *);
int extract_kernel_binary(struct image_section *, char *); int extract_kernel_binary(struct image_section *, char *);
int extract_ubi_volume(char *, char *, char *);
int extract_rootfs_binary(char *);
int is_image_version_higher(void); int is_image_version_higher(void);
int update_version(void); int update_version(void);
int check_image_version(void); int check_image_version(void);