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

Re: [PATCH] Make strbuf_cmp inline, constify its arguments and optimize it a bit

From
FWFlorian Weimer <fweimer@bfk.de>
Date
Oct 8, 2007, 08:54 UTC
Message-ID
<82k5py6l6f.fsf@mid.bfk.de>
In-Reply-To
<20071008072312.GA22552@artemis.corp>
* Pierre Habouzit:
Show 6 quoted lines
>> So I think the last line can just be:
>> 
>>    return a->len - b->len;
>
>   Won't work because ->len are size_t and return value is int, so on 64
> bits platform, this has chances to overflow.
Nit: It can overflow on 32-bit, too.

And "int len" in the first line of the function body should be "size_t len".

Moving that to a compare_int/compare_size_t function should help; AFAIK there's no short idiom which does the job.

-- 
Florian Weimer                <fweimer@bfk.de>
BFK edv-consulting GmbH       http://www.bfk.de/
Kriegsstraße 100              tel: +49-721-96201-1
D-76133 Karlsruhe             fax: +49-721-96201-99
Previous: Pierre HabouzitNext: Alex Riesen
Message 15 of 25 in “mini-refactor in rerere.c”
  1. Pierre HabouzitSep 24, 2007
  2. Johannes SchindelinSep 24, 2007
  3. Junio C HamanoSep 26, 2007
  4. Pierre HabouzitSep 26, 2007
  5. Make strbuf_cmp inline, constify its arguments and optimize it a bitAlex Riesen, Oct 7, 2007
  6. Timo HirvonenOct 7, 2007
  7. Pierre HabouzitOct 7, 2007
  8. Miles BaderOct 7, 2007
  9. David KastrupOct 7, 2007
  10. Alex RiesenOct 7, 2007
  11. Wincent ColaiutaOct 7, 2007
  12. Alex RiesenOct 7, 2007
  13. Miles BaderOct 8, 2007
  14. Pierre HabouzitOct 8, 2007
  15. Florian WeimerOct 8, 2007
  16. Alex RiesenOct 8, 2007
  17. Johannes SchindelinOct 7, 2007
  18. Timo HirvonenOct 7, 2007
  19. Johannes SchindelinOct 7, 2007
  20. Pierre HabouzitOct 7, 2007
  21. David KastrupOct 7, 2007
  22. Alex RiesenOct 7, 2007
  23. David KastrupOct 7, 2007
  24. Alex RiesenOct 7, 2007
  25. Jeff KingOct 8, 2007

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.