size_t len = statbuf.st_size;
- if (add_jffs2_eof)
+ if (add_jffs2_eof) {
if (file_system_partition)
len = ALIGN(len + file_system_partition->base, 0x10000) + sizeof(jffs2_eof_mark) - file_system_partition->base;
else
len = ALIGN(len, 0x10000) + sizeof(jffs2_eof_mark);
+ }
struct image_partition_entry entry = alloc_image_partition(part_name, len);
unsigned long base,
unsigned long size)
{
- int ptr;
+ size_t ptr;
/* check if the list has a free entry */
for (ptr = 0; ptr < max_entries; ptr++, part_list++) {
if (part_list->name == NULL &&
if (fseek(file, offset, SEEK_SET) < 0)
error(1, errno, "Can not seek in the firmware");
- if (fread(buf, 1, 2048, file) < 0)
+ if (fread(buf, 2048, 1, file) != 1)
error(1, errno, "Can not read fwup-ptn from the firmware");
buf[2047] = '\0';
fseek(input_file, entry->base + firmware_offset, SEEK_SET);
for (offset = 0; sizeof(buf) + offset <= entry->size; offset += sizeof(buf)) {
- if (fread(buf, sizeof(buf), 1, input_file) < 0)
+ if (fread(buf, sizeof(buf), 1, input_file) != 1)
error(1, errno, "Can not read partition from input_file");
- if (fwrite(buf, sizeof(buf), 1, output_file) < 0)
+ if (fwrite(buf, sizeof(buf), 1, output_file) != 1)
error(1, errno, "Can not write partition to output_file");
}
/* write last chunk smaller than buffer */
if (offset < entry->size) {
offset = entry->size - offset;
- if (fread(buf, offset, 1, input_file) < 0)
+ if (fread(buf, offset, 1, input_file) != 1)
error(1, errno, "Can not read partition from input_file");
- if (fwrite(buf, offset, 1, output_file) < 0)
+ if (fwrite(buf, offset, 1, output_file) != 1)
error(1, errno, "Can not write partition to output_file");
}
}
error(1, 0, "Error can not read the partition table (fwup-ptn)");
}
- for (int i = 0; i < max_entries; i++) {
+ for (size_t i = 0; i < max_entries; i++) {
if (entries[i].name == NULL &&
entries[i].base == 0 &&
entries[i].size == 0)
struct flash_partition_entry *entries, size_t max_entries,
const char *name, const char *error_msg)
{
- for (int i = 0; i < max_entries; i++, entries++) {
+ for (size_t i = 0; i < max_entries; i++, entries++) {
if (strcmp(entries->name, name) == 0)
return entries;
}
static void write_ff(FILE *output_file, size_t size)
{
char buf[4096];
- int offset;
+ size_t offset;
memset(buf, 0xff, sizeof(buf));
for (offset = 0; offset + sizeof(buf) < size ; offset += sizeof(buf)) {
- if (fwrite(buf, sizeof(buf), 1, output_file) < 0)
+ if (fwrite(buf, sizeof(buf), 1, output_file) != 1)
error(1, errno, "Can not write 0xff to output_file");
}
/* write last chunk smaller than buffer */
if (offset < size) {
offset = size - offset;
- if (fwrite(buf, offset, 1, output_file) < 0)
+ if (fwrite(buf, offset, 1, output_file) != 1)
error(1, errno, "Can not write partition to output_file");
}
}