On Mon, Mar 16, 2015 at 05:16:57PM -0400, Russell Bryant wrote: > On 03/16/2015 05:08 PM, Ben Pfaff wrote: > > On Mon, Mar 16, 2015 at 12:01:56PM -0400, Russell Bryant wrote: > >> I started working on a new command line utility that used this shared > >> code. I wanted the ability to pass some data from common > >> initialization code to all of the commands. You can find a similar > >> pattern in ovs-vsctl. > >> > >> This patch updates the command handler to take a new struct, > >> ovs_cmdl_context, instead of argc and argv directly. It includes argc > >> and argv, but also includes an opaque type (void *), where the user of > >> this API can attach its custom data it wants passed along to command > >> handlers. > >> > >> This patch affected the ovstest sub-programs, as well. The patch > >> includes a bit of an odd hack to OVSTEST_REGISTER() to avoid making > >> the main() function of the sub-programs take a ovs_cmdl_context. > >> The test main() functions still receive argc and argv directly, as > >> that seems more natural. The test-subprograms themselves are able to > >> make use of a context internally, though. > >> > >> Signed-off-by: Russell Bryant <rbry...@redhat.com> > > > > Thanks for the patch! > > > > I'm happy with this idea, although in writing it myself I would have a > > hard time deciding whether to include the void * pointer or to expect > > the caller to embed the structure into a larger one that could contain > > additional data. > > Hm, sure, that works too. I can't say I have much of a preference. I'd > be happy to change to the other if you'd prefer. > > I suppose embedding is slightly more efficient, though I don't expect > any of this to be in performance critical code paths.
It's not worth changing; just thinking out loud. _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev