Y Giridhar Appaji Nag <[EMAIL PROTECTED]> quotes: > make[4]: Entering directory > `/tmp/buildd/elinks-0.12~20080127/build-main/src/protocol/smb' > [CC] src/protocol/smb/smb2.o > cc1: warnings being treated as errors > /tmp/buildd/elinks-0.12~20080127/src/protocol/smb/smb2.c: In function > 'do_smb': > /tmp/buildd/elinks-0.12~20080127/src/protocol/smb/smb2.c:352: warning: format > '%lld' expects type 'long long int', but argument 3 has type '__off_t' > make[4]: *** [smb2.o] Error 1
Thank you. I pushed the following patch, which should fix these.
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.
---
commit 61019c31304f89141248b0381974d1e3886cf160
tree a3343d1895bfd6892bbc6cf275930c513a508bec
parent 6555359f8e56b6e08bd1a8f40fd363506a0e3ff5
author Kalle Olavi Niemitalo <[EMAIL PROTECTED]> Sun, 10 Feb 2008 11:20:33 +0200
committer Kalle Olavi Niemitalo <[EMAIL PROTECTED]> Sun, 10 Feb 2008 11:30:27
+0200
src/cache/cache.c | 8 +++++---
src/cache/dialogs.c | 8 ++++----
src/dialogs/document.c | 5 +++--
src/osdep/types.h | 22 +++++++++++++++++-----
src/protocol/fsp/fsp.c | 3 ++-
src/protocol/ftp/ftp.c | 3 ++-
src/protocol/smb/smb2.c | 3 ++-
7 files changed, 35 insertions(+), 17 deletions(-)
diff --git a/src/cache/cache.c b/src/cache/cache.c
index db9efe1..8b05080 100644
--- a/src/cache/cache.c
+++ b/src/cache/cache.c
@@ -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) \
diff --git a/src/cache/dialogs.c b/src/cache/dialogs.c
index b0a33b3..29a9446 100644
--- a/src/cache/dialogs.c
+++ b/src/cache/dialogs.c
@@ -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);
diff --git a/src/dialogs/document.c b/src/dialogs/document.c
index ba55ea2..458e839 100644
--- a/src/dialogs/document.c
+++ b/src/dialogs/document.c
@@ -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));
diff --git a/src/osdep/types.h b/src/osdep/types.h
index 2404ac0..f1c42f8 100644
--- a/src/osdep/types.h
+++ b/src/osdep/types.h
@@ -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
diff --git a/src/protocol/fsp/fsp.c b/src/protocol/fsp/fsp.c
index 06b24ef..efa6e2e 100644
--- a/src/protocol/fsp/fsp.c
+++ b/src/protocol/fsp/fsp.c
@@ -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)
diff --git a/src/protocol/ftp/ftp.c b/src/protocol/ftp/ftp.c
index 1320127..eefe8b1 100644
--- a/src/protocol/ftp/ftp.c
+++ b/src/protocol/ftp/ftp.c
@@ -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, " - ");
}
diff --git a/src/protocol/smb/smb2.c b/src/protocol/smb/smb2.c
index 30908b3..0a839db 100644
--- a/src/protocol/smb/smb2.c
+++ b/src/protocol/smb/smb2.c
@@ -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) {
pgpL2xCxz1rzs.pgp
Description: PGP signature

