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

Re: [PATCH] Fix git to be (more) ANSI C99 compliant.

From
FFFlorian Forster <octo@verplant.org>
Date
Jun 18, 2006, 08:21 UTC
Message-ID
<20060618082103.GA1331@verplant.org>
In-Reply-To
<20060618110749.e6fb9030.tihirvon@gmail.com>
Hi,
On Sun, Jun 18, 2006 at 11:07:49AM +0300, Timo Hirvonen wrote:
> Many of the void-pointer arithmetic warnings could be fixed by
> changing the variable types to char * instead of casting them in many
> places.

true. Casting to a void-pointer can be done implicitely (even according to the standard), so changing a function's argument from `void *' to `char *' might break code somewhere else.

Show 6 quoted lines
> > -			struct {
> > -				struct combine_diff_path p;
> > -				struct combine_diff_parent filler[5];
> > -			} combine;
> 
> Yes this is somewhat ugly but avoids a malloc.

No, malloc is still needed to allocate `combine.p.path'. My change does allocate all memory in one pass, so the number of calls to malloc doesn't differ.

> Leave the code as it is now unless it causes real problems.

`struct combine_diff_path' has a flexible array member (FAM) and is therefore an incomplete type. This means you may not instanciate it.

GCC ignores the FAM in this case and allocates `sizeof (struct combine_diff_path)' bytes. However, this is not correct according to ANSI and prevents building using other compilers (e.g. Sun cc).

To be honest, I don't get the point of FAMs anyways. Why don't we just use a pointer to `struct combine_diff_parent' there in the first place?

> 'A'...'Z' is more readable.  Does some compiler fail to compile it?
It's not in ANSI, therefore GCC with `-ansi' failes, so does the Sun cc.
> >  static inline int needs_quote(int ch)
> 
> Hmm.. same function in http-fetch.c.  Lots of common code could be
> moved to http.h.
Right, I wanted to keep the changes as minimal as possible, though.

As you can probably tell my goal is building a Solaris version of git using the Sun cc. I'm not quite there yet and don't have time to look into the remaining issue(s) today nor tomorrow, but I might have some time at the end of the week.

Regards, -octo

-- 
Florian octo Forster
Hacker in training
GnuPG: 0x91523C3D
http://verplant.org/
Previous: Thomas GlanzmannNext: Timo Hirvonen
Message 4 of 15 in “Fix git to be (more) ANSI C99 compliant.”
  1. Fix git to be (more) ANSI C99 compliant.Florian Forster, Jun 18, 2006
  2. Timo HirvonenJun 18, 2006
  3. Thomas GlanzmannJun 18, 2006
  4. Florian ForsterJun 18, 2006
  5. Timo HirvonenJun 18, 2006
  6. Rene ScharfeJun 18, 2006
  7. Florian ForsterJun 18, 2006
  8. 0/7 Improve ANSI C99 complianceFlorian Forster, Jun 18, 2006
  9. Junio C HamanoJun 18, 2006
  10. Linus TorvaldsJun 18, 2006
  11. Florian ForsterJun 19, 2006
  12. Junio C HamanoJun 20, 2006
  13. Rene ScharfeJun 20, 2006
  14. Junio C HamanoJun 20, 2006
  15. Junio C HamanoJun 21, 2006

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.