mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Debian bug 464384: fix OFF_T_FORMAT mismatches on amd64
On AMD64 apparently, off_t is long but ELinks detected SIZEOF_OFF_T == 8 and defined OFF_T_FORMAT as "lld", which expects long long and so causes GCC to warn about a mismatching format specifier. Because --enable-debug adds -Werror to $CFLAGS, this warning breaks the build. When both SIZEOF_LONG and SIZEOF_LONG_LONG are 8, ELinks cannot know which type it should use. To fix this, do not attempt to find a format specifier for off_t itself. Instead cast all printed off_t values to a new typedef off_print_T that is large enough, and replace OFF_T_FORMAT with OFF_PRINT_FORMAT which is suitable for off_print_T altough not necessarily for off_t. ELinks already had a similar scheme with time_print_T and TIME_PRINT_FORMAT.
This commit is contained in:
parent
6555359f8e
commit
61019c3130
8
src/cache/cache.c
vendored
8
src/cache/cache.c
vendored
@ -40,9 +40,11 @@ static void truncate_entry(struct cache_entry *cached, off_t offset, int final);
|
||||
|
||||
#define dump_frag(frag, count) \
|
||||
do { \
|
||||
DBG(" [%d] f=%p offset=%" OFF_T_FORMAT " length=%" OFF_T_FORMAT \
|
||||
" real_length=%" OFF_T_FORMAT, \
|
||||
count, frag, frag->offset, frag->length, frag->real_length); \
|
||||
DBG(" [%d] f=%p offset=%" OFF_PRINT_FORMAT \
|
||||
" length=%" OFF_PRINT_FORMAT \
|
||||
" real_length=%" OFF_PRINT_FORMAT, \
|
||||
count, frag, (off_print_T) frag->offset, \
|
||||
(off_print_T) frag->length, (off_print_T) frag->real_length); \
|
||||
} while (0)
|
||||
|
||||
#define dump_frags(entry, comment) \
|
||||
|
8
src/cache/dialogs.c
vendored
8
src/cache/dialogs.c
vendored
@ -82,10 +82,10 @@ get_cache_entry_info(struct listbox_item *item, struct terminal *term)
|
||||
}
|
||||
}
|
||||
|
||||
add_format_to_string(&msg, "\n%s: %" OFF_T_FORMAT, _("Size", term),
|
||||
cached->length);
|
||||
add_format_to_string(&msg, "\n%s: %" OFF_T_FORMAT, _("Loaded size", term),
|
||||
cached->data_size);
|
||||
add_format_to_string(&msg, "\n%s: %" OFF_PRINT_FORMAT, _("Size", term),
|
||||
(off_print_T) cached->length);
|
||||
add_format_to_string(&msg, "\n%s: %" OFF_PRINT_FORMAT, _("Loaded size", term),
|
||||
(off_print_T) cached->data_size);
|
||||
if (cached->content_type) {
|
||||
add_format_to_string(&msg, "\n%s: %s", _("Content type", term),
|
||||
cached->content_type);
|
||||
|
@ -152,8 +152,9 @@ document_info_dialog(struct session *ses)
|
||||
if (cached) {
|
||||
unsigned char *a;
|
||||
|
||||
add_format_to_string(&msg, "\n%s: %" OFF_T_FORMAT,
|
||||
_("Size", term), cached->length);
|
||||
add_format_to_string(&msg, "\n%s: %" OFF_PRINT_FORMAT,
|
||||
_("Size", term),
|
||||
(off_print_T) cached->length);
|
||||
|
||||
if (cached->incomplete) {
|
||||
add_format_to_string(&msg, " (%s)", _("incomplete", term));
|
||||
|
@ -146,12 +146,24 @@ typedef unsigned long long uint32_t;
|
||||
*/
|
||||
typedef long longptr_T;
|
||||
|
||||
/* Define internal off_t format macro for printing variables. */
|
||||
#if HAVE_OFF_T == 1 && SIZEOF_OFF_T == 8
|
||||
#define OFF_T_FORMAT "lld"
|
||||
/* To print off_t offset, ELinks does:
|
||||
*
|
||||
* printf("%" OFF_PRINT_FORMAT, (off_print_T) offset);
|
||||
*
|
||||
* The cast is necessary because it is not possible to guess
|
||||
* a printf format for off_t itself based on what we have here.
|
||||
* The off_t type might be either long or long long, and the format
|
||||
* string must match even if both types have the same representation,
|
||||
* because GCC warns about mismatches and --enable-debug adds -Werror
|
||||
* to $CFLAGS. */
|
||||
#if !HAVE_OFF_T || SIZEOF_OFF_T <= SIZEOF_LONG
|
||||
typedef long off_print_T;
|
||||
# define OFF_PRINT_FORMAT "ld"
|
||||
#elif HAVE_LONG_LONG && SIZEOF_OFF_T <= SIZEOF_LONG_LONG
|
||||
typedef long long off_print_T;
|
||||
# define OFF_PRINT_FORMAT "lld"
|
||||
#else
|
||||
/* For ELinks, off_t defaults to long. */
|
||||
#define OFF_T_FORMAT "ld"
|
||||
# error "cannot figure out how to print off_t values"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -314,7 +314,8 @@ do_fsp(struct connection *conn)
|
||||
#endif
|
||||
|
||||
/* Send filesize */
|
||||
fprintf(stderr, "%" OFF_T_FORMAT "\n", (off_t)(sb.st_size));
|
||||
fprintf(stderr, "%" OFF_PRINT_FORMAT "\n",
|
||||
(off_print_T) sb.st_size);
|
||||
fclose(stderr);
|
||||
|
||||
while ((r = fsp_fread(buf, 1, READ_SIZE, file)) > 0)
|
||||
|
@ -1170,7 +1170,8 @@ display_dir_entry(struct cache_entry *cached, off_t *pos, int *tries,
|
||||
add_to_string(&string, " 1 ftp ftp ");
|
||||
|
||||
if (ftp_info->size != FTP_SIZE_UNKNOWN) {
|
||||
add_format_to_string(&string, "%12" OFF_T_FORMAT " ", ftp_info->size);
|
||||
add_format_to_string(&string, "%12" OFF_PRINT_FORMAT " ",
|
||||
(off_print_T) ftp_info->size);
|
||||
} else {
|
||||
add_to_string(&string, " - ");
|
||||
}
|
||||
|
@ -349,7 +349,8 @@ do_smb(struct connection *conn)
|
||||
smb_error(res);
|
||||
}
|
||||
/* filesize */
|
||||
fprintf(stderr, "%" OFF_T_FORMAT, sb.st_size);
|
||||
fprintf(stderr, "%" OFF_PRINT_FORMAT,
|
||||
(off_print_T) sb.st_size);
|
||||
fclose(stderr);
|
||||
|
||||
while ((r = smbc_read(file, buf, READ_SIZE)) > 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user