bug-parted
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bug in endianess conversion in disk_sun.c


From: Sven Luther
Subject: Re: bug in endianess conversion in disk_sun.c
Date: Tue, 16 Dec 2003 12:20:49 +0100
User-agent: Mutt/1.5.4i

On Tue, Dec 16, 2003 at 12:06:48PM +0100, Jakub Bogusz wrote:
> Hello,
> 
> I found a bug in endianess conversion in disk_sun.c.
> SUN_DISK_MAGIC is 16 bits long, but was converted as 32-bit.
> It caused warning (and error because of -Werror) when compiling using
> gcc 3.x on big-endians.
> 
> Patch attached.
> 
> 
> -- 
> Jakub Bogusz    http://cyber.cs.net.pl/~qboosh/
> PLD Linux       http://www.pld-linux.org/

> --- parted-1.6.6/libparted/disk_sun.c.orig    2003-06-30 00:48:11.000000000 
> +0000
> +++ parted-1.6.6/libparted/disk_sun.c 2003-12-15 09:17:03.000000000 +0000
> @@ -354,7 +354,7 @@
>       if (!ped_device_read (disk->dev, &old_label, 0, 1))
>               return;
>       if (old_label.info [0]
> -         && old_label.magic == PED_CPU_TO_LE32 (SUN_DISK_MAGIC))
> +         && old_label.magic == PED_CPU_TO_LE16 (SUN_DISK_MAGIC))
>               memcpy (&sun_specific->raw_label, &old_label, 512);
>  }

Notice that this patch :

--- parted-1.6.6.orig/libparted/disk_sun.c
+++ parted-1.6.6/libparted/disk_sun.c
@@ -354,7 +354,7 @@
        if (!ped_device_read (disk->dev, &old_label, 0, 1))
                return;
        if (old_label.info [0]
-           && old_label.magic == PED_CPU_TO_LE32 (SUN_DISK_MAGIC))
+           && PED_BE16_TO_CPU (old_label.magic) == SUN_DISK_MAGIC)
                memcpy (&sun_specific->raw_label, &old_label, 512);
 }


already applied in the debian package of parted 1.6.6 (together with
other gcc 3.3 fixes i should maybe have sent here too), is maybe a
preferable patch. i don't remember exactly why, but gcc complained some
when doing it your way, something about comparison between values of
different signedness if i remember well, but then it was in July.

Friendly,

Sven Luther




reply via email to

[Prev in Thread] Current Thread [Next in Thread]