From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 14 03:04:15 2011 Received: (at submit) by debbugs.gnu.org; 14 Jul 2011 07:04:15 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QhFy2-0008Qw-Dh for submit@debbugs.gnu.org; Thu, 14 Jul 2011 03:04:14 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QhFy0-0008Qj-0a for submit@debbugs.gnu.org; Thu, 14 Jul 2011 03:04:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QhFxt-0001Q4-MQ for submit@debbugs.gnu.org; Thu, 14 Jul 2011 03:04:06 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,HTML_MESSAGE, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([140.186.70.17]:33661) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QhFxt-0001Q0-L0 for submit@debbugs.gnu.org; Thu, 14 Jul 2011 03:04:05 -0400 Received: from eggs.gnu.org ([140.186.70.92]:60574) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QhFxs-0000Nn-Ea for bug-coreutils@gnu.org; Thu, 14 Jul 2011 03:04:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QhFxr-0001PV-8e for bug-coreutils@gnu.org; Thu, 14 Jul 2011 03:04:04 -0400 Received: from moutng.kundenserver.de ([212.227.17.10]:56848) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QhFxq-0001PJ-QV for bug-coreutils@gnu.org; Thu, 14 Jul 2011 03:04:03 -0400 Received: from DualCore (dsdf-4db52e8d.pool.mediaWays.net [77.181.46.141]) by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis) id 0Lkgke-1RFDCn0MwW-00aXLP; Thu, 14 Jul 2011 09:04:01 +0200 From: "Joachim Schmitz" To: Subject: coreutils-8.12: fiemap.h uses "struct fiemap_extent fm_extents[0];" Date: Thu, 14 Jul 2011 09:03:56 +0200 Message-ID: <003801cc41f4$33196630$994c3290$@schmitz-digital.de> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0039_01CC4204.F6A48020" X-Mailer: Microsoft Outlook 14.0 Thread-Index: AcxB8+H92kG8gSpfQXCBZGY0sS2uvQ== Content-Language: de X-Provags-ID: V02:K0:DfTHiHnU1+YBtf6GYEJnytV1TNPFPlFKsvufHNI2gFR OtAz2DeFb2CphwwSMtWsu7gY1eE2oFSDe9lFAL2oqWcZ8KP97o BZHG4GUReeDl4fEIInOnnsdsCSHiIpksfB+6zy/7wwlTDSz0hk R6BqRK8H+APLZCBkzwaYxVBSitazHGuAXQ/PgqdKwjxMbs/nlj KWbnqAB/OSAVLdIEerI7yde6i9A3JITyDY84N+hulE= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.17 X-Spam-Score: -5.3 (-----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.3 (-----) This is a multipart message in MIME format. ------=_NextPart_000_0039_01CC4204.F6A48020 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi folks fiemap.h uses struct fiemap_extent fm_extents[0]; My compiler (HP NonStop) disallows that. The following would be allowed though: struct fiemap_extent fm_extents[]; Bye, Jojo ------=_NextPart_000_0039_01CC4204.F6A48020 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hi folks

 

fiemap.h uses

 

struct fiemap_extent = fm_extents[0];

 

My compiler (HP NonStop) disallows that. The following = would be allowed though:

 

struct fiemap_extent fm_extents[];

 

Bye, = Jojo

------=_NextPart_000_0039_01CC4204.F6A48020-- From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 14 07:47:31 2011 Received: (at 9077) by debbugs.gnu.org; 14 Jul 2011 11:47:31 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QhKO7-00079C-70 for submit@debbugs.gnu.org; Thu, 14 Jul 2011 07:47:31 -0400 Received: from mail1.slb.deg.dub.stisp.net ([84.203.253.98]) by debbugs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1QhKO1-00078x-Ik for 9077@debbugs.gnu.org; Thu, 14 Jul 2011 07:47:25 -0400 Received: (qmail 96944 invoked from network); 14 Jul 2011 11:47:15 -0000 Received: from unknown (HELO ?192.168.2.25?) (84.203.137.218) by mail1.slb.deg.dub.stisp.net with SMTP; 14 Jul 2011 11:47:15 -0000 Message-ID: <4E1ED6D5.2000801@draigBrady.com> Date: Thu, 14 Jul 2011 12:45:25 +0100 From: =?ISO-8859-1?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3 MIME-Version: 1.0 To: Joachim Schmitz Subject: Re: bug#9077: coreutils-8.12: fiemap.h uses "struct fiemap_extent fm_extents[0]; " References: <003801cc41f4$33196630$994c3290$@schmitz-digital.de> In-Reply-To: <003801cc41f4$33196630$994c3290$@schmitz-digital.de> X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: 9077 Cc: 9077@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) On 14/07/11 08:03, Joachim Schmitz wrote: > Hi folks > > fiemap.h uses > > struct fiemap_extent fm_extents[0]; > > My compiler (HP NonStop) disallows that. The following would be allowed > though: > > struct fiemap_extent fm_extents[]; The non standard "zero length array" syntax was copied from the linux kernel headers. Changing this to a C99 flexible array as you suggest, should be fine according to the constraints listed here: http://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html It results in identical object files with GCC here. I'll apply the above in your name. cheers, Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 14 18:50:17 2011 Received: (at 9077) by debbugs.gnu.org; 14 Jul 2011 22:50:17 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QhUjY-00043f-Q5 for submit@debbugs.gnu.org; Thu, 14 Jul 2011 18:50:17 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QhUjW-00043T-2I for 9077@debbugs.gnu.org; Thu, 14 Jul 2011 18:50:15 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id D9CED39E80F0; Thu, 14 Jul 2011 15:50:07 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yVkWAcJwU7FX; Thu, 14 Jul 2011 15:50:07 -0700 (PDT) Received: from [131.179.64.200] (Penguin.CS.UCLA.EDU [131.179.64.200]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 54E7F39E80E0; Thu, 14 Jul 2011 15:50:07 -0700 (PDT) Message-ID: <4E1F729F.4@cs.ucla.edu> Date: Thu, 14 Jul 2011 15:50:07 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110621 Fedora/3.1.11-1.fc14 Thunderbird/3.1.11 MIME-Version: 1.0 To: =?ISO-8859-1?Q?P=E1draig_Brady?= Subject: Re: bug#9077: coreutils-8.12: fiemap.h uses "struct fiemap_extent fm_extents[0]; " References: <003801cc41f4$33196630$994c3290$@schmitz-digital.de> <4E1ED6D5.2000801@draigBrady.com> In-Reply-To: <4E1ED6D5.2000801@draigBrady.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -3.1 (---) X-Debbugs-Envelope-To: 9077 Cc: Joachim Schmitz , 9077@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.1 (---) On 07/14/11 04:45, P=E1draig Brady wrote: > The non standard "zero length array" syntax was copied from > the linux kernel headers. Changing this to a C99 flexible array > as you suggest, should be fine according to the constraints listed here= : Won't this break non-GCC compilers that don't support C99 flexible arrays? Instead, how about this patch? If I understand things correctly, it should fix the problem on NonStop, and should also work with pre-C99 non-GCC compilers. diff --git a/src/fiemap.h b/src/fiemap.h index 1938c74..e7243b4 100644 --- a/src/fiemap.h +++ b/src/fiemap.h @@ -51,8 +51,9 @@ struct fiemap =20 uint32_t fm_reserved; =20 - /* Array of mapped extents(out). */ - struct fiemap_extent fm_extents[0]; + /* Array of mapped extents(out). + The actual size is given by fm_extent_count. */ + struct fiemap_extent fm_extents[1]; }; =20 /* The maximum offset can be mapped for a file. */ From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 14 21:13:09 2011 Received: (at 9077) by debbugs.gnu.org; 15 Jul 2011 01:13:10 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QhWxp-0008Ft-Dt for submit@debbugs.gnu.org; Thu, 14 Jul 2011 21:13:09 -0400 Received: from mail1.slb.deg.dub.stisp.net ([84.203.253.98]) by debbugs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1QhWxn-0008FW-KE for 9077@debbugs.gnu.org; Thu, 14 Jul 2011 21:13:08 -0400 Received: (qmail 22842 invoked from network); 15 Jul 2011 01:13:01 -0000 Received: from unknown (HELO ?192.168.2.25?) (84.203.137.218) by mail1.slb.deg.dub.stisp.net with SMTP; 15 Jul 2011 01:13:01 -0000 Message-ID: <4E1F93AC.7030101@draigBrady.com> Date: Fri, 15 Jul 2011 02:11:08 +0100 From: =?ISO-8859-1?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3 MIME-Version: 1.0 To: Paul Eggert Subject: Re: bug#9077: coreutils-8.12: fiemap.h uses "struct fiemap_extent fm_extents[0]; " References: <003801cc41f4$33196630$994c3290$@schmitz-digital.de> <4E1ED6D5.2000801@draigBrady.com> <4E1F729F.4@cs.ucla.edu> In-Reply-To: <4E1F729F.4@cs.ucla.edu> X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: 9077 Cc: Joachim Schmitz , 9077@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) On 14/07/11 23:50, Paul Eggert wrote: > On 07/14/11 04:45, Pádraig Brady wrote: >> The non standard "zero length array" syntax was copied from >> the linux kernel headers. Changing this to a C99 flexible array >> as you suggest, should be fine according to the constraints listed here: > > Won't this break non-GCC compilers that don't support > C99 flexible arrays? Yes. But we require C99, and it would be interesting to see what features we could rely on going forward. I had checked with solaris compilers which support this since 2004 at least. Though saying that, the single element hack isn't too bad and might allow some other platform to build without issue. > Instead, how about this patch? If I understand things correctly, > it should fix the problem on NonStop, and should also work with > pre-C99 non-GCC compilers. feel free to push that cheers, Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Fri Jul 15 01:08:48 2011 Received: (at 9077-done) by debbugs.gnu.org; 15 Jul 2011 05:08:48 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Qhads-0004z7-5j for submit@debbugs.gnu.org; Fri, 15 Jul 2011 01:08:48 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Qhadp-0004yu-Ce for 9077-done@debbugs.gnu.org; Fri, 15 Jul 2011 01:08:46 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 3E5F939E80F7; Thu, 14 Jul 2011 22:08:39 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CBfqyoY-9VlY; Thu, 14 Jul 2011 22:08:38 -0700 (PDT) Received: from [192.168.1.10] (pool-71-189-109-235.lsanca.fios.verizon.net [71.189.109.235]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id C785E39E80F2; Thu, 14 Jul 2011 22:08:38 -0700 (PDT) Message-ID: <4E1FCB56.8070101@cs.ucla.edu> Date: Thu, 14 Jul 2011 22:08:38 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110516 Thunderbird/3.1.10 MIME-Version: 1.0 To: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= Subject: Re: bug#9077: coreutils-8.12: fiemap.h uses "struct fiemap_extent fm_extents[0]; " References: <003801cc41f4$33196630$994c3290$@schmitz-digital.de> <4E1ED6D5.2000801@draigBrady.com> <4E1F729F.4@cs.ucla.edu> <4E1F93AC.7030101@draigBrady.com> In-Reply-To: <4E1F93AC.7030101@draigBrady.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -3.0 (---) X-Debbugs-Envelope-To: 9077-done Cc: 9077-done@debbugs.gnu.org, Joachim Schmitz X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.0 (---) On 07/14/11 18:11, P=C3=A1draig Brady wrote: > feel free to push that OK, thanks, done. From debbugs-submit-bounces@debbugs.gnu.org Fri Jul 15 05:51:32 2011 Received: (at 9077-done) by debbugs.gnu.org; 15 Jul 2011 09:51:32 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Qhf3U-0002sC-1J for submit@debbugs.gnu.org; Fri, 15 Jul 2011 05:51:32 -0400 Received: from mail1.slb.deg.dub.stisp.net ([84.203.253.98]) by debbugs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1Qhf3R-0002rz-Ho for 9077-done@debbugs.gnu.org; Fri, 15 Jul 2011 05:51:30 -0400 Received: (qmail 89446 invoked from network); 15 Jul 2011 09:51:23 -0000 Received: from unknown (HELO ?192.168.2.25?) (84.203.137.218) by mail1.slb.deg.dub.stisp.net with SMTP; 15 Jul 2011 09:51:23 -0000 Message-ID: <4E200D29.7070608@draigBrady.com> Date: Fri, 15 Jul 2011 10:49:29 +0100 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3 MIME-Version: 1.0 To: Paul Eggert Subject: Re: bug#9077: coreutils-8.12: fiemap.h uses "struct fiemap_extent fm_extents[0]; " References: <003801cc41f4$33196630$994c3290$@schmitz-digital.de> <4E1ED6D5.2000801@draigBrady.com> <4E1F729F.4@cs.ucla.edu> <4E1F93AC.7030101@draigBrady.com> <4E1FCB56.8070101@cs.ucla.edu> In-Reply-To: <4E1FCB56.8070101@cs.ucla.edu> X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: 9077-done Cc: 9077-done@debbugs.gnu.org, Joachim Schmitz X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) On 15/07/11 06:08, Paul Eggert wrote: > On 07/14/11 18:11, Pádraig Brady wrote: >> feel free to push that > > OK, thanks, done. And now that I look at the code a little longer, I think that the sizeof calculations need to be adjusted in extent_scan_read() too. But that's a step too far I think. So I'm going to apply this. cheers, Pádraig. commit 1ab94c86ca409c2800ce39e2934538c1eed2af10 Author: Pádraig Brady Date: Fri Jul 15 09:51:35 2011 +0100 build: avoid a fiemap compile failure on some systems * src/fiemap.h (struct fiemap): Adjust the previous change to the fiemap_extents array, which would also require changes to the sizeof calculations in extent_scan_read(). Instead, only declare the fiemap_extents zero length array on linux, which is the only platform that references this member. This avoids a compilation failure on systems that don't support this non standard construct. We don't use the equivalent C99 flexible array construct so as to have maximum portability. * src/extent-scan.c: Cleanup. Remove a redundant #ifndef. diff --git a/src/extent-scan.c b/src/extent-scan.c index 48dd564..37445b8 100644 --- a/src/extent-scan.c +++ b/src/extent-scan.c @@ -24,11 +24,9 @@ #include "system.h" #include "extent-scan.h" +#include "fiemap.h" #include "xstrtol.h" -#ifndef HAVE_FIEMAP -# include "fiemap.h" -#endif /* Work around Linux kernel issues on BTRFS and EXT4 before 2.6.39. FIXME: remove in 2013, or whenever we're pretty confident diff --git a/src/fiemap.h b/src/fiemap.h index e7243b4..3b35297 100644 --- a/src/fiemap.h +++ b/src/fiemap.h @@ -52,8 +52,12 @@ struct fiemap uint32_t fm_reserved; /* Array of mapped extents(out). - The actual size is given by fm_extent_count. */ - struct fiemap_extent fm_extents[1]; + This is protected by the ifdef because it uses non standard + zero length arrays. Note C99 has the equivalent flexible arrays, + but we don't use those for maximum portability to older systems. */ +#ifdef __linux__ + struct fiemap_extent fm_extents[0]; +#endif }; /* The maximum offset can be mapped for a file. */ From debbugs-submit-bounces@debbugs.gnu.org Fri Jul 15 18:45:45 2011 Received: (at 9077-done) by debbugs.gnu.org; 15 Jul 2011 22:45:46 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Qhr8i-0005Gy-Rr for submit@debbugs.gnu.org; Fri, 15 Jul 2011 18:45:45 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Qhr8f-0005Gj-3j for 9077-done@debbugs.gnu.org; Fri, 15 Jul 2011 18:45:42 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 2FFB439E80E0; Fri, 15 Jul 2011 15:45:35 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ivO9eYZ5Z4IE; Fri, 15 Jul 2011 15:45:31 -0700 (PDT) Received: from [192.168.1.10] (pool-71-189-109-235.lsanca.fios.verizon.net [71.189.109.235]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id A52DA39E80F2; Fri, 15 Jul 2011 15:45:31 -0700 (PDT) Message-ID: <4E20C30B.7030305@cs.ucla.edu> Date: Fri, 15 Jul 2011 15:45:31 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110516 Thunderbird/3.1.10 MIME-Version: 1.0 To: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= Subject: Re: bug#9077: coreutils-8.12: fiemap.h uses "struct fiemap_extent fm_extents[0]; " References: <003801cc41f4$33196630$994c3290$@schmitz-digital.de> <4E1ED6D5.2000801@draigBrady.com> <4E1F729F.4@cs.ucla.edu> <4E1F93AC.7030101@draigBrady.com> <4E1FCB56.8070101@cs.ucla.edu> <4E200D29.7070608@draigBrady.com> In-Reply-To: <4E200D29.7070608@draigBrady.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -3.0 (---) X-Debbugs-Envelope-To: 9077-done Cc: 9077-done@debbugs.gnu.org, Joachim Schmitz X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.0 (---) On 07/15/11 02:49, P=C3=A1draig Brady wrote: > +#ifdef __linux__ > + struct fiemap_extent fm_extents[0]; > +#endif This assumes that all GNU/Linux compiles will use a compiler that allows size-zero arrays; also, it assumes that sizeof (struct fiemap) =3D=3D offsetof (struct fiemap, fm_extents). Although both assumptions are probably portable in practice in this particular case, it's better to avoid them, if avoiding them is easy. This will help future-proof the code if we alter the data structures, as altering them might cause problems such as what I recently encountered in GNU Emacs's C code. How about the following further patch? It should do the trick. build: more-portable fix for fiemap compile failure * src/extent-scan.c: Include , for offsetof. (extent_scan_read): Don't assume that sizeof (struct fiemap) is equal to offsetof (struct fiemap, fm_extents). Although this should be a portable assumption in practice for this particular case, the C standard doesn't guarantee it, and we might as well do it the right way. As it happens I recently got burned by this exact issue in the source code for GNU Emacs; see . * src/fiemap.h (struct fiemap.fm_extents): Change size back to 1. diff --git a/src/extent-scan.c b/src/extent-scan.c index 37445b8..434258f 100644 --- a/src/extent-scan.c +++ b/src/extent-scan.c @@ -17,6 +17,7 @@ Written by Jie Liu (jeff.liu@oracle.com). */ #include +#include #include #include #include @@ -96,7 +97,10 @@ extent_scan_read (struct extent_scan *scan) union { struct fiemap f; char c[4096]; } fiemap_buf; struct fiemap *fiemap =3D &fiemap_buf.f; struct fiemap_extent *fm_extents =3D &fiemap->fm_extents[0]; - enum { count =3D (sizeof fiemap_buf - sizeof *fiemap)/sizeof *fm_e= xtents }; + enum { + size =3D sizeof fiemap_buf - offsetof (struct fiemap, fm_extents= ), + count =3D size / sizeof *fm_extents + }; verify (count > 1); /* This is required at least to initialize fiemap->fm_start, diff --git a/src/fiemap.h b/src/fiemap.h index 15ddff9..60561d3 100644 --- a/src/fiemap.h +++ b/src/fiemap.h @@ -52,12 +52,9 @@ struct fiemap uint32_t fm_reserved; /* Array of mapped extents(out). - This is protected by the ifdef because it uses non standard - zero length arrays. Note C99 has the equivalent flexible arrays, - but we don't use those for maximum portability to older systems. *= / -# ifdef __linux__ - struct fiemap_extent fm_extents[0]; -# endif + This uses a size 1 array to be compatible with compilers that + don't support C99's flexible arrays or GCC's size-zero arrays. */ + struct fiemap_extent fm_extents[1]; }; /* The maximum offset can be mapped for a file. */ From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 16 04:39:45 2011 Received: (at 9077-done) by debbugs.gnu.org; 16 Jul 2011 08:39:45 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Qi0PZ-0001bd-76 for submit@debbugs.gnu.org; Sat, 16 Jul 2011 04:39:45 -0400 Received: from mail1.slb.deg.dub.stisp.net ([84.203.253.98]) by debbugs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1Qi0PX-0001bR-Oo for 9077-done@debbugs.gnu.org; Sat, 16 Jul 2011 04:39:44 -0400 Received: (qmail 91886 invoked from network); 16 Jul 2011 08:39:37 -0000 Received: from unknown (HELO ?192.168.2.25?) (84.203.137.218) by mail1.slb.deg.dub.stisp.net with SMTP; 16 Jul 2011 08:39:37 -0000 Message-ID: <4E214DD2.8020002@draigBrady.com> Date: Sat, 16 Jul 2011 09:37:38 +0100 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3 MIME-Version: 1.0 To: Paul Eggert Subject: Re: bug#9077: coreutils-8.12: fiemap.h uses "struct fiemap_extent fm_extents[0]; " References: <003801cc41f4$33196630$994c3290$@schmitz-digital.de> <4E1ED6D5.2000801@draigBrady.com> <4E1F729F.4@cs.ucla.edu> <4E1F93AC.7030101@draigBrady.com> <4E1FCB56.8070101@cs.ucla.edu> <4E200D29.7070608@draigBrady.com> <4E20C30B.7030305@cs.ucla.edu> In-Reply-To: <4E20C30B.7030305@cs.ucla.edu> X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: 9077-done Cc: 9077-done@debbugs.gnu.org, Joachim Schmitz X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) On 15/07/11 23:45, Paul Eggert wrote: > On 07/15/11 02:49, Pádraig Brady wrote: >> +#ifdef __linux__ >> + struct fiemap_extent fm_extents[0]; >> +#endif > > This assumes that all GNU/Linux compiles will > use a compiler that allows size-zero arrays; > also, it assumes that sizeof (struct fiemap) > == offsetof (struct fiemap, fm_extents). > Although both assumptions are probably > portable in practice in this particular case, > it's better to avoid them, if avoiding them is easy. > This will help future-proof the code if we alter the > data structures, as altering them might cause problems > such as what I recently encountered in GNU Emacs's C code. > > How about the following further patch? It should do the trick. I tested that and it didn't work. Even though the *fiemap structs are the same in mem with and without the change, the ioctl() is returning ENOTTY when the array is of size 1. I guess this is because the array element is unpacked for the ioctl which is then failing kernel checks. cheers, Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 16 06:22:06 2011 Received: (at 9077-done) by debbugs.gnu.org; 16 Jul 2011 10:22:06 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Qi20c-0003sw-D8 for submit@debbugs.gnu.org; Sat, 16 Jul 2011 06:22:06 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Qi20a-0003sU-IO for 9077-done@debbugs.gnu.org; Sat, 16 Jul 2011 06:22:05 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 14FFD39E80E1; Sat, 16 Jul 2011 03:21:59 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3JMOadVxgecq; Sat, 16 Jul 2011 03:21:58 -0700 (PDT) Received: from [192.168.1.10] (pool-71-189-109-235.lsanca.fios.verizon.net [71.189.109.235]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 85CB039E80E0; Sat, 16 Jul 2011 03:21:58 -0700 (PDT) Message-ID: <4E216646.1040406@cs.ucla.edu> Date: Sat, 16 Jul 2011 03:21:58 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110516 Thunderbird/3.1.10 MIME-Version: 1.0 To: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= Subject: Re: bug#9077: coreutils-8.12: fiemap.h uses "struct fiemap_extent fm_extents[0]; " References: <003801cc41f4$33196630$994c3290$@schmitz-digital.de> <4E1ED6D5.2000801@draigBrady.com> <4E1F729F.4@cs.ucla.edu> <4E1F93AC.7030101@draigBrady.com> <4E1FCB56.8070101@cs.ucla.edu> <4E200D29.7070608@draigBrady.com> <4E20C30B.7030305@cs.ucla.edu> <4E214DD2.8020002@draigBrady.com> In-Reply-To: <4E214DD2.8020002@draigBrady.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -3.0 (---) X-Debbugs-Envelope-To: 9077-done Cc: 9077-done@debbugs.gnu.org, Joachim Schmitz X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.0 (---) On 07/16/11 01:37, P=C3=A1draig Brady wrote: > I guess this is because > the array element is unpacked for the ioctl which > is then failing kernel checks. That's odd, since as far as I can see, ioctl should see exactly the same bytes either way; the kernel doesn't know about the app's array elements, and all it should care about are the bytes. However, I've run out of ideas for debugging remotely. Perhaps this will have to wait until someone runs into the portability problem that I am merely hypothesizing. Thanks for looking into it, anyway. From unknown Mon Aug 18 00:06:42 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 13 Aug 2011 11:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator