firmware-utils: fix unused variable warnings

This fixes warnings from the:
1. -Wunused-variable
2. -Wunused-but-set-variable

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
This commit is contained in:
Rafał Miłecki 2021-04-09 07:38:46 +02:00
parent e65b633a5b
commit 7c01e2bac1
20 changed files with 18 additions and 60 deletions

View File

@ -98,7 +98,6 @@ uint16_t get_hcs ( ldr_header_t* hd )
uint8_t hcs_minor; uint8_t hcs_minor;
uint8_t hcs_major; uint8_t hcs_major;
uint16_t n = 0xffff; uint16_t n = 0xffff;
uint16_t m = 0;
int state = 0; int state = 0;
int i,j; int i,j;
for ( i = 0; i < 0x54; i++ ) for ( i = 0; i < 0x54; i++ )
@ -226,7 +225,7 @@ int dump_header ( ldr_header_t* hd )
printf ( "HNW:\t\t0x%04X\n",reverse_endian16 ( hd->her_znaet_chto ) ); //Hell knows what printf ( "HNW:\t\t0x%04X\n",reverse_endian16 ( hd->her_znaet_chto ) ); //Hell knows what
printf ( "CRC:\t\t0x%08X\n",reverse_endian32 ( hd->crc ) ); printf ( "CRC:\t\t0x%08X\n",reverse_endian32 ( hd->crc ) );
printf ( "=== Binary Header Dump===\n" ); printf ( "=== Binary Header Dump===\n" );
int i,j; int i;
uint8_t* head = ( uint8_t* ) hd; uint8_t* head = ( uint8_t* ) hd;
for ( i=0;i<=sizeof ( ldr_header_t );i++ ) for ( i=0;i<=sizeof ( ldr_header_t );i++ )
{ {

View File

@ -126,16 +126,13 @@ int main(int argc, char **argv)
int fdout; int fdout;
struct stat sb; struct stat sb;
uint32_t filesize; uint32_t filesize;
uint32_t padding;
int ret = 0; int ret = 0;
const char *pathin; const char *pathin;
const char *pathout; const char *pathout;
unsigned char *buffer; unsigned char *buffer;
unsigned char *infop;
uint32_t sum; uint32_t sum;
size_t bufsize; size_t bufsize;
size_t bytes; size_t bytes;
int i;
if (argc < 3) { if (argc < 3) {
printf("Too few arguments.\n"); printf("Too few arguments.\n");
@ -150,7 +147,6 @@ int main(int argc, char **argv)
return ret; return ret;
filesize = sb.st_size; filesize = sb.st_size;
padding = filesize % 4;
printf("INFILE: %s, size: %08x bytes\n", pathin, filesize); printf("INFILE: %s, size: %08x bytes\n", pathin, filesize);
/* File + extended header size */ /* File + extended header size */
bufsize = filesize + HEADER_SIZE; bufsize = filesize + HEADER_SIZE;
@ -180,9 +176,6 @@ int main(int argc, char **argv)
} }
close(fdin); close(fdin);
/* PREP HEADER AND FOOTER */
infop = buffer;
be_wr(buffer + OFFSET_MAGIC, IH_MAGIC); be_wr(buffer + OFFSET_MAGIC, IH_MAGIC);
/* FIXME: use actual time */ /* FIXME: use actual time */

View File

@ -82,8 +82,8 @@ int tagfile(const char *kernel, const char *rootfs, const char *bin, \
struct bcm_tag tag; struct bcm_tag tag;
struct kernelhdr khdr; struct kernelhdr khdr;
FILE *kernelfile = NULL, *rootfsfile = NULL, *binfile = NULL, *cfefile = NULL; FILE *kernelfile = NULL, *rootfsfile = NULL, *binfile = NULL, *cfefile = NULL;
size_t cfeoff, cfelen, kerneloff, kernellen, rootfsoff, rootfslen, \ size_t cfelen, kerneloff, kernellen, rootfsoff, rootfslen, \
read, imagelen, rootfsoffpadlen = 0, kernelfslen, kerneloffpadlen = 0, oldrootfslen, \ read, imagelen, rootfsoffpadlen = 0, oldrootfslen, \
rootfsend; rootfsend;
uint8_t readbuf[1024]; uint8_t readbuf[1024];
uint32_t imagecrc = IMAGETAG_CRC_START; uint32_t imagecrc = IMAGETAG_CRC_START;
@ -91,7 +91,6 @@ int tagfile(const char *kernel, const char *rootfs, const char *bin, \
uint32_t rootfscrc = IMAGETAG_CRC_START; uint32_t rootfscrc = IMAGETAG_CRC_START;
uint32_t kernelfscrc = IMAGETAG_CRC_START; uint32_t kernelfscrc = IMAGETAG_CRC_START;
uint32_t fwaddr = 0; uint32_t fwaddr = 0;
uint8_t crc_val;
const uint32_t deadcode = htonl(DEADCODE); const uint32_t deadcode = htonl(DEADCODE);
int i; int i;
int is_pirelli = 0; int is_pirelli = 0;
@ -126,7 +125,6 @@ int tagfile(const char *kernel, const char *rootfs, const char *bin, \
fwaddr = flash_start + image_offset; fwaddr = flash_start + image_offset;
if (cfefile) { if (cfefile) {
cfeoff = flash_start;
cfelen = getlen(cfefile); cfelen = getlen(cfefile);
/* Seek to the start of the file after tag */ /* Seek to the start of the file after tag */
fseek(binfile, sizeof(tag), SEEK_SET); fseek(binfile, sizeof(tag), SEEK_SET);
@ -138,7 +136,6 @@ int tagfile(const char *kernel, const char *rootfs, const char *bin, \
} }
} else { } else {
cfeoff = 0;
cfelen = 0; cfelen = 0;
} }
@ -239,7 +236,6 @@ int tagfile(const char *kernel, const char *rootfs, const char *bin, \
oldrootfslen = getlen(rootfsfile); oldrootfslen = getlen(rootfsfile);
rootfslen = oldrootfslen; rootfslen = oldrootfslen;
rootfslen = ( (rootfslen % block_size) > 0 ? (((rootfslen / block_size) + 1) * block_size) : rootfslen ); rootfslen = ( (rootfslen % block_size) > 0 ? (((rootfslen / block_size) + 1) * block_size) : rootfslen );
kerneloffpadlen = rootfslen - oldrootfslen;
oldrootfslen = rootfslen; oldrootfslen = rootfslen;
kerneloff = rootfsoff + rootfslen; kerneloff = rootfsoff + rootfslen;
@ -391,7 +387,6 @@ int tagfile(const char *kernel, const char *rootfs, const char *bin, \
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int c, i;
char *kernel, *rootfs, *bin; char *kernel, *rootfs, *bin;
uint32_t flash_start, image_offset, block_size, load_address, entry; uint32_t flash_start, image_offset, block_size, load_address, entry;
flash_start = image_offset = block_size = load_address = entry = 0; flash_start = image_offset = block_size = load_address = entry = 0;

View File

@ -763,8 +763,7 @@ write_out_header(FILE *outfile)
int int
write_out_images(FILE *outfile) write_out_images(FILE *outfile)
{ {
struct image_desc *desc; int res;
int i, res;
res = image_writeout(outfile, &kernel_image); res = image_writeout(outfile, &kernel_image);
if (res) if (res)
@ -839,7 +838,6 @@ parse_opt_image(char ch, char *arg)
{ {
char buf[MAX_ARG_LEN]; char buf[MAX_ARG_LEN];
char *argv[MAX_ARG_COUNT]; char *argv[MAX_ARG_COUNT];
int argc;
char *p; char *p;
struct image_desc *desc = NULL; struct image_desc *desc = NULL;
int i; int i;
@ -864,7 +862,7 @@ parse_opt_image(char ch, char *arg)
if (!desc) if (!desc)
return ERR_FATAL; return ERR_FATAL;
argc = parse_arg(arg, buf, argv); parse_arg(arg, buf, argv);
i = 0; i = 0;
p = argv[i++]; p = argv[i++];
@ -886,9 +884,6 @@ parse_opt_image(char ch, char *arg)
int int
process_images(void) process_images(void)
{ {
struct image_desc *desc;
uint32_t offs = 0;
int i;
int res; int res;
kernel_image.out_size = board->max_kernel_size; kernel_image.out_size = board->max_kernel_size;

View File

@ -792,7 +792,6 @@ parse_opt_block(char ch, char *arg)
{ {
char buf[MAX_ARG_LEN]; char buf[MAX_ARG_LEN];
char *argv[MAX_ARG_COUNT]; char *argv[MAX_ARG_COUNT];
int argc;
char *p; char *p;
struct csys_block *block; struct csys_block *block;
int i; int i;
@ -854,7 +853,7 @@ parse_opt_block(char ch, char *arg)
return ERR_FATAL; return ERR_FATAL;
} }
argc = parse_arg(arg, buf, argv); parse_arg(arg, buf, argv);
i = 0; i = 0;
p = argv[i++]; p = argv[i++];

View File

@ -50,7 +50,6 @@ static char *board_id;
void usage(int status) void usage(int status)
{ {
FILE *stream = (status != EXIT_SUCCESS) ? stderr : stdout; FILE *stream = (status != EXIT_SUCCESS) ? stderr : stdout;
struct board_info *board;
fprintf(stream, "Usage: %s [OPTIONS...]\n", progname); fprintf(stream, "Usage: %s [OPTIONS...]\n", progname);
fprintf(stream, fprintf(stream,

View File

@ -65,7 +65,6 @@ typedef struct image_info {
} image_info_t; } image_info_t;
static image_info_t im; static image_info_t im;
static int debug = 0;
static int zero_part_baseaddr = 0; static int zero_part_baseaddr = 0;
static void write_header(void* mem, const char* version) static void write_header(void* mem, const char* version)

View File

@ -848,14 +848,13 @@ parse_opt_id(char ch, char *arg)
{ {
char buf[MAX_ARG_LEN]; char buf[MAX_ARG_LEN];
char *argv[MAX_ARG_COUNT]; char *argv[MAX_ARG_COUNT];
int argc;
char *p; char *p;
if (required_arg(ch, arg)) { if (required_arg(ch, arg)) {
goto err_out; goto err_out;
} }
argc = parse_arg(arg, buf, argv); parse_arg(arg, buf, argv);
/* processing vendor ID*/ /* processing vendor ID*/
p = argv[0]; p = argv[0];
@ -1011,7 +1010,6 @@ parse_opt_partition(char ch, char *arg)
{ {
char buf[MAX_ARG_LEN]; char buf[MAX_ARG_LEN];
char *argv[MAX_ARG_COUNT]; char *argv[MAX_ARG_COUNT];
int argc;
char *p; char *p;
struct mylo_partition *part; struct mylo_partition *part;
struct fw_part *fp; struct fw_part *fp;
@ -1028,7 +1026,7 @@ parse_opt_partition(char ch, char *arg)
fp = &fw_parts[fw_num_partitions++]; fp = &fw_parts[fw_num_partitions++];
part = &fp->mylo; part = &fp->mylo;
argc = parse_arg(arg, buf, argv); parse_arg(arg, buf, argv);
/* processing partition address */ /* processing partition address */
p = argv[0]; p = argv[0];

View File

@ -105,7 +105,6 @@ static struct board_info *find_board(char *id)
void usage(int status) void usage(int status)
{ {
FILE *stream = (status != EXIT_SUCCESS) ? stderr : stdout; FILE *stream = (status != EXIT_SUCCESS) ? stderr : stdout;
struct board_info *board;
fprintf(stream, "Usage: %s [OPTIONS...]\n", progname); fprintf(stream, "Usage: %s [OPTIONS...]\n", progname);
fprintf(stream, fprintf(stream,

View File

@ -102,7 +102,6 @@ static void
usage(const char *progname, int status) usage(const char *progname, int status)
{ {
FILE *stream = (status != EXIT_SUCCESS) ? stderr : stdout; FILE *stream = (status != EXIT_SUCCESS) ? stderr : stdout;
int i;
fprintf(stream, "Usage: %s [OPTIONS...]\n", progname); fprintf(stream, "Usage: %s [OPTIONS...]\n", progname);
fprintf(stream, "\n" fprintf(stream, "\n"
@ -116,12 +115,12 @@ usage(const char *progname, int status)
int int
process_image(char *progname, char *filename, op_mode_t opmode) process_image(char *progname, char *filename, op_mode_t opmode)
{ {
int fd, len; int fd;
void *data, *ptr; void *ptr;
char namebuf[IH_NMLEN]; char namebuf[IH_NMLEN];
struct stat sbuf; struct stat sbuf;
uint32_t checksum, offset_kernel, offset_sqfs, offset_end, uint32_t offset_kernel, offset_sqfs, offset_end,
offset_sec_header, offset_eb, offset_image_end; offset_sec_header, offset_eb, offset_image_end;
squashfs_sb_t *sqs; squashfs_sb_t *sqs;
image_header_t *hdr; image_header_t *hdr;

View File

@ -40,7 +40,6 @@ void print_help(void)
void mknspimg_print_hdr(struct nsp_img_hdr *hdr) void mknspimg_print_hdr(struct nsp_img_hdr *hdr)
{ {
struct nsp_img_hdr_chksum *chksum; struct nsp_img_hdr_chksum *chksum;
struct nsp_img_hdr_section_info *sect_info;
struct nsp_img_hdr_sections *section; struct nsp_img_hdr_sections *section;
int i; int i;
@ -118,14 +117,11 @@ int main(int argc, char* argv[], char* env[])
int cmdline_err; int cmdline_err;
char* cmdline_error_msg; char* cmdline_error_msg;
char* filen_kernel;
char* filen_files;
char* filen_out; char* filen_out;
int i,count; /* loop variables */ int i,count; /* loop variables */
int num_sects = 2; /* We require exactly two image with -i option int num_sects = 2; /* We require exactly two image with -i option
(see CMDLINE_CFG structure above) */ (see CMDLINE_CFG structure above) */
int desc_count=0;
int total = 0; int total = 0;
int header_size=0; int header_size=0;
@ -158,8 +154,6 @@ int main(int argc, char* argv[], char* env[])
header_version=atoi(argv[cmdline_getarg(cmdline_getarg_list('h'),0)]); header_version=atoi(argv[cmdline_getarg(cmdline_getarg_list('h'),0)]);
} }
/* Set up arguments */ /* Set up arguments */
filen_kernel = argv[cmdline_getarg(cmdline_getarg_list('i'),0)];
filen_files = argv[cmdline_getarg(cmdline_getarg_list('i'),1)];
filen_out = argv[cmdline_getarg(cmdline_getarg_list('o'),0)]; filen_out = argv[cmdline_getarg(cmdline_getarg_list('o'),0)];
/* Command line arguments have been parsed. Start doing our work. */ /* Command line arguments have been parsed. Start doing our work. */

View File

@ -184,7 +184,6 @@ static struct flash_layout layouts[] = {
static void usage(int status) static void usage(int status)
{ {
FILE *stream = (status != EXIT_SUCCESS) ? stderr : stdout; FILE *stream = (status != EXIT_SUCCESS) ? stderr : stdout;
struct board_info *board;
fprintf(stream, "Usage: %s [OPTIONS...]\n", progname); fprintf(stream, "Usage: %s [OPTIONS...]\n", progname);
fprintf(stream, fprintf(stream,

View File

@ -127,7 +127,6 @@ static struct board_info *find_board(char *id)
static void usage(int status) static void usage(int status)
{ {
FILE *stream = (status != EXIT_SUCCESS) ? stderr : stdout; FILE *stream = (status != EXIT_SUCCESS) ? stderr : stdout;
struct board_info *board;
fprintf(stream, "Usage: %s [OPTIONS...]\n", progname); fprintf(stream, "Usage: %s [OPTIONS...]\n", progname);
fprintf(stream, fprintf(stream,
@ -276,8 +275,6 @@ static int build_fw(void)
char *buf; char *buf;
char *p; char *p;
int ret = EXIT_FAILURE; int ret = EXIT_FAILURE;
int writelen = 0;
uint32_t crc;
struct fw_header *hdr; struct fw_header *hdr;
struct fw_tail *tail; struct fw_tail *tail;
@ -361,11 +358,6 @@ static int build_fw(void)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int ret = EXIT_FAILURE; int ret = EXIT_FAILURE;
int err;
FILE *outfile;
progname = basename(argv[0]);
while ( 1 ) { while ( 1 ) {
int c; int c;

View File

@ -922,7 +922,6 @@ parse_opt_block(char ch, char *arg)
{ {
char buf[MAX_ARG_LEN]; char buf[MAX_ARG_LEN];
char *argv[MAX_ARG_COUNT]; char *argv[MAX_ARG_COUNT];
int argc;
char *p; char *p;
struct fw_block *block; struct fw_block *block;
int i; int i;
@ -951,7 +950,7 @@ parse_opt_block(char ch, char *arg)
break; break;
} }
argc = parse_arg(arg, buf, argv); parse_arg(arg, buf, argv);
i = 0; i = 0;
p = argv[i++]; p = argv[i++];

View File

@ -58,7 +58,6 @@ static char *ofname;
void usage(int status) void usage(int status)
{ {
FILE *stream = (status != EXIT_SUCCESS) ? stderr : stdout; FILE *stream = (status != EXIT_SUCCESS) ? stderr : stdout;
struct board_info *board;
fprintf(stream, "Usage: %s [OPTIONS...]\n", progname); fprintf(stream, "Usage: %s [OPTIONS...]\n", progname);
fprintf(stream, fprintf(stream,

View File

@ -215,7 +215,6 @@ static int decrypt;
void usage(int status) void usage(int status)
{ {
FILE *stream = (status != EXIT_SUCCESS) ? stderr : stdout; FILE *stream = (status != EXIT_SUCCESS) ? stderr : stdout;
struct board_info *board;
fprintf(stream, "Usage: %s [OPTIONS...]\n", progname); fprintf(stream, "Usage: %s [OPTIONS...]\n", progname);
fprintf(stream, fprintf(stream,

View File

@ -167,7 +167,6 @@ int main(int argc, char **argv)
char *ifn = NULL; char *ifn = NULL;
char *ofn = NULL; char *ofn = NULL;
int c; int c;
int v0, v1, v2;
size_t n; size_t n;
int first_block = 1; int first_block = 1;

View File

@ -433,9 +433,8 @@ int srecLine(char *pSrecLine)
int srec2bin(int argc,char *argv[],int verbose) int srec2bin(int argc,char *argv[],int verbose)
{ {
int i,rlen,sts; int rlen,sts;
FILE *fp; FILE *fp;
char ac;
char buff[256]; char buff[256];
bit32u TAG_BIG = 0xDEADBE42; bit32u TAG_BIG = 0xDEADBE42;
bit32u TAG_LITTLE = 0xFEEDFA42; bit32u TAG_LITTLE = 0xFEEDFA42;

View File

@ -140,6 +140,10 @@ int main(int argc, char *argv[])
rewind(fpIn); rewind(fpIn);
/* read the whole file*/ /* read the whole file*/
res = fread(buf, 1, length, fpIn); res = fread(buf, 1, length, fpIn);
if (res != length) {
fprintf(stderr, "Unable to fread from input file\n");
return EXIT_FAILURE;
}
p = (struct trx_header *)buf; p = (struct trx_header *)buf;
if (LOAD32_LE(p->magic) != TRX_MAGIC) { if (LOAD32_LE(p->magic) != TRX_MAGIC) {

View File

@ -61,7 +61,6 @@ int main(int argc, char **argv)
char hex_pattern[128]; char hex_pattern[128];
unsigned int hex_buf; unsigned int hex_buf;
int c; int c;
int v0, v1, v2;
size_t n; size_t n;
int p_len, p_off = 0; int p_len, p_off = 0;