On Wed, 28 Nov 2012 17:03:04 +0100, Mark Wielaard wrote:
I don't like a new field in struct Dwfl_Module that is only used
this single thing. So if we can store the state somewhere else that
would be nice.
I had the same issue, this is was one of the reasons I used the USERDATA
I see what you are saying can happen theoretically, but have a
trouble imagining when this would every happen. If you are just using
parse_argp for command line parsing I don't really see how that would
happen. Are you thinking of some server program that would reuse
dwfl_standard_argp () multiple times?
There are two issues:
Reusing of USERDATA instead of separate Dwfl_Module->executable_for_core:
The problem is that Dwfl_Module will remain without opening its Elf file
possibly very long from the parse_opt call till someone requests the Elf file.
So the USERDATA field is in fact used indefinitely/permanently.
Using dwfl_standard_argp () multiple times:
I agree this is very unlikely. But I find good coding practice to never use
global variables. And the field state->hook vs. field state->input and their
handling in ARGP_KEY_ERROR etc. is already so cryptic that if the original
author could use a global variable I am certain he would certainly do it.
He did not so I did not want to break this reentrancy validity of code.