author | René Scharfe <rene.scharfe@lsrfire.ath.cx> | |
Thu, 23 Nov 2006 22:02:37 +0000 (23:02 +0100) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Thu, 23 Nov 2006 22:20:32 +0000 (14:20 -0800) | ||
commit | 0ea865ce7af4b2b6ee85dc52b5fad84260e27871 | |
tree | 992fce6f9e24c1351e081bd57d37f60f1f5f0719 | tree | snapshot |
parent | e945f95157c2c515e763ade874931fc1eb671a0b | commit | diff |
archive-zip: don't use sizeof(struct ...)
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>
Signed-off-by: Junio C Hamano <junkio@cox.net>
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>
Signed-off-by: Junio C Hamano <junkio@cox.net>
archive-zip.c | diff | blob | history |