1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-09-26 02:46:13 -04:00
elinks/src/cookies
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
..
cookies.c bug 764: Initialize the right member of union option_value 2012-11-03 22:16:32 +02:00
cookies.h Add cookies file format description to cookies.h. 2007-10-18 09:26:43 +02:00
dialogs.c get_opt_*: Add ses parameter 2007-08-28 17:24:59 +00:00
dialogs.h Declare element types of lists. 2007-07-26 22:47:23 +03:00
Makefile Fix parsetst building 2005-12-28 17:16:39 +01:00
parser.c Remove now useless $Id: lines. 2005-10-21 09:14:07 +02:00
parser.h Remove empty lines in start of header files 2005-11-15 11:33:27 +01:00
parsetst.c Remove now useless $Id: lines. 2005-10-21 09:14:07 +02:00