git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] commit-slab: declare functions "static inline"

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Nov 25, 2013, 20:35 UTC
Message-ID
<20131125203557.GP4212@google.com>
In-Reply-To
<87wqjw1bm5.fsf@thomasrast.ch>
Thomas Rast wrote:
> Jonathan Nieder <jrnieder@gmail.com> writes:
>> Thomas Rast wrote:
Show 20 quoted lines
>>> This shuts up compiler warnings about unused functions.
>>
>> If that is the only goal, I think it would be cleaner to use
>>
>> 	#define MAYBE_UNUSED __attribute__((__unused__))
>>
>> 	static MAYBE_UNUSED void init_ ...
>>
>> like was done in the vcs-svn/ directory until cba3546 (drop obj_pool,
>> 2010-12-13) et al.
>>
>> I haven't thought carefully about whether encouraging inlining here
>> (or encouraging the reader to think of these functions as inline) is a
>> good or bad change.
>
> Hmm.
>
> I actually had this idea after seeing the same trick in khash.h.  Is
> __atribute__((__unused__)) universal?  If so, maybe we could apply the
> same also to khash?  If not, I'd rather go with the inline.

The khash functions are very small, so it very well may make sense for them to be inline.

git-compat-util.h (or compat/msvc.h) defines __attribute__(x) to an empty sequence of tokens except on HP C and gcc. Attribute unused has existed at least since GCC 2.95.

Unfortunately HP C doesn't support attribute __unused__. :( http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/Online_Help/pragmas.htm#Attributes

On the bright side, it would be easy to work around using a conditional definition of MAYBE_UNUSED for the sake of HP C. From August 2010 until March 2011 nobody noticed.

Jonathan
Previous: Thomas RastNext: Junio C Hamano
Message 13 of 18 in “commit-slab cleanups”
  1. 0/2 commit-slab cleanupsThomas Rast, Nov 25, 2013
  2. 1/2 commit-slab: document clear_$slabname()Thomas Rast, Nov 25, 2013
  3. Jonathan NiederNov 25, 2013
  4. Thomas RastNov 29, 2013
  5. Junio C HamanoNov 25, 2013
  6. Eric SunshineNov 27, 2013
  7. 2/2 commit-slab: declare functions "static inline"Thomas Rast, Nov 25, 2013
  8. Junio C HamanoNov 25, 2013
  9. Thomas RastNov 25, 2013
  10. commit-slab: declare functions "static inline"Thomas Rast, Nov 25, 2013
  11. Jonathan NiederNov 25, 2013
  12. Thomas RastNov 25, 2013
  13. Jonathan NiederNov 25, 2013
  14. Junio C HamanoNov 25, 2013
  15. Junio C HamanoNov 25, 2013
  16. Duy NguyenDec 1, 2013
  17. commit-slab: sizeof() the right type in xreallocThomas Rast, Dec 1, 2013
  18. Jeff KingDec 2, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.