[Parted-maintainers] Bug#292937: parted: FTBFS (amd64/gcc-4.0): static declaration of 'ped_constraint_none' follows non-static declaration
Andreas Jochens
Andreas Jochens <aj@andaco.de>, 292937@bugs.debian.org
Mon, 31 Jan 2005 11:49:30 +0100
Package: parted
Severity: normal
Tags: patch
When building 'parted' on amd64 with gcc-4.0,
I get the following error:
x86_64-linux-gcc -DHAVE_CONFIG_H -I. -I../../../libparted/fs_fat -I../.. -I../../../include -g -O2 -D_REENTRANT -D_FILE_OFFSET_BITS=no -DLOCALEDIR=\"/usr/share/locale\" -DLOCALEDIR=\"/usr/share/locale\" -W -Wall -Wno-unused -Wno-switch -Wno-format -Werror -MT context.lo -MD -MP -MF .deps/context.Tpo -c ../../../libparted/fs_fat/context.c -fPIC -DPIC -o .libs/context.o
cc1: warnings being treated as errors
../../../libparted/fs_fat/context.c: In function 'fat_op_context_new':
../../../libparted/fs_fat/context.c:94: warning: pointer targets in assignment differ in signedness
make[4]: *** [context.lo] Error 1
make[4]: Leaving directory `/parted-1.6.21/build-deb/libparted/fs_fat'
There are some more of those warnings. After fixing those warnings or
switching them off with 'CONFFLAGS += --disable-Werror' in debian/rules,
I get the following error:
x86_64-linux-gcc -DHAVE_CONFIG_H -I. -I../../libparted -I.. -I../../include -g-O2 -D_REENTRANT -D_FILE_OFFSET_BITS=no -DLOCALEDIR=\"/usr/share/locale\" -DLOCALEDIR=\"/usr/share/locale\" -W -Wall -Wno-unused -Wno-switch -Wno-format -MT constraint.lo -MD -MP -MF .deps/constraint.Tpo -c ../../libparted/constraint.c -fPIC -DPIC -o .libs/constraint.o
../../libparted/constraint.c:23: error: static declaration of 'ped_constraint_none' follows non-static declaration
../../include/parted/constraint.h:96: error: previous declaration of 'ped_constraint_none' was here
make[4]: *** [constraint.lo] Error 1
make[4]: Leaving directory `/srv/dbuild/tmp/parted-1.6.21/build-deb/libparted'
With the attached patch 'parted' can be compiled
on amd64 using gcc-4.0.
The patch adds a new file 'debian/patches/gcc4-fix.dpatch'.
It also corrects two causes for gcc4 warnings in 'debian/patches/hfs.dpatch'.
The last one of those two corrections replaces 'node' with 'node_1'.
This looks like a good example where the stricter warnings of gcc4 serve
to find a real error in the code.
Regards
Andreas Jochens
diff -urN ../tmp-orig/parted-1.6.21/debian/patches/00list ./debian/patches/00list
--- ../tmp-orig/parted-1.6.21/debian/patches/00list 2005-01-31 11:26:53.644278220 +0100
+++ ./debian/patches/00list 2005-01-31 11:18:56.722381052 +0100
@@ -2,6 +2,7 @@
doc-package
reiserfs-libname
# Patch susceptible to be merged upstrea,
+gcc4-fix
hfs
errors-to-stderr
devfs
diff -urN ../tmp-orig/parted-1.6.21/debian/patches/gcc4-fix.dpatch ./debian/patches/gcc4-fix.dpatch
--- ../tmp-orig/parted-1.6.21/debian/patches/gcc4-fix.dpatch 1970-01-01 01:00:00.000000000 +0100
+++ ./debian/patches/gcc4-fix.dpatch 2005-01-31 11:18:56.722381052 +0100
@@ -0,0 +1,147 @@
+#! /bin/sh -e
+## gcc4-fix.dpatch by Andres Jochens <aj@andaco.de>
+##
+## DP: Fixes for compilation with gcc4
+
+. $(dirname $0)/DPATCH
+
+@DPATCH@
+diff -urN ../tmp-orig/parted-1.6.21/include/parted/constraint.h ./include/parted/constraint.h
+--- ../tmp-orig/parted-1.6.21/include/parted/constraint.h 2005-01-04 17:09:50.000000000 +0100
++++ ./include/parted/constraint.h 2005-01-31 11:01:24.151652795 +0100
+@@ -93,7 +93,5 @@
+ extern PedConstraint*
+ ped_constraint_exact (const PedGeometry* geom);
+
+-extern const PedConstraint* ped_constraint_none;
+-
+ #endif /* PED_CONSTRAINT_H_INCLUDED */
+
+diff -urN ../tmp-orig/parted-1.6.21/libparted/disk_amiga.c ./libparted/disk_amiga.c
+--- ../tmp-orig/parted-1.6.21/libparted/disk_amiga.c 2005-01-06 00:16:52.000000000 +0100
++++ ./libparted/disk_amiga.c 2005-01-31 11:10:40.786155918 +0100
+@@ -813,7 +813,7 @@
+ partition->pb_Flags = PED_CPU_TO_BE32(0);
+ /* TODO : use a scheme including the device name and the
+ * partition number, if it is possible */
+- _amiga_set_bstr("dhx", partition->pb_DriveName, 32);
++ _amiga_set_bstr("dhx", (char*)partition->pb_DriveName, 32);
+
+ partition->de_TableSize = PED_CPU_TO_BE32(19);
+ partition->de_SizeBlock = PED_CPU_TO_BE32(128);
+@@ -1001,7 +1001,7 @@
+ PED_ASSERT (part->disk_specific != NULL, return);
+
+ partition = PART(part->disk_specific);
+- _amiga_set_bstr(name, partition->pb_DriveName, 32);
++ _amiga_set_bstr(name, (char*)partition->pb_DriveName, 32);
+ }
+ static const char*
+ amiga_partition_get_name (const PedPartition* part)
+@@ -1013,7 +1013,7 @@
+
+ partition = PART(part->disk_specific);
+
+- return _amiga_get_bstr(partition->pb_DriveName);
++ return _amiga_get_bstr((char*)partition->pb_DriveName);
+ }
+
+ static PedConstraint*
+diff -urN ../tmp-orig/parted-1.6.21/libparted/disk_gpt.c ./libparted/disk_gpt.c
+--- ../tmp-orig/parted-1.6.21/libparted/disk_gpt.c 2005-01-04 17:09:51.000000000 +0100
++++ ./libparted/disk_gpt.c 2005-01-31 11:03:22.761746894 +0100
+@@ -382,8 +382,8 @@
+ ped_geometry_init (&gpt_disk_data->data_area, dev, data_start,
+ data_end - data_start + 1);
+ gpt_disk_data->entry_count = GPT_DEFAULT_PARTITION_ENTRIES;
+- uuid_generate ((char*) &gpt_disk_data->uuid);
+- swap_uuid_and_efi_guid((char*)(&gpt_disk_data->uuid));
++ uuid_generate ((unsigned char*) &gpt_disk_data->uuid);
++ swap_uuid_and_efi_guid((unsigned char*)(&gpt_disk_data->uuid));
+ return disk;
+
+ error_free_disk:
+@@ -872,8 +872,8 @@
+ gpt_part_data->raid = 0;
+ gpt_part_data->boot = 0;
+ gpt_part_data->hp_service = 0;
+- uuid_generate ((char*) &gpt_part_data->uuid);
+- swap_uuid_and_efi_guid((char*)(&gpt_part_data->uuid));
++ uuid_generate ((unsigned char*) &gpt_part_data->uuid);
++ swap_uuid_and_efi_guid((unsigned char*)(&gpt_part_data->uuid));
+ strcpy (gpt_part_data->name, "");
+ return part;
+
+diff -urN ../tmp-orig/parted-1.6.21/libparted/disk_pc98.c ./libparted/disk_pc98.c
+--- ../tmp-orig/parted-1.6.21/libparted/disk_pc98.c 2004-08-15 14:34:39.000000000 +0200
++++ ./libparted/disk_pc98.c 2005-01-31 11:04:25.695593152 +0100
+@@ -381,7 +381,7 @@
+ pc98_data->boot = GET_BIT(raw_part->mid, 7);
+ pc98_data->hidden = !GET_BIT(raw_part->sid, 7);
+
+- ped_partition_set_name (part, raw_part->name);
++ ped_partition_set_name (part, (char*) raw_part->name);
+
+ pc98_data->ipl_sector = chs_to_sector (
+ disk->dev,
+diff -urN ../tmp-orig/parted-1.6.21/libparted/disk_sun.c ./libparted/disk_sun.c
+--- ../tmp-orig/parted-1.6.21/libparted/disk_sun.c 2005-01-06 00:16:52.000000000 +0100
++++ ./libparted/disk_sun.c 2005-01-31 11:04:51.541601789 +0100
+@@ -201,7 +201,7 @@
+ PED_CPU_TO_BE32(hw_geom->cylinders * cyl_size);
+
+ /* Now a neato string to describe this label */
+- snprintf(label->info, sizeof(label->info) - 1,
++ snprintf((char*)label->info, sizeof(label->info) - 1,
+ "GNU Parted Custom cyl %d alt 2 hd %d sec %d",
+ PED_BE16_TO_CPU(label->ncyl), PED_BE16_TO_CPU(label->ntrks),
+ PED_BE16_TO_CPU(label->nsect));
+diff -urN ../tmp-orig/parted-1.6.21/libparted/fs_fat/context.c ./libparted/fs_fat/context.c
+--- ../tmp-orig/parted-1.6.21/libparted/fs_fat/context.c 2002-01-01 17:17:02.000000000 +0100
++++ ./libparted/fs_fat/context.c 2005-01-31 10:53:28.604490139 +0100
+@@ -90,7 +90,7 @@
+ goto error;
+
+ ctx->buffer_frags = old_fs_info->buffer_sectors / ctx->frag_sectors;
+- ctx->buffer_map = (FatCluster*) ped_malloc (sizeof (FatFragment)
++ ctx->buffer_map = (FatFragment*) ped_malloc (sizeof (FatFragment)
+ * ctx->buffer_frags);
+ if (!ctx->buffer_map)
+ goto error_free_ctx;
+diff -urN ../tmp-orig/parted-1.6.21/libparted/fs_fat/count.c ./libparted/fs_fat/count.c
+--- ../tmp-orig/parted-1.6.21/libparted/fs_fat/count.c 2002-05-17 14:16:16.000000000 +0200
++++ ./libparted/fs_fat/count.c 2005-01-31 10:54:42.675185657 +0100
+@@ -188,7 +188,8 @@
+ fs_info->total_dir_clusters++;
+
+ fs_info->cluster_info [clst].flag = flag;
+- fs_info->cluster_info [clst].units_used = 64;
++ fs_info->cluster_info [clst].units_used = 63;
++ fs_info->cluster_info [clst].units_used++;
+ }
+
+ if (size
+diff -urN ../tmp-orig/parted-1.6.21/libparted/fs_fat/traverse.c ./libparted/fs_fat/traverse.c
+--- ../tmp-orig/parted-1.6.21/libparted/fs_fat/traverse.c 2002-04-08 01:06:22.000000000 +0200
++++ ./libparted/fs_fat/traverse.c 2005-01-31 10:57:17.638259293 +0100
+@@ -347,7 +347,7 @@
+ int i;
+ char *src;
+
+- src = dir_entry->name;
++ src = (char*) dir_entry->name;
+
+ for (i=0; i<8; i++) {
+ if (src[i] == ' ' || src[i] == 0) break;
+diff -urN ../tmp-orig/parted-1.6.21/libparted/linux.c ./libparted/linux.c
+--- ../tmp-orig/parted-1.6.21/libparted/linux.c 2005-01-16 02:01:57.000000000 +0100
++++ ./libparted/linux.c 2005-01-31 11:12:59.321402086 +0100
+@@ -519,7 +519,7 @@
+ /* hdi.model is not guaranteed to be NULL terminated */
+ memcpy (hdi_buf, hdi.model, 40);
+ hdi_buf[40] = '\0';
+- dev->model = strip_name (hdi.model);
++ dev->model = strip_name ((char*)hdi.model);
+ }
+
+ if (!_device_probe_geometry (dev))
diff -urN ../tmp-orig/parted-1.6.21/debian/patches/hfs.dpatch ./debian/patches/hfs.dpatch
--- ../tmp-orig/parted-1.6.21/debian/patches/hfs.dpatch 2005-01-31 11:26:53.641278799 +0100
+++ ./debian/patches/hfs.dpatch 2005-01-31 11:26:44.183105355 +0100
@@ -6552,7 +6552,7 @@
+ new_start = hfs_do_move(fs, ptr_fblock, ptr_to_fblock, cache, ref);
+ if (new_start == -1) return -1;
+ if (new_start > old_start) { /* detect 2 pass reloc */
-+ new_start = hfs_do_move(fs,&new_start,ptr_to_fblock,cache,ref);
++ new_start = hfs_do_move(fs,(unsigned*)&new_start,ptr_to_fblock,cache,ref);
+ if (new_start == -1 || new_start > old_start) return -1;
+ }
+ return 1;
@@ -7471,7 +7471,7 @@
+ uint8_t node_1[PED_SECTOR_SIZE];
+ uint8_t* node;
+ HfsPHeaderRecord* header;
-+ HfsPNodeDescriptor* desc = (HfsPNodeDescriptor*) node;
++ HfsPNodeDescriptor* desc = (HfsPNodeDescriptor*) node_1;
+ HfsPExtentKey* extent_key;
+ HfsPExtDescriptor* extent;
+ unsigned int leaf_node, record_number;