While I'm not a big fan of the "lookup" APIs myself, if they exist implementations should be able to use them I think.
Does the nesting violate any coding style restrictions? ret = odp_shm_free(odp_shm_lookup("shm_odp_cos_tbl")); -----Original Message----- From: Taras Kondratiuk [mailto:taras.kondrat...@linaro.org] Sent: Wednesday, February 18, 2015 11:01 AM To: Robbie King (robking) Cc: Mike Holmes; lng-odp@lists.linaro.org; Petri Savolainen (petri.savolai...@linaro.org) Subject: Re: [lng-odp] [PATCH v2 00/10] add global and local termination On 02/18/2015 05:53 PM, Robbie King (robking) wrote: > Hey Mike (and everyone else), > > I noticed this code is replicated throughout the patch: > > cos_shm = odp_shm_lookup("shm_odp_cos_tbl"); > if (cos_shm == ODP_SHM_INVALID) > return -1; > ret = odp_shm_free(cos_shm); > > As I was looking to make the changes we discussed (continue > on versus returning -1) it seemed instead of replicating > even more code it would be better to have some cleaner way > of doing this. > > One possibility is to simply nest the calls (shm_free just > returns -1 if passed SHM_INVALID). > > ret = odp_shm_free(odp_shm_lookup("shm_odp_cos_tbl")); > > Another option is to create a helper function, something like: > > ret = odp_shm_free_by_name("shm_odp_cos_tbl"); > > If the helper is the way to go, then it could either be internal > or published API. Any thoughts on the "correct solution"? > > 1) nested calls > 2) internal API > 3) published API I prefer a forth option :) Save allocated odp_shm_t handle and don't lookup it. _______________________________________________ lng-odp mailing list lng-odp@lists.linaro.org http://lists.linaro.org/mailman/listinfo/lng-odp