mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-20 22:23:27 +00:00
firmware-utils: mkfwimage: fix more errors reported by gcc-6/7/9
src/mkfwimage.c:276:8: error: format '%lld' expects argument of type 'long long int', but argument 4 has type '__off_t' {aka 'const long int'} [-Werror=format=] src/fw.h:71:36: error: format '%llu' expects argument of type 'long long unsigned int', but argument 6 has type '__off_t' {aka 'long int'} [-Werror=format=] inlined from 'main' at src/mkfwimage.c:543:12: /string_fortified.h:106:10: error: '__builtin_strncpy' output truncated before terminating nul copying 4 bytes from a string of the same length [-Werror=stringop-truncation] inlined from 'write_part' at src/mkfwimage.c:235:2, string_fortified.h:106:10: error: '__builtin_strncpy' specified bound 16 equals destination size [-Werror=stringop-truncation] inlined from 'main' at src/mkfwimage.c:477:5: string_fortified.h:106:10: error: '__builtin_strncpy' specified bound 256 equals destination size [-Werror=stringop-truncation] inlined from 'main' at src/mkfwimage.c:496:5: string_fortified.h:106:10: error: '__builtin_strncpy' specified bound 4096 equals destination size [-Werror=stringop-truncation] inlined from 'main' at src/mkfwimage.c:481:5: string_fortified.h:106:10: error: '__builtin_strncpy' specified bound 4096 equals destination size [-Werror=stringop-truncation] inlined from 'main' at src/mkfwimage.c:485:5: string_fortified.h:106:10: error: '__builtin_strncpy' specified bound 16 equals destination size [-Werror=stringop-truncation] Runtested on ath79 and UBNT Bullet M XW. Signed-off-by: Petr Štetiar <ynezz@true.cz>
This commit is contained in:
parent
90b7dbf7d8
commit
04cb651376
@ -38,7 +38,7 @@ define Host/Compile
|
|||||||
$(call cc,mkzynfw)
|
$(call cc,mkzynfw)
|
||||||
$(call cc,lzma2eva,-lz)
|
$(call cc,lzma2eva,-lz)
|
||||||
$(call cc,mkcasfw)
|
$(call cc,mkcasfw)
|
||||||
$(call cc,mkfwimage,-lz -Wall -Werror -Wextra)
|
$(call cc,mkfwimage,-lz -Wall -Werror -Wextra -D_FILE_OFFSET_BITS=64)
|
||||||
$(call cc,mkfwimage2,-lz)
|
$(call cc,mkfwimage2,-lz)
|
||||||
$(call cc,imagetag imagetag_cmdline cyg_crc32)
|
$(call cc,imagetag imagetag_cmdline cyg_crc32)
|
||||||
$(call cc,add_header)
|
$(call cc,add_header)
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#define MAGIC_ENDS "ENDS"
|
#define MAGIC_ENDS "ENDS"
|
||||||
|
|
||||||
#define MAGIC_LENGTH 4
|
#define MAGIC_LENGTH 4
|
||||||
|
#define PART_NAME_LENGTH 16
|
||||||
|
|
||||||
typedef struct header {
|
typedef struct header {
|
||||||
char magic[MAGIC_LENGTH];
|
char magic[MAGIC_LENGTH];
|
||||||
@ -37,7 +38,7 @@ typedef struct header {
|
|||||||
|
|
||||||
typedef struct part {
|
typedef struct part {
|
||||||
char magic[MAGIC_LENGTH];
|
char magic[MAGIC_LENGTH];
|
||||||
char name[16];
|
char name[PART_NAME_LENGTH];
|
||||||
char pad[12];
|
char pad[12];
|
||||||
u_int32_t memaddr;
|
u_int32_t memaddr;
|
||||||
u_int32_t index;
|
u_int32_t index;
|
||||||
|
@ -230,9 +230,10 @@ static int write_part(void* mem, part_data_t* d)
|
|||||||
memcpy(mem + sizeof(part_t), addr, d->stats.st_size);
|
memcpy(mem + sizeof(part_t), addr, d->stats.st_size);
|
||||||
munmap(addr, d->stats.st_size);
|
munmap(addr, d->stats.st_size);
|
||||||
|
|
||||||
memset(p->name, 0, sizeof(p->name));
|
memset(p->name, 0, PART_NAME_LENGTH);
|
||||||
strncpy(p->magic, MAGIC_PART, MAGIC_LENGTH);
|
memcpy(p->magic, MAGIC_PART, MAGIC_LENGTH);
|
||||||
strncpy(p->name, d->partition_name, sizeof(p->name));
|
memcpy(p->name, d->partition_name, PART_NAME_LENGTH);
|
||||||
|
|
||||||
p->index = htonl(d->partition_index);
|
p->index = htonl(d->partition_index);
|
||||||
p->data_size = htonl(d->stats.st_size);
|
p->data_size = htonl(d->stats.st_size);
|
||||||
p->part_size = htonl(d->partition_length);
|
p->part_size = htonl(d->partition_length);
|
||||||
@ -273,7 +274,7 @@ static void print_image_info(const image_info_t* im)
|
|||||||
for (i = 0; i < im->part_count; ++i)
|
for (i = 0; i < im->part_count; ++i)
|
||||||
{
|
{
|
||||||
const part_data_t* d = &im->parts[i];
|
const part_data_t* d = &im->parts[i];
|
||||||
INFO(" %10s: %8lld bytes (free: %8lld)\n",
|
INFO(" %10s: %8ld bytes (free: %8ld)\n",
|
||||||
d->partition_name,
|
d->partition_name,
|
||||||
d->stats.st_size,
|
d->stats.st_size,
|
||||||
d->partition_length - d->stats.st_size);
|
d->partition_length - d->stats.st_size);
|
||||||
@ -372,7 +373,7 @@ static int validate_image_layout(image_info_t* im)
|
|||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
if (d->stats.st_size > d->partition_length) {
|
if (d->stats.st_size > d->partition_length) {
|
||||||
ERROR("File '%s' too big (%d) - max size: 0x%08X (exceeds %llu bytes)\n",
|
ERROR("File '%s' too big (%d) - max size: 0x%08X (exceeds %lu bytes)\n",
|
||||||
d->filename, i, d->partition_length,
|
d->filename, i, d->partition_length,
|
||||||
d->stats.st_size - d->partition_length);
|
d->stats.st_size - d->partition_length);
|
||||||
return -4;
|
return -4;
|
||||||
@ -474,30 +475,30 @@ int main(int argc, char* argv[])
|
|||||||
switch (o) {
|
switch (o) {
|
||||||
case 'v':
|
case 'v':
|
||||||
if (optarg)
|
if (optarg)
|
||||||
strncpy(im.version, optarg, sizeof(im.version));
|
strncpy(im.version, optarg, sizeof(im.version) - 1);
|
||||||
break;
|
break;
|
||||||
case 'o':
|
case 'o':
|
||||||
if (optarg)
|
if (optarg)
|
||||||
strncpy(im.outputfile, optarg, sizeof(im.outputfile));
|
strncpy(im.outputfile, optarg, sizeof(im.outputfile) - 1);
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
if (optarg)
|
if (optarg)
|
||||||
strncpy(im.magic, optarg, sizeof(im.magic));
|
strncpy(im.magic, optarg, sizeof(im.magic) - 1);
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
usage(argv[0]);
|
usage(argv[0]);
|
||||||
return -1;
|
return -1;
|
||||||
case 'k':
|
case 'k':
|
||||||
if (optarg)
|
if (optarg)
|
||||||
strncpy(kernelfile, optarg, sizeof(kernelfile));
|
strncpy(kernelfile, optarg, sizeof(kernelfile) - 1);
|
||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
if (optarg)
|
if (optarg)
|
||||||
strncpy(rootfsfile, optarg, sizeof(rootfsfile));
|
strncpy(rootfsfile, optarg, sizeof(rootfsfile) - 1);
|
||||||
break;
|
break;
|
||||||
case 'B':
|
case 'B':
|
||||||
if (optarg)
|
if (optarg)
|
||||||
strncpy(board_name, optarg, sizeof(board_name));
|
strncpy(board_name, optarg, sizeof(board_name) - 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user