The following patch fixes all the GCC 4.0 build errors. However, it does need testing by an ftape user (to check old tapes still read--there were some struct packing issues).
Regards, Roger diff -urN ftape-tools-1.09.2002.03.21.original/debian/changelog ftape-tools-1.09.2002.03.21/debian/changelog --- ftape-tools-1.09.2002.03.21.original/debian/changelog 2005-07-24 12:10:54.000000000 +0100 +++ ftape-tools-1.09.2002.03.21/debian/changelog 2005-07-24 14:13:45.000000000 +0100 @@ -1,3 +1,28 @@ +ftape-tools (1:1.09.2002.03.21-0.4) unstable; urgency=low + + * Non-maintainer upload. + * Fix several GCC 4.0 incompatibilies (Closes: #318533). + - src/ftformat/ftfmt-options.c: struct opt_parms.label is a + "u_int8_t *"; add appropriate typecasts. + - /src/ftformat/ftfmt-tapelib.c: + + Replace the use of the non-standard preprocessor macro + __FUNCTION__ with the C99 __func__. + + Include missing <stdlib.h>. + - src/ftformat/ftformat.c: + + Include missing <stdlib.h>. + + Add "char *" casts to quell signedness warnings. + - src/ftformat/ftformat.h, src/vtblc/ftvt.h: "__attribute__ ((packed))" + must come immediately after the end of the struct definition, not + after the typedef name. + - src/vtblc/libftvt.c: + + Add "char *" casts to quell signedness warnings. + + Add GET_SINGLE_BITFIELD_VALUE_ACTION and GET_SINGLE_BITFIELD_VALUE + macros to replace the use of GET_SINGLE_VALUE_ACTION and + GET_SINGLE_VALUE for bitfield values in structs. The latter + use the GCC typeof extension, which does not work with bifields. + + -- Roger Leigh <[EMAIL PROTECTED]> Sun, 24 Jul 2005 14:13:33 +0100 + ftape-tools (1:1.09.2002.03.21-0.3) unstable; urgency=low * Uploading with maintainer set to QA group diff -urN ftape-tools-1.09.2002.03.21.original/src/ftformat/ftfmt-options.c ftape-tools-1.09.2002.03.21/src/ftformat/ftfmt-options.c --- ftape-tools-1.09.2002.03.21.original/src/ftformat/ftfmt-options.c 2000-07-23 14:55:40.000000000 +0100 +++ ftape-tools-1.09.2002.03.21/src/ftformat/ftfmt-options.c 2005-07-24 12:59:34.000000000 +0100 @@ -51,7 +51,7 @@ #include "version.h" struct opt_parms opt = { - FTAPE_DEF_LABEL, + (u_int8_t *) FTAPE_DEF_LABEL, FTAPE_DEF_TAPE, FT_BUFF_SIZE * NR_FTAPE_BUFFERS, AUTO, @@ -311,7 +311,7 @@ } break; case 'L': - opt.label = optarg; + opt.label = (u_int8_t *) optarg; break; case 'M': opt.dma_size = strtol(optarg, NULL, 0); diff -urN ftape-tools-1.09.2002.03.21.original/src/ftformat/ftfmt-tapelib.c ftape-tools-1.09.2002.03.21/src/ftformat/ftfmt-tapelib.c --- ftape-tools-1.09.2002.03.21.original/src/ftformat/ftfmt-tapelib.c 2000-07-23 23:47:59.000000000 +0100 +++ ftape-tools-1.09.2002.03.21/src/ftformat/ftfmt-tapelib.c 2005-07-24 12:18:25.000000000 +0100 @@ -36,6 +36,7 @@ #define MAP_FAILED (void *)(-1) #endif #include <stdio.h> +#include <stdlib.h> #include <unistd.h> #include <sys/stat.h> #include <fcntl.h> @@ -437,7 +438,7 @@ printf(_("Writing reference bursts ... ")); if (qic_simple_command(tape_fd, 0, QIC_ENTER_FORMAT_MODE, -1, 0, NULL)) { - fprintf(stderr, "\n"__FUNCTION__ " %s", _("failed!\n")); + fprintf(stderr, "\n%s %s", __func__, _("failed!\n")); return -1; } if (qic_simple_command(tape_fd, 0, QIC_WRITE_REFERENCE_BURST, -1, 940, @@ -445,7 +446,7 @@ return -1; } if (!(status & QIC_STATUS_REFERENCED)) { - fprintf(stderr, "\n"__FUNCTION__ " %s", _("failed!\n")); + fprintf(stderr, "\n%s %s", __func__, _("failed!\n")); return -1; } printf(_("done.\n")); @@ -804,7 +805,8 @@ } if (buf_pos == buf_end) { /* cycle */ msync_offset = 0; /* reset to start of buffer */ - buf_start = (void*) buf_pos = buf; + buf_pos = buf; + buf_start = (void*) buf_pos; } } /* We only sync after computing enough parameters for an entire page, @@ -845,7 +847,7 @@ struct mtftformat_virtual fmtc; if (qic_simple_command(tape_fd, 0, QIC_ENTER_FORMAT_MODE, -1, 0, NULL)) { - fprintf(stderr, __FUNCTION__ " %s", _("failed!\n")); + fprintf(stderr, "%s %s", __func__, _("failed!\n")); return -1; } trk = 0; diff -urN ftape-tools-1.09.2002.03.21.original/src/ftformat/ftformat.c ftape-tools-1.09.2002.03.21/src/ftformat/ftformat.c --- ftape-tools-1.09.2002.03.21.original/src/ftformat/ftformat.c 2002-03-21 22:00:14.000000000 +0000 +++ ftape-tools-1.09.2002.03.21/src/ftformat/ftformat.c 2005-07-24 13:00:26.000000000 +0100 @@ -31,6 +31,7 @@ #include <sys/types.h> #include <stdio.h> +#include <stdlib.h> #include <unistd.h> #include <string.h> #include <locale.h> @@ -202,7 +203,7 @@ exit (1); } - if (compose_header_segment(hseg, opts.label, &tpparms)) { + if (compose_header_segment(hseg, (char *) opts.label, &tpparms)) { tape_close(tape_fd, dma_buffer, opts.dma_size); exit (1); } diff -urN ftape-tools-1.09.2002.03.21.original/src/ftformat/ftformat.h ftape-tools-1.09.2002.03.21/src/ftformat/ftformat.h --- ftape-tools-1.09.2002.03.21.original/src/ftformat/ftformat.h 2001-08-11 01:08:58.000000000 +0100 +++ ftape-tools-1.09.2002.03.21/src/ftformat/ftformat.h 2005-07-24 12:55:27.000000000 +0100 @@ -45,11 +45,11 @@ typedef struct { u_int8_t cyl; u_int8_t head; u_int8_t sect; u_int8_t size; -} format_sector __attribute__ ((packed)); +} __attribute__ ((packed)) format_sector; typedef struct { format_sector sectors[FT_SECTORS_PER_SEGMENT]; -} format_segment __attribute__ ((packed)); +} __attribute__ ((packed)) format_segment; #define MAX_FLOPPY_SECTOR 128 /* number of sectors per track */ #define SEGMENTS_PER_FLOPPY_TRACK (MAX_FLOPPY_SECTOR/FT_SECTORS_PER_SEGMENT) diff -urN ftape-tools-1.09.2002.03.21.original/src/vtblc/ftvt.h ftape-tools-1.09.2002.03.21/src/vtblc/ftvt.h --- ftape-tools-1.09.2002.03.21.original/src/vtblc/ftvt.h 2001-08-12 17:34:20.000000000 +0100 +++ ftape-tools-1.09.2002.03.21/src/vtblc/ftvt.h 2005-07-24 13:01:15.000000000 +0100 @@ -111,14 +111,14 @@ u_int8_t cmap; u_int8_t qic113; u_int8_t reserved[26-ZFT_SIGLEN-2-1-1]; -} zft_ext_qic80_t __attribute__ ((packed)); +} __attribute__ ((packed)) zft_ext_qic80_t; typedef struct zft_ext_qic113 { u_int8_t sig[ZFT_SIGLEN2]; u_int8_t version; u_int16_t blksz; u_int8_t reserved[8]; -} zft_ext_qic113_t __attribute__ ((packed)); +} __attribute__ ((packed)) zft_ext_qic113_t; /* for bsm map stuff */ @@ -162,7 +162,7 @@ u_int8_t format; u_int8_t reserved_2; u_int8_t reserved_3; -} ftvt_entry __attribute__ ((packed)); +} __attribute__ ((packed)) ftvt_entry; typedef struct ftvt { int num; diff -urN ftape-tools-1.09.2002.03.21.original/src/vtblc/libftvt.c ftape-tools-1.09.2002.03.21/src/vtblc/libftvt.c --- ftape-tools-1.09.2002.03.21.original/src/vtblc/libftvt.c 2001-08-11 01:16:32.000000000 +0100 +++ ftape-tools-1.09.2002.03.21/src/vtblc/libftvt.c 2005-07-24 13:27:06.000000000 +0100 @@ -680,26 +680,26 @@ printf("QIC_MINOR %d\n", volume->entry.ext.qic113.minor); print_hex_line(stdout, "VENDOR_EXTENSION \"", - volume->entry.ext.qic113.ext, + (char *)volume->entry.ext.qic113.ext, "\"\n", sizeof(volume->entry.ext.qic113.ext)); print_char_line(stdout, "# ", - volume->entry.ext.qic113.ext, + (char*)volume->entry.ext.qic113.ext, "\n", sizeof(volume->entry.ext.qic113.ext)); } else { print_hex_line(stdout, "VENDOR_EXTENSION \"", - volume->entry.ext.ext, + (char*)volume->entry.ext.ext, "\"\n", sizeof(volume->entry.ext.ext)); print_char_line(stdout, "# ", - volume->entry.ext.ext, + (char*)volume->entry.ext.ext, "\n", sizeof(volume->entry.ext.ext)); } - print_hex_line(stdout, "PASSWORD \"", volume->entry.pwd, "\"\n", - sizeof(volume->entry.pwd)); + print_hex_line(stdout, "PASSWORD \"", (char *)volume->entry.pwd, + "\"\n", sizeof(volume->entry.pwd)); if (volume->entry.pwd[0] != '\0') { - print_char_line(stdout, "# ", volume->entry.pwd, "\n", + print_char_line(stdout, "# ", (char *)volume->entry.pwd, "\n", sizeof(volume->entry.pwd)); } else { printf("# no password\n"); @@ -722,9 +722,10 @@ } else { /* print remaining values as hex string */ print_hex_line(stdout, - "VENDOR_DATA \"", &volume->bytes[56], "\"\n", 72); + "VENDOR_DATA \"", (char *)&volume->bytes[56], + "\"\n", 72); print_char_line(stdout, - "# ", &volume->bytes[56], "\n", 72); + "# ", (char *)&volume->bytes[56], "\n", 72); } } @@ -812,28 +813,28 @@ */ static void print_one_xtbl(const ftvt *volume) { - print_hex_line(stdout, - "NAME \"", &volume->bytes[XTBL_NAME], "\"\n", 88); - print_hex_line(stdout, - "PASSWORD \"", &volume->bytes[XTBL_PWD], "\"\n", 16); - print_hex_line(stdout, - "RESERVED \"", &volume->bytes[XTBL_RES], "\"\n", 20); + print_hex_line(stdout, "NAME \"", + (char *)&volume->bytes[XTBL_NAME], "\"\n", 88); + print_hex_line(stdout, "PASSWORD \"", + (char *)&volume->bytes[XTBL_PWD], "\"\n", 16); + print_hex_line(stdout, "RESERVED \"", + (char *)&volume->bytes[XTBL_RES], "\"\n", 20); } static void print_one_utid(const ftvt *volume) { - print_hex_line(stdout, - "NAME \"", &volume->bytes[UTID_NAME], "\"\n", 88); - print_hex_line(stdout, - "RESERVED \"", &volume->bytes[XTBL_RES], "\"\n", 36); + print_hex_line(stdout, "NAME \"", + (char *)&volume->bytes[UTID_NAME], "\"\n", 88); + print_hex_line(stdout, "RESERVED \"", + (char *)&volume->bytes[XTBL_RES], "\"\n", 36); } static void print_one_exvt(const ftvt *volume) { printf("PARENT %d\n", *(u_int16_t *)&volume->bytes[EXVT_PARENT]); printf("CHILD %d\n", *(u_int16_t *)&volume->bytes[EXVT_CHILD]); - print_hex_line(stdout, - "RESERVED \"", &volume->bytes[EXVT_RES], "\"\n", 120); + print_hex_line(stdout, "RESERVED \"", + (char *)&volume->bytes[EXVT_RES], "\"\n", 120); } /* Print one volume table in tagged output format (i.e. keyword-value @@ -868,9 +869,9 @@ } } if (i == NR_ITEMS(prt_handler)) { /* unknown signature */ - print_hex_line(stdout, - "ENTRY_DATA \"", &volume->bytes[4], "\"\n", 124); - print_char_line(stdout, "# ", &volume->bytes[4], "\n", 124); + print_hex_line(stdout, "ENTRY_DATA \"", + (char *)&volume->bytes[4], "\"\n", 124); + print_char_line(stdout, "# ", (char *)&volume->bytes[4], "\n", 124); } } @@ -918,13 +919,13 @@ * * tag : the keyword * conv: conversion characater (like d, u, L etc.) for the numeric value - * dest: Location to store the value in. + * dest: Location to store the value in (NOT a bitfield). * action: something. Must allow a semicolon at end. * */ #define GET_SINGLE_VALUE_ACTION(tag, conv, dest, action) \ { \ - typeof(dest) value; /* cope with bitfields */ \ + typeof(dest) value; \ \ if (strncmp(#tag, buffer, sizeof(#tag)-1) == 0) { \ if (sscanf(buffer, #tag" %"#conv, &value) == 1) { \ @@ -943,12 +944,47 @@ * * tag : the keyword * conv: conversion characater (like d, u, L etc.) for the numeric value - * dest: Location to store the value in. + * dest: Location to store the value in (NOT a bitfield). * */ #define GET_SINGLE_VALUE(tag, conv, dest) \ GET_SINGLE_VALUE_ACTION(tag, conv, dest, /**/) +/* Internal use. Get a single bitfield value and do something + * + * tag : the keyword + * conv: conversion characater (like d, u, L etc.) for the numeric value + * dest: Bitfield location to store the value in. + * action: something. Must allow a semicolon at end. + * + */ +#define GET_SINGLE_BITFIELD_VALUE_ACTION(tag, conv, dest, action) \ +{ \ + unsigned int value; /* storage for bitfield */ \ + \ + if (strncmp(#tag, buffer, sizeof(#tag)-1) == 0) { \ + if (sscanf(buffer, #tag" %"#conv, &value) == 1) { \ + (dest) = value; \ + action; \ + } else { \ + ftvt_error(_("Corrupt volume input data: %s\n"), \ + buffer); \ + return -1; \ + } \ + continue; \ + } \ +} + +/* Internal use. Get a single bitfield value. + * + * tag : the keyword + * conv: conversion characater (like d, u, L etc.) for the numeric value + * dest: Bitfield location to store the value in. + * + */ +#define GET_SINGLE_BITFIELD_VALUE(tag, conv, dest) \ + GET_SINGLE_BITFIELD_VALUE_ACTION(tag, conv, dest, /**/) + /* Internal use only. Get a string value. * * tag: the keyword. @@ -1071,7 +1107,7 @@ ftvt_error(_("Corrupt volume input data\n")); return -1; } - GET_STRING_VALUE(SIGNATURE, volume->ftvt_sig, 4, + GET_STRING_VALUE(SIGNATURE, (char *)volume->ftvt_sig, 4, { int i; @@ -1098,38 +1134,38 @@ GET_SINGLE_VALUE_ACTION(END, i, volume->end, end_seen = 1); GET_SINGLE_VALUE_ACTION (NUM_SEGMENTS, i, volume->num_segments, num_segments_seen = 1); - GET_STRING_VALUE(DESCRIPTION, volume->ftvt_desc, 44, + GET_STRING_VALUE(DESCRIPTION, (char *)volume->ftvt_desc, 44, memset(volume->ftvt_desc + strlen(value), ' ', 44 - strlen(value))); GET_STRING_VALUE(DATE, NULL, 1024, { if (ftvt_set_date(volumes, maxnum, value, num)) { return -1; } }); - GET_SINGLE_VALUE(FLAG_VENDOR_SPECIFIC, i, - volume->entry.vendor_specific); + GET_SINGLE_BITFIELD_VALUE(FLAG_VENDOR_SPECIFIC, (char *)i, + volume->entry.vendor_specific); GET_SINGLE_VALUE(QIC_MAJOR, i, volume->entry.ext.qic113.major); GET_SINGLE_VALUE(QIC_MINOR, i, volume->entry.ext.qic113.minor); - GET_STRING_VALUE(VENDOR_DATA, &volume->bytes[56], 72, /**/); + GET_STRING_VALUE(VENDOR_DATA, (char *)&volume->bytes[56], 72, /**/); if (volume->entry.vendor_specific && (volume->fmt_code == fmt_big || (volume->fmt_code != fmt_big && volume->entry.ext.qic113.major != 113))) { continue; /* ignore all other tags */ } - GET_SINGLE_VALUE(FLAG_MULTI_CARTRIDGE, i, - volume->entry.multi_cartridge); - GET_SINGLE_VALUE(FLAG_NOT_VERIFIED, i, - volume->entry.not_verified); - GET_SINGLE_VALUE(FLAG_REDIRECTION_INHIBIT, i, - volume->entry.inhibit_redirection); - GET_SINGLE_VALUE(FLAG_SEGMENT_SPANNING, i, - volume->entry.segment_spanning); - GET_SINGLE_VALUE(FLAG_DIRECTORY_LAST, i, - volume->entry.directory_last); - GET_SINGLE_VALUE(FLAG_RESERVED_6, i, - volume->entry.fl_reserved_6); - GET_SINGLE_VALUE(FLAG_RESERVED_7, i, - volume->entry.fl_reserved_7); + GET_SINGLE_BITFIELD_VALUE(FLAG_MULTI_CARTRIDGE, i, + volume->entry.multi_cartridge); + GET_SINGLE_BITFIELD_VALUE(FLAG_NOT_VERIFIED, i, + volume->entry.not_verified); + GET_SINGLE_BITFIELD_VALUE(FLAG_REDIRECTION_INHIBIT, i, + volume->entry.inhibit_redirection); + GET_SINGLE_BITFIELD_VALUE(FLAG_SEGMENT_SPANNING, i, + volume->entry.segment_spanning); + GET_SINGLE_BITFIELD_VALUE(FLAG_DIRECTORY_LAST, i, + volume->entry.directory_last); + GET_SINGLE_BITFIELD_VALUE(FLAG_RESERVED_6, i, + volume->entry.fl_reserved_6); + GET_SINGLE_BITFIELD_VALUE(FLAG_RESERVED_7, i, + volume->entry.fl_reserved_7); GET_SINGLE_VALUE(MULTI_CARTRIDGE_COUNT, i, volume->entry.m_no); GET_SINGLE_VALUE(DIRECTORY_SIZE, i, @@ -1188,7 +1224,8 @@ while (isspace(*p)) p++; while (*p != '\0' && !isspace(*p)) p++; } }); - GET_STRING_VALUE(SOURCE_DRIVE, volume->entry.source_drive, 16, + GET_STRING_VALUE(SOURCE_DRIVE, + (char*)volume->entry.source_drive, 16, /**/); break; case xtbl: @@ -1507,7 +1544,7 @@ ftvt_error(_("Volume number too big or negative: %d\n"), vtbl_no); return -1; } - strncpy(volumes[vtbl_no].ftvt_desc, desc, 44); + strncpy((char *)volumes[vtbl_no].ftvt_desc, desc, 44); if ((len = strlen(desc)) < 44) { memset(volumes[vtbl_no].ftvt_desc + len, ' ', 44 - len); } -- Roger Leigh Printing on GNU/Linux? http://gimp-print.sourceforge.net/ Debian GNU/Linux http://www.debian.org/ GPG Public Key: 0x25BFB848. Please sign and encrypt your mail. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]