1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00
elinks/src/network
Kalle Olavi Niemitalo 8b00e1ef70 bug 764: Initialize the right member of union option_value
INIT_OPTION used to initialize union option_value at compile time by
casting the default value to LIST_OF(struct option) *, which is the
type of the first member.  On sparc64 and other big-endian systems
where sizeof(int) < sizeof(struct list_head *), this tended to leave
option->value.number as zero, thus messing up OPT_INT and OPT_BOOL
at least.  OPT_LONG however tended to work right.

This would be easy to fix with C99 designated initializers,
but doc/hacking.txt says ELinks must be kept C89 compatible.
Another solution would be to make register_options() read the
value from option->value.tree (the first member), cast it back
to the right type, and write it to the appropriate member;
but that would still require somewhat dubious conversions
between integers, data pointers, and function pointers.

So here's a rather more invasive solution.  Add struct option_init,
which is somewhat similar to struct option but has non-overlapping
members for different types of values, to ensure nothing is lost
in compile-time conversions.  Move unsigned char *path from struct
option_info to struct option_init, and replace struct option_info
with a union that contains struct option_init and struct option.
Now, this union can be initialized with no portability problems,
and register_options() then moves the values from struct option_init
to their final places in struct option.

In my x86 ELinks build with plenty of options configured in, this
change bloated the text section by 340 bytes but compressed the data
section by 2784 bytes, presumably because union option_info is a
pointer smaller than struct option_info was.
(cherry picked from elinks-0.12 commit e5f6592ee2)

Conflicts:
	src/protocol/fsp/fsp.c: All options had been removed in 0.13.GIT.
	src/protocol/smb/smb2.c: Ditto.
2012-11-03 22:16:32 +02:00
..
ssl bug 764: Initialize the right member of union option_value 2012-11-03 22:16:32 +02:00
connection.c Removed code using pipes for decompression and simplified decompress_data. 2010-09-24 16:12:35 +02:00
connection.h Removed code using pipes for decompression and simplified decompress_data. 2010-09-24 16:12:35 +02:00
dns.c Merge branch 'elinks-0.12' into elinks-0.13 2008-11-01 22:39:17 +02:00
dns.h Remove empty lines in start of header files 2005-11-15 11:33:27 +01:00
Makefile path_to_top -> top_builddir 2005-10-20 04:00:35 +02:00
progress.c Erase progress.timer before calling progress.timer_func 2008-06-15 11:27:19 +03:00
progress.h Remove empty lines in start of header files 2005-11-15 11:33:27 +01:00
socket.c On Windows safe_read or safe_write return -1 and set errno = EWOULDBLOCK 2012-05-25 19:43:10 +02:00
socket.h Bug 1013: Don't assume errno is between 0 and 100000 2008-08-03 17:56:41 +03:00
state.c Merge branch 'elinks-0.12' into elinks-0.13 2008-09-27 16:28:28 +03:00
state.h Merge branch 'elinks-0.12' 2009-07-24 18:32:25 +03:00