bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH] hash: declare some functions with the warn_unused_result att


From: Eric Blake
Subject: Re: [PATCH] hash: declare some functions with the warn_unused_result attribute
Date: Mon, 08 Jun 2009 05:56:12 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.21) Gecko/20090302 Thunderbird/2.0.0.21 Mnenhy/0.7.6.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Eric Blake on 6/7/2009 9:51 PM:
> According to Jim Meyering on 6/6/2009 2:41 PM:
>> A few of the function declarations in hash.h could benefit from
>> gcc's warn_unused_result attribute, so I'm adding it:
> 
> Including one in hash.c itself:
> 
> hash.c: In function `hash_delete':
> hash.c:1015: warning: ignoring return value of `hash_rehash', declared
> with attribute warn_unused_result
> 
> We should fix this, and decide whether shrinking the hash table when
> deletion frees up a bucket is always possible, or else deal with memory
> allocation failure here, too.

Additionally, it looks like hash_rehash has a memory leak - if new_table
is allocated, but we later fail to allocate new_entry, the function
returns immediately without reclaiming new_table.  Which means that even
if an application is prepared to deal with a false return by trying other
means to reduce memory usage rather than just giving up with xalloc_die,
the leaked memory from the previous attempt will interfere.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkos/FwACgkQ84KuGfSFAYCADACgwm1bO7FqbqYAao9BS+Ue4NG5
J70AoIU22kJ2XGRwQKgIdn+roy3sP/VT
=g3W7
-----END PGP SIGNATURE-----




reply via email to

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