This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: glob.c warnings


On 09/04/2013 06:31 AM, Eric Blake wrote:
> [just now noticing an old thread]
> 
> On 06/03/2013 05:05 AM, Colin Watson wrote:
>> I get these warnings from a project using Gnulib 20130529:
>>
>>   glob.c:165:1: warning: '__leaf__' attribute has no effect on unit local functions [-Wattributes]
>>   glob.c:213:1: warning: '__leaf__' attribute has no effect on unit local functions [-Wattributes]
>>   glob.c:214:1: warning: '__leaf__' attribute has no effect on unit local functions [-Wattributes]
>>
>> These are from uses of __THROW on static functions.  Is it perhaps worth
>> using (and defining if necessary) __THROWNL instead, which I think would
>> pacify these warnings?
> 
> What version of gcc and what CFLAGS were you using?  Yes, this is
> probably worth fixing.

Indeed, reading
http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html states under
'leaf' that "The attribute has no effect on functions defined within the
current compilation unit.", and therefore __THROWNL is safe to use in
place of __THROW.  I propose the following patch to glibc, and will
install a counterpart patch into gnulib:

From c84321367fb6d1dc35c8d04e075f1315eddcc720 Mon Sep 17 00:00:00 2001
From: Eric Blake <eblake@redhat.com>
Date: Wed, 4 Sep 2013 17:02:47 -0600
Subject: [PATCH] glob: silence -Wattribute warnings

Colin Watson reported that some versions of gcc warn about
attribute leaf used on a static function, since it has no
effect on anything but external functions.

* posix/glob.c (next_brace_sub, prefix_array, collated_compare):
Use __THROWNL rather than __THROW on static functions.

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 ChangeLog    | 5 +++++
 posix/glob.c | 6 +++---
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1f29127..32613ae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-09-04  Eric Blake  <eblake@redhat.com>
+
+	* posix/glob.c (next_brace_sub, prefix_array, collated_compare):
+	Use __THROWNL rather than __THROW on static functions.
+
 2013-09-04  Joseph Myers  <joseph@codesourcery.com>

 	* conform/conformtest.pl (newtoken): Treat tokens not allowed as
diff --git a/posix/glob.c b/posix/glob.c
index 4c7dce5..ece71c1 100644
--- a/posix/glob.c
+++ b/posix/glob.c
@@ -193,7 +193,7 @@
 # define GET_LOGIN_NAME_MAX()	(-1)
 #endif
 
-static const char *next_brace_sub (const char *begin, int flags) __THROW;
+static const char *next_brace_sub (const char *begin, int flags) __THROWNL;

 #endif /* !defined _LIBC || !defined GLOB_ONLY_P */

@@ -208,8 +208,8 @@ extern int __glob_pattern_type (const char *pattern,
int quote)
     attribute_hidden;

 #if !defined _LIBC || !defined GLOB_ONLY_P
-static int prefix_array (const char *prefix, char **array, size_t n)
__THROW;
-static int collated_compare (const void *, const void *) __THROW;
+static int prefix_array (const char *prefix, char **array, size_t n)
__THROWNL;
+static int collated_compare (const void *, const void *) __THROWNL;


 /* Find the end of the sub-pattern in a brace expression.  */
-- 
1.8.3.1



-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]