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

Re: [PATCH] archive-zip: don't use sizeof(struct ...)

From
Gerrit Pape <pape@smarden.org>
Date
Nov 24, 2006, 08:53 UTC
Message-ID
<20061124085357.21541.qmail@fd76b23131eb24.315fe32.mid.smarden.org>
In-Reply-To
<45661A7D.9070207@lsrfire.ath.cx>
On Thu, Nov 23, 2006 at 11:02:37PM +0100, Ren? Scharfe wrote:
Show 18 quoted lines
> We can't rely on sizeof(struct zip_*) returning the sum of
> all struct members.  At least on ARM padding is added at the
> end, as Gerrit Pape reported.  This fixes the problem but
> still lets the compiler do the summing by introducing
> explicit padding at the end of the structs and then taking
> its offset as the combined size of the preceding members.
> 
> As Junio correctly notes, the _end[] marker array's size
> must be greater than zero for compatibility with compilers
> other than gcc.  The space wasted by the markers can safely
> be neglected because we only have one instance of each
> struct, i.e. in sum 3 wasted bytes on i386, and 0 on ARM. :)
> 
> We still rely on the compiler to not add padding between the
> struct members, but that's reasonable given that all of them
> are unsigned char arrays.
> 
> Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Previous: René Scharfe
Message 13 of 13 in “sizeof(struct ...)”
  1. Gerrit PapeNov 23, 2006
  2. René ScharfeNov 23, 2006
  3. René ScharfeNov 23, 2006
  4. Andy WhitcroftNov 23, 2006
  5. René ScharfeNov 23, 2006
  6. Erik MouwNov 23, 2006
  7. René ScharfeNov 23, 2006
  8. Andy WhitcroftNov 23, 2006
  9. René ScharfeNov 23, 2006
  10. Erik MouwNov 23, 2006
  11. Junio C HamanoNov 23, 2006
  12. archive-zip: don't use sizeof(struct ...)René Scharfe, Nov 23, 2006
  13. Gerrit PapeNov 24, 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.